OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Designing for extensibility using namespaces and schemas... and validat

[ Lists Home | Date Index | Thread Index ]
  • To: <xml-dev@lists.xml.org>
  • Subject: Designing for extensibility using namespaces and schemas... and validating
  • From: Gustav Lidén <gustav.liden@ctakt.com>
  • Date: Wed, 10 Sep 2003 15:20:52 +0200
  • Importance: Normal

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@ctakt.com
+46 (0)733 552805
+46 (0)31 818620





 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS