Jump to content
Sign in to follow this  
Guest hagai

can't validate xml with a schema

Recommended Posts

Guest hagai

Hi,I wrote an xml schema and an xml. I can't validate the xml against the schema, and I don't understand the error.This is the schema:

<?xml version="1.0" encoding="UTF-8"?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">	<xs:element name="MessageStream">		<xs:complexType>			<xs:sequence>				<xs:element name="APIMessage" type="APIMessage" maxOccurs="unbounded"/>			</xs:sequence>		</xs:complexType>	</xs:element>	<xs:complexType name="APIMessage" abstract="true">		<xs:attribute name="version" type="xs:float" use="required"/>	</xs:complexType>	<xs:complexType name="APISessionMessage" abstract="true">		<xs:complexContent>			<xs:extension base="APIMessage">				<xs:sequence>					<xs:element ref="UniqueID"/>				</xs:sequence>			</xs:extension>		</xs:complexContent>	</xs:complexType>	<xs:complexType name="AddMessageToConversation">		<xs:complexContent>			<xs:extension base="APISessionMessage">				<xs:sequence>					<xs:element ref="Text"/>				</xs:sequence>			</xs:extension>		</xs:complexContent>	</xs:complexType>	<xs:complexType name="MessageError">		<xs:complexContent>			<xs:extension base="APIMessage">				<xs:sequence>					<xs:element ref="EmbeddedMessage"/>				</xs:sequence>			</xs:extension>		</xs:complexContent>	</xs:complexType>	<xs:element name="UniqueID">		<xs:simpleType>			<xs:restriction base="xs:string">				<xs:pattern value="[a-zA-Z0-9]+@[a-zA-Z0-9]+@LP|GN"/>			</xs:restriction>		</xs:simpleType>	</xs:element>	<xs:element name="Text" type="xs:string"/>	<xs:element name="EmbeddedMessage">		<xs:complexType>			<xs:sequence>				<xs:any/>			</xs:sequence>		</xs:complexType>	</xs:element></xs:schema>

this is the xml:

<?xml version="1.0" encoding="UTF-8"?><!--Sample XML file generated by XMLSpy v2007 sp2 (http://www.altova.com)--><MessageStream xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="D:\test\xmlbeans\testschema.xsd">	<APIMessage xsi:type="MessageError" version="1.0">		<EmbeddedMessage>			<APIMessage xsi:type="AddMessageToConversation" version="1.0">				<UniqueID>12345@abcd@LP</UniqueID>				<Text>				       abcd				</Text>			</APIMessage>		</EmbeddedMessage>	</APIMessage></MessageStream>

I get an error on this line:

<APIMessage xsi:type="AddMessageToConversation" version="1.0">

the error is:while validating complex type {'anonymous'}, element <APIMessage> matched wildcard {##any}but no element declaration was found.Does anybody have an idea why this error occurs?Thanks,Hagai.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...