Jump to content

complexType with multi child nodes?


Guest tim_perrett

Recommended Posts

Guest tim_perrett

Hi guysi have the folllowing xml structure...<?xml version="1.0" encoding="iso-8859-1"?><errorLog> <error codepage="100" date="2005-10-11"> <errorCode>-14</errorCode> <errorDesc>Error sdfoi sdfi sn dsikdskdskdkdf omfkfoo oo fdjg</errorDesc> </error> <error codepage="251" date="2005-10-12"> <errorCode>-14</errorCode> <errorDesc>Error sdfoi sdfi sn dsikdskdskdkdf omfkfoo oo fdjg</errorDesc> </error></errorLog>But what i cannont see how to do is define an element (not the root) that has child nodes, this is my xml schema...<?xml version="1.0" encoding="ISO-8859-1"?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"targetNamespace="http://www.w3schools.com"xmlns="http://www.w3schools.com"elementFormDefault="qualified"> <xs:element name="errorLog"> <xs:complexType> <xs:element name="error"> <xs:complexType> <xs:sequence> <xs:element name="errorCode" type="xs:string"/> <xs:element name="errorDesc" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element> </xs:complexType> </xs:element></xs:schema>But it fails on validation saying ' The 'http://www.w3.org/2001/XMLSchema:element' element is not supported in this context. An error occurred at , (9, 5).' so now im at a bit of a loss?Can anyone help me? Many thanks in advanceTim Perrett

Link to comment
Share on other sites

  • 4 months later...
Guest rdevaki
Hi guysi have the folllowing xml structure...<?xml version="1.0" encoding="iso-8859-1"?><errorLog> <error codepage="100" date="2005-10-11">  <errorCode>-14</errorCode>  <errorDesc>Error sdfoi sdfi sn dsikdskdskdkdf omfkfoo oo fdjg</errorDesc> </error> <error codepage="251" date="2005-10-12">  <errorCode>-14</errorCode>  <errorDesc>Error sdfoi sdfi sn dsikdskdskdkdf omfkfoo oo fdjg</errorDesc> </error></errorLog>But what i cannont see how to do is define an element (not the root) that has child nodes, this is my xml schema...<?xml version="1.0" encoding="ISO-8859-1"?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"targetNamespace="http://www.w3schools.com"xmlns="http://www.w3schools.com"elementFormDefault="qualified"> <xs:element name="errorLog">  <xs:complexType>  <xs:element name="error">  <xs:complexType>    <xs:sequence>    <xs:element name="errorCode" type="xs:string"/>    <xs:element name="errorDesc" type="xs:string"/>    </xs:sequence>  </xs:complexType>  </xs:element>  </xs:complexType> </xs:element></xs:schema>But it fails on validation saying ' The 'http://www.w3.org/2001/XMLSchema:element' element is not supported in this context. An error occurred at , (9, 5).' so now im at  a bit of a loss?Can anyone help me? Many thanks in advanceTim Perrett

Hi Tim Perrett,It seems look schema validation, Try this way...<?xml version="1.0" encoding="ISO-8859-1"?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"targetNamespace="http://www.w3schools.com"xmlns="http://www.w3schools.com"elementFormDefault="qualified"><xs:element name="error"><xs:complexType><xs:sequence><xs:element name="errorCode" type="xs:string"/><xs:element name="errorDesc" type="xs:string"/></xs:sequence></xs:complexType></xs:element></xs:schema>Thanks,Ram
Link to comment
Share on other sites

Guest hanson
:) try this ,i do it by using xmlspy ,according to ur xml :<?xml version="1.0" encoding="UTF-8"?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:element name="errorLog"> <xs:annotation> <xs:documentation>Comment describing your root element</xs:documentation> </xs:annotation> <xs:complexType> <xs:sequence> <xs:element name="error" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="errorCode" type="xs:int"/> <xs:element name="errorDesc" type="xs:string"/> </xs:sequence> <xs:attribute name="codepage" type="xs:long"/> <xs:attribute name="date" type="xs:date"/> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element></xs:schema>
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...