Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

xsd:any element and Name Space...

I am new to XML can anybody tell me how can i create an XML Schema for the XML below...

<?xml version='1.0'?>
<mum:university xmlns:mum='http://www.mumde.net/university'
xmlns:sim='http://www.mumde.net/simplefamily'
xmlns:det='http://www.mumde.net/detailedfamily'>
<mum:student name='bob'>
<sim:family>
<father name='jim'/>
<mother name='sara'/>
<brother name='josh'/>
</sim:family>
<mum:education school='brown' degree='BA' />
<mum:education school='ucla' degree='MFA' />
</mum:student>

<mum:student name='jill'>
<det:family>
<father name='ridgley'>
<brother name='carleton'/>
</father>
<mother name='mary'/>
<sister name='daphne'/>
</det:family>
<mum:education school='brown' degree='BA' />
<mum:education school='ucla' degree='MFA' />
</mum:student>
</mum:university>
[1356 byte] By [theone] at [2007-11-11 7:58:53]
# 1 Re: xsd:any element and Name Space...
I have tried my level best iand cameup with something..But it has some problem...

<?xml version='1.0' encoding='UTF-8'?>
<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:sim='http://www.mumde.net/simplefamily'
xmlns:det='http://www.mumde.net/detailedfamily'
targetNamespace='http://www.mumde.net/university'>

<xsd:element name='university' type='universityType' />

<xsd:complexType name='universityType'>
<xsd:sequence>
<xsd:element name='student' type='studentType' form='qualified' minOccurs='0' maxOccurs='unbounded'/>
</xsd:sequence>
</xsd:complexType>

<xsd:complexType name='studentType' >
<xsd:sequence>
<xsd:any minOccurs="1" maxOccurs="1"/>
<xsd:element name='education' type='educationElementType' form='unqualified' minOccurs='0' maxOccurs='unbounded' />
</xsd:sequence>
<xsd:attribute name='name' type='xsd:string' />
</xsd:complexType>

<xsd:complexType name='educationElementType'>
<xsd:attribute name='school' type='xsd:token' />
<xsd:attribute name='degree' type='degreeValueType' />
</xsd:complexType>

<xsd:simpleType name='degreeValueType' >
<xsd:restriction base='xsd:token'>
<xsd:enumeration value='BA'/>
<xsd:enumeration value='BS' />
<xsd:enumeration value='MFA' />
<xsd:enumeration value='MA'/>
<xsd:enumeration value='MS' />
<xsd:enumeration value='PhD' />
</xsd:restriction>
</xsd:simpleType>

<xsd:element name='family' type='familyType'/>

<xsd:complexType name='familyType'>
<xsd:sequence>
<xsd:element name='father' type='parentType' minOccurs='1' maxOccurs='1'/>
<xsd:element name='mother' type='parentType' minOccurs='1' maxOccurs='1'/>
<xsd:choice minOccurs='0' maxOccurs='unbounded'>
<xsd:element name='brother' type='siblingType' minOccurs='0' maxOccurs='unbounded' />
<xsd:element name='sister' type='siblingType' minOccurs='0' maxOccurs='unbounded' />
</xsd:choice>
</xsd:sequence>
<xsd:attribute name='student' type='xsd:string'/>
</xsd:complexType>

<xsd:complexType name='parentType'>
<xsd:choice minOccurs='0' maxOccurs='unbounded'>
<xsd:element name='brother' type='siblingType'/>
<xsd:element name='sister' type='siblingType' />
</xsd:choice>
<xsd:attribute name='name' type='xsd:string'/>
</xsd:complexType>

<xsd:complexType name='siblingType'>
<xsd:attribute name='name' type='xsd:string'/>
<xsd:attribute name='status' type='xsd:string'/>
</xsd:complexType>



</xsd:schema>
theone at 2007-11-11 23:28:36 >
# 2 Re: xsd:any element and Name Space...
The error i am getting is

Type 'degreeValueType' is not declared, or is not a simple type.
theone at 2007-11-11 23:29:47 >
# 3 Re: xsd:any element and Name Space...
If i remove >> targetNamespace='http://www.mumde.net/university'>

form <xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:sim='http://www.mumde.net/simplefamily'
xmlns:det='http://www.mumde.net/detailedfamily'
targetNamespace='http://www.mumde.net/university'>

It parese fine..But i think there is something wrong as It is not validating the Value restrictions..etc...

...Can anybody help...?
theone at 2007-11-11 23:30:42 >