|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
xml schema problem
Hi
I am writing a schema for an XML document i would like the document to have a structure such as the the one below ------------------------------------------------------------ <?xml version="1.0"?> <group xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation='lr2.xsd'> <house ref="3" name="Waseem House"> <room ref="3443" type="Standard" beds="2"> <price day="2004-06-30">222.99</lrate_price> <price day="2004-06-29">222.99</lrate_price> </room> </house> </group> ----------------------------------------------------------- This means the element price must have an attributre and an element value i cant get this to work in my schema, when i do this it says that the element price cant have a simple type "type" and a complex type attribute [i am using perl / xerces] my schema is below <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'> <xs:element name="group"> <xs:complexType> <xs:sequence> <xs:element ref="house" minOccurs='1' maxOccurs='unbounded'/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="house"> <xs:complexType> <xs:sequence> <xs:element ref="room" minOccurs='1' maxOccurs='unbounded'/> </xs:sequence> <xs:attribute name="ref" type="xs:integer" use='required'/> <xs:attribute name="name" type="xs:string" use='required'/> </xs:complexType> </xs:element> <xs:element name="room"> <xs:complexType> <xs:sequence> <xs:element ref="price" type="lratetype" minOccurs='1' maxOccurs='unbounded'/> </xs:sequence> <xs:attribute name="ref" type="xs:integer" use='required'/> <xs:attribute name="type" type="xs:string" use='required'/> <xs:attribute name="beds" type="xs:integer" use='required'/> </xs:complexType> </xs:element> <xs:element name="price" type="xs:decimal"> <xs:complexType> <xs:attribute name="day" type="xs:date" use='required'/> </xs:complexType> </element> </xs:schema> ---------------------------------------------------------- Im not sure what i am doing wrong as i need to make sure the text in the price element is of decimal , do i need to use the restriction syntax ? Waseem |
|
#2
|
|||
|
|||
|
I think maybe you need to looak at your xml file first.
It's not exactly well formed, you should not put (xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation='lr2.xsd') into the root. And (<price day="2004-06-30">222.99</lrate_price>) must be changed to (<price day="2004-06-30">222.99</price>) |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > xml schema problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|