[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

  • To: <xml-dev@l...>
  • Subject: Designing for extensibility using namespaces and schemas... and validating
  • From: Gustav Lidén <gustav.liden@c...>
  • Date: Wed, 10 Sep 2003 15:20:52 +0200
  • Importance: Normal

urn xmlns
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!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.