...

View Full Version : XML Restriction Problem



gold2040
05-06-2009, 12:09 PM
Hello

I'm working on an assignment and i'm trying to place a restriction on one of my XML values

here is my XML code



<cameras
xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation = 'cameras.xsd' >

<camera>
<model> Fujifilm Finepix J10 </model>
<price> 97.89 </price>
<megapixel> 3 </megapixel>
<image> camera.gif </image>
<logo> fujifilm.jpg </logo>
<blurb> Aluminium body. Movie capture with sound. 21 scene modes. Smile shutter. Previous catalogue price 199.99 </blurb>
<features>
<zoom> 10 </zoom>
<lcd> 2.5 </lcd>
<antiblur> Digital </antiblur>
<face> 10 </face>
<battery> Li-Ion </battery>
<format> SD/SDHC/xD </format>
<maxiso> 1600 </maxiso>
<depth> 1.9 </depth>
<catno> 559/1019 </catno>
</features>

</camera>

<camera>
<model> Sanyo E10 </model>
<price> 97.989 </price>
<megapixel> 10 </megapixel>
<image> camera2.gif </image>
<logo> sanyo.gif </logo>
<blurb> Aluminium body </blurb>
<features>
<zoom> 5 </zoom>
<lcd> 2.5 </lcd>
<antiblur> Digital </antiblur>
<face> 12 </face>
<battery> AA </battery>
<format> SD </format>
<maxiso> 2500 </maxiso>
<depth> 2.3 </depth>
<catno> 559/1325 </catno>
</features>

</camera>
<camera>
<model> Kodak M1063 </model>
<price> 87.99 </price>
<megapixel> 10 </megapixel>
<image> camera3.gif </image>
<logo> kodak.jpg </logo>
<blurb> Aluminium body </blurb>
<features>
<zoom> 3 </zoom>
<lcd> 2.7 </lcd>
<antiblur> Digital </antiblur>
<face> 3 </face>
<battery> Li-ion </battery>
<format> SD/SDHC </format>
<maxiso> 1000 </maxiso>
<depth> 2.1 </depth>
<catno> 580/1903 </catno>
</features>
</camera>

<camera>
<model> Sony 4GHDH </model>
<price> 87.99 </price>
<megapixel> 10 </megapixel>
<image> camera4.gif </image>
<logo> canon.gif </logo>
<blurb> Aluminium body </blurb>
<features>
<zoom> 3.3 </zoom>
<lcd> 2.5 </lcd>
<antiblur> Digital </antiblur>
<face> 9 </face>
<battery> AA </battery>
<format> SD/SDHC/MMC/MMC+</format>
<maxiso> 3200 </maxiso>
<depth> 15 </depth>
<catno> 580/0625 </catno>
</features>
</camera>

<camera>
<model> Sony 4GHDH </model>
<price> 136.99 </price>
<megapixel> 10 </megapixel>
<image> camera5.gif </image>
<logo> sony.gif </logo>
<blurb> Aluminium body </blurb>
<features>
<zoom> 4 </zoom>
<lcd> 2.7 </lcd>
<antiblur> Digital </antiblur>
<face> 0 </face>
<battery> Li-ion </battery>
<format> MSPD </format>
<maxiso> 0 </maxiso>
<depth> 2.9 </depth>
<catno> 580/1930 </catno>
</features>
</camera>

</cameras>


and here is my XSD code



<?xml version= "1.0" encoding= "UTF-8"?>

<xs:schema xmlns:xs = 'http://www.w3.org/2001/XMLSchema'>

<xs:element name= "cameras">

<xs:complexType>
<xs:sequence>
<xs:element ref = "camera" maxOccurs = 'unbounded' />
</xs:sequence>
</xs:complexType>

</xs:element>

<xs:element name= "camera">

<xs:complexType>
<xs:sequence>
<xs:element name = "model" type = "xs:string" />
<xs:element name = "price" type = "xs:decimal" />
<xs:element name = "megapixel" type = "xs:integer" />
<xs:element name = "image" type = "xs:string" />
<xs:element name = "logo" type = "xs:string" />
<xs:element name = "blurb" type = "xs:string" />
<xs:element ref = "features" />
</xs:sequence>
</xs:complexType>

</xs:element>

<xs:element name="megapixel">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:minInclusive value="5"/>
<xs:maxInclusive value="15"/>
</xs:restriction>
</xs:simpleType>
</xs:element>


<xs:element name= "features">
<xs:complexType>
<xs:sequence>
<xs:element name = "zoom" type="xs:decimal" />
<xs:element name = "lcd" type="xs:decimal" />
<xs:element name = "antiblur" type="xs:string" />
<xs:element name = "face" type="xs:string" />
<xs:element name = "battery" type="xs:string" />
<xs:element name = "format" type="xs:string" />
<xs:element name = "maxiso" type="xs:decimal" />
<xs:element name = "depth" type="xs:decimal" />
<xs:element name = "catno" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>

</xs:schema>


the value I am using is "megapixel"
I am using a version of JEdit which is the software used on my course which has been customized
when I build and validate the code with a value 5 or over it validates fine
when I build and validate the code with a value less then 5 it still validates fine

am I doing something wrong?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum