Schema Validation Issues

From: Date: Mon, 06 Sep 2004 10:30:15 +0000
Subject: Schema Validation Issues
Groups: php.xml.dev 
Request: Send a blank email to php-xml-dev+get-452@lists.php.net to get a copy of this message
Hey all. On seeing the new DOM XML/XSLT/XPath et al integration with PHP5 I thought - finally! However, that didn't last too long :) I'm almost certain this isn't an issue with the new systems ... more likely an issue with my old brain ... but thought I'd head to the source for any advice/pointers/flamings as required. Anyway .. enough rambling ... the issue: I have an xml schema and an xml sample file that should validate against the schema. I get the error 'Invalid Schema' and I was pretty sure the schema was right ... To double-check I used an old example schema (from on of the Visual Quickstart Guides I picked up 5 years ago) thinking this should work - it did before :) I Ran the schema across it's own sample xml file and got same error. I then ran the schema against the wc3 schema validation service and it 'seems' to validate? Pasted below is the schema file and the xml file being validated. What have I missed here? Anyone? ----- SCHEMA FILE ----- <?xml version="1.0"?> <xsd:schema xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"> <xsd:element name="endangered_species" type="endspeciesType"/> <xsd:complexType name="endspeciesType"> <xsd:sequence> <xsd:element name="animal" type="animalType" maxOccurs="unbounded"/> </xsd:sequence> </xsd:complexType> <xsd:complexType name="animalType"> <xsd:sequence> <xsd:element ref="name" minOccurs="1" maxOccurs="unbounded"/> <xsd:element name="threats" type="threatsType"/> <xsd:element name="weight" type="xsd:string" minOccurs="0"/> <xsd:element name="length" type="xsd:string" minOccurs="0"/> <xsd:element ref="source"/> <xsd:element name="picture" type="pictureType"/> <xsd:element name="subspecies" type="subspeciesType" minOccurs="1" maxOccurs="unbounded"/> </xsd:sequence> </xsd:complexType> <!--Here are the global declarations of the name and source elements. Notice that they are considerably simplified for this example. --> <xsd:element name="name" type="xsd:string"/> <xsd:element name="source" type="xsd:string"/> <xsd:complexType name="threatsType"> <xsd:sequence> <xsd:element name="threat" type="xsd:string" maxOccurs="unbounded"/> </xsd:sequence> </xsd:complexType> <xsd:complexType name="pictureType"> <xsd:complexContent> <xsd:restriction base="xsd:anyType"> <xsd:attribute name="filename" type="xsd:uriReference" use="required"/> <xsd:attribute name="x" type="xsd:integer"/> <xsd:attribute name="y" type="xsd:integer"/> </xsd:restriction> </xsd:complexContent> </xsd:complexType> <xsd:complexType name="subspeciesType"> <xsd:sequence> <xsd:element ref="name" minOccurs="1" maxOccurs="unbounded"/> <xsd:element name="region" type="xsd:string"/> <xsd:element name="population"> <xsd:complexType> <xsd:simpleContent> <xsd:extension base="xsd:nonNegativeInteger"> <xsd:attribute name="year" type="xsd:year"/> </xsd:extension> </xsd:simpleContent> </xsd:complexType> </xsd:element> </xsd:sequence> </xsd:complexType> </xsd:schema> ---- END --- --- XML file --- <?xml version="1.0"?> <endangered_species xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.cookwood.com/xml/examples/namespac es/global_endspecies.xsd"> <animal> <name>Tiger</name> <name>panthera tigris</name> <threats><threat>poachers</threat> <threat>habitat destruction</threat> <threat>trade in tiger bones for traditional Chinese medicine (TCM)</threat> </threats> <weight>500 pounds</weight> <length>3 yards from nose to tail</length> <source>World Wildlife Fund</source> <picture filename="tiger.jpg" x="200" y="197"/> <subspecies> <name>Amur or Siberian</name> <name>P.t. altaica</name> <region>Far East Russia</region> <population year="1999">445</population> </subspecies> <subspecies> <name>Balian</name> <name>P.t. balica</name> <region>Bali</region> <population year="1937">0</population> </subspecies> <subspecies> <name>Javan</name> <name>P.t. sondaica</name> <region>Java</region> <population year="1972">0</population> </subspecies> <subspecies> <name>Caspian</name> <name>P.t. virgata</name> <region>Caspian Sea</region> <population year="1950">0</population> </subspecies> <subspecies> <name>Bengal</name> <name>P.t. tigris</name> <region>India</region> <population year="1999">3159</population> </subspecies> <subspecies> <name>Sumatran</name> <name>P.t. sumatrae</name> <region>India, Bangladesh</region> <population year="1999">400</population> </subspecies> <subspecies> <name>Amoy</name> <name>P.t. amoyensis</name> <region>South China</region> <population year="1999">20</population> </subspecies> <subspecies> <name>Indo-chinese</name> <name>P.t. corbetti</name> <region>Indo-China</region> <population year="1998">1227</population> </subspecies> </animal> <animal> <name>Black Rhino</name> <name>diceros bicornis</name> <threats><threat>poaching to satisfy demand for rhino horn in traditional Asian medicines and as decorative dagger handles in Middle East</threat> <threat>habitat destruction</threat> </threats> <source>World Wildlife Fund</source> <picture filename="rhino.jpg" x="200" y="158"/> <subspecies> <name>Southern Black Rhino</name> <name>D.b. minor</name> <region>Zimbabwe and South Africa</region> <population year="1999">1365</population> </subspecies> <subspecies> <name>Southwestern Black Rhino</name> <name>D.b. bicornis</name> <region>Namibia</region> <population year="1999">740</population> </subspecies> <subspecies> <name>Eastern Black Rhino</name> <name>D.b. michaeli</name> <region>Kenya (Ethiopia and Rwanda)</region> <population year="1999">485</population> </subspecies> <subspecies> <name>Northwestern Black Rhino</name> <name>D.b. longipes</name> <region>Cameroon</region> <population year="1999">10</population> </subspecies> </animal> </endangered_species> ---- END ---

« previous php.xml.dev (#452) next »