Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

element is not declared. An error occurred...

Status
Not open for further replies.

DaZZleD

Programmer
Oct 21, 2003
886
0
0
US
hi everybody.

I have an XML that looks like this
Code:
<InterOpMessage xmlns="[URL unfurl="true"]http://www.apl.ro/interop">[/URL]
	<EnvelopeVersion>1.0</EnvelopeVersion>
	<Header>
		<MessageDetails>
			<Class>ITL_DECC_01</Class>
			<Timestamp></Timestamp>
		</MessageDetails>
		<SenderDetails>
			<IDAuthentication>
				<SenderID>1547</SenderID>
			</IDAuthentication>
		</SenderDetails>
	</Header>
	<InterOpDetails />
	<Body />
</InterOpMessage>

and an xsd schema that I want to validate the xml. the schema is
Code:
<?xml version="1.0" ?>
<xsd:schema targetNamespace="[URL unfurl="true"]http://www.apl.ro/interop"[/URL] xmlns:xsd="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema"[/URL] 

xmlns="[URL unfurl="true"]http://www.apl.ro/interop"[/URL]
	xmlns:gt="[URL unfurl="true"]http://www.apl.ro/interop"[/URL] attributeFormDefault="unqualified" elementFormDefault="qualified" version="2.0" 

id="interOpMessage_Envelope">
	<xsd:element name="interOpMessage">
		<xsd:complexType>
			<xsd:sequence>
				<xsd:element name="EnvelopeVersion" type="xsd:string" />
				<xsd:element name="Header">
					<xsd:complexType>
						<xsd:sequence>
							<xsd:element name="MessageDetails">
								<xsd:complexType>
									<xsd:sequence>
										<xsd:element name="Class">
											<xsd:simpleType>
												<xsd:restriction 

base="gt:UnicodeNameString">
													<xsd:maxLength value="32" />
													<xsd:minLength value="4" />
												</xsd:restriction>
											</xsd:simpleType>
										</xsd:element>
										<xsd:element name="Timestamp" type="xsd:dateTime" 

minOccurs="0" />
									</xsd:sequence>
								</xsd:complexType>
							</xsd:element>
							<xsd:element name="SenderDetails" minOccurs="0">
								<xsd:complexType>
									<xsd:sequence>
										<xsd:element ref="gt:IDAuthentication" minOccurs="0" 

/>
									</xsd:sequence>
								</xsd:complexType>
							</xsd:element>
						</xsd:sequence>
					</xsd:complexType>
				</xsd:element>
				<xsd:element name="InterOpDetails">
					<xsd:complexType>
						<xsd:sequence>
							<xsd:element name="Keys" minOccurs="0">
								<xsd:complexType>
									<xsd:sequence>
										<xsd:element name="Key" minOccurs="0" 

maxOccurs="unbounded">
											<xsd:complexType>
												<xsd:simpleContent>
													<xsd:extension 

base="gt:UnicodeNameString">
														<xsd:attribute 

name="Type" type="gt:UnicodeNameString" use="required" />
													</xsd:extension>
												</xsd:simpleContent>
											</xsd:complexType>
										</xsd:element>
									</xsd:sequence>
								</xsd:complexType>
							</xsd:element>
						</xsd:sequence>
					</xsd:complexType>
				</xsd:element>
				<xsd:element name="Body" minOccurs="0">
					<xsd:complexType>
						<xsd:sequence>
							<xsd:element name="Data" minOccurs="0">
								<xsd:complexType>
									<xsd:sequence>
										<xsd:any namespace="##any" processContents="lax" 

minOccurs="0" maxOccurs="unbounded" />
									</xsd:sequence>
									<xsd:anyAttribute namespace="##any" />
								</xsd:complexType>
							</xsd:element>
						</xsd:sequence>
					</xsd:complexType>
				</xsd:element>
			</xsd:sequence>
		</xsd:complexType>
	</xsd:element>
	<xsd:element name="IDAuthentication">
		<xsd:complexType>
			<xsd:sequence>
				<xsd:element name="SenderID" type="xsd:string" minOccurs="0" />
			</xsd:sequence>
		</xsd:complexType>
	</xsd:element>
	<xsd:simpleType name="UnicodeNameString">
		<xsd:restriction base="xsd:string">
			<xsd:pattern value="[\p{L}\p{Nd}_\-\(\)\{\}]*" />
		</xsd:restriction>
	</xsd:simpleType>
</xsd:schema>

i'm using VS 2003 and when I try to validate the xml I get the following error:
Code:
The '[URL unfurl="true"]http://www.apl.ro/interop:InterOpMessage'[/URL] element is not declared. An error occurred at , (1, 2).

--------------------------
"two wrongs don't make a right, but three lefts do" - the unknown sage
 
I think the problem is that in your XSD you're doing this:
Code:
xmlns="[URL unfurl="true"]http://www.apl.ro/interop"[/URL]
    xmlns:gt="[URL unfurl="true"]http://www.apl.ro/interop"[/URL]
If I have it right, this is saying that your URL is in both the default namespace and the "gt" namespace.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
if i remember correctly, i had to add the gt namespace to make references to elements in the same schema (like IDAuthentication) in this case...

anyway, the error is the same for all the elements in the xml...

--------------------------
"two wrongs don't make a right, but three lefts do" - the unknown sage
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top