|
[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Designing for extensibility using namespaces and schemas... and validat
Hi xml-dev, I am considering a design for representing a "collection of parts", where the "parts" can be of different types but linked together by the "collection". I want to be able to output the collection as an xml-document, but also the parts as documents in themselves (that follow an xsd). I also want to be able to add new types of parts in the future. My idea is using a set of schemas and namespaces: [Collection.xsd] <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns="urn:xmlns:test:collection" targetNamespace="urn:xmlns:test:collection"> <xs:element name="Collection" type="CollectionType"/> <xs:complexType name="CollectionType"> <xs:sequence> <xs:any namespace="##other" processContents="strict" minOccurs="1" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> </xs:schema> [Part1.xsd] <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns="urn:xmlns:test:part1" targetNamespace="urn:xmlns:test:part1"> <xs:element name="Part1" type="Part1Type"/> <xs:complexType name="Part1Type"> <xs:simpleContent> <xs:extension base="xs:string"> <xs:attribute name="part1Attr" type="xs:string"/> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:schema> [Part2.xsd] <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns="urn:xmlns:test:part2" targetNamespace="urn:xmlns:test:part2"> <xs:element name="Part2" type="Part2Type"/> <xs:complexType name="Part2Type"> <xs:simpleContent> <xs:extension base="xs:string"> <xs:attribute name="part2Attr" type="xs:string"/> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:schema> ...and then have resulting xml files similar to this: [Collection.xml] <c:Collection xmlns:c="urn:xmlns:test:collection" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:xmlns:test:collection Collection.xsd"> <p1:Part1 part1Attr="p1a" xmlns:p1="urn:xmlns:test:p1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:xmlns:test:part1 Part1.xsd"/> <p2:Part2 part2Attr="p2a" xmlns:p2="urn:xmlns:test:p2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:xmlns:test:part1 Part2.xsd"/> </c:Collection> Now, trying this out, XMLSpy validates this without complaint but Schematron reports that <p1:Part1> is used but not declared in the schema. Is Collection.xml a valid xml-file? Doesn't the processContents="strict" attribute of <xs:any> say that elements should be validated using an xsd found using xsi:schemaLocation? What other designs should I consider? Best regards, Gustav Lidén ---------------------- Gustav Lidén C-takt AB gustav.liden@c... +46 (0)733 552805 +46 (0)31 818620
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|
|||||||||

Cart








