W3C home > Mailing lists > Public > xmlschema-dev@w3.org > December 2003

Question about redefine with extension using choice

From: Justin Makeig <lists@makeig.com>
Date: Mon, 15 Dec 2003 15:59:21 -0800
To: <xmlschema-dev@w3.org>
Message-Id: <E1AW2cI-0006P7-BK@hyperion.site5.com>

I've got a strange and complicated problem that I can't quite seem to figure
out. 
I wrote my own pseudo-XHTML schema (excerpted in XHTML.xsd below). I would
like to use types from this schema across other schemas (in other
namespaces) so that text the vocabulary used to build blocks of structured
text is the same XHTML across my application. However, to make things
complicated I need to extend my XHTML's vocabulary to include some of my own
application-specific custom elements. For example, I'd like to be able to
write something like

	<other:Body>
		<xhtml:p>Some text in a mixed
<xhtml:acronym>XHTML</xhtml:acronym> and <txt:KeyTerm>custom</txt:KeyTerm>
vocabulary. </xhtml:p>
	</other:Body>

in my instance docs, where xhtml:p contains text nodes, inline XHTML, or
custom inline elements from the txt namespace. Each of these inline elements
can nest other inline elements from either namespace.

I use the XHTMLExtension schema (below in its entirety) to redefine how
inline elements from the XHTML namespace (e.g. span and em) so that they
also include the inline elements from my custom txt namespace. However, as
things are below, any element that can accommodate an inline element from
the xhtml or txt namespaces must have at least one, thus creating an
infinite loop. However, when I try to put a minOccurs="0" on the choice or
element elements in the redefine in XHTMLExtension, it get a "Unique
Particle Attribution" error.

I hope I've explained this adequately. Any help would be much appreciated.

Thanks.

- Justin Makeig

XHTMLExtension.xsd
==================
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
	xmlns:xhtml="http://www.mycompany.com/2.0/xhtml"
	xmlns:txt="http://www.mycompany.com/2.0/structuredtext"
	xmlns:link="http://www.mycompany.com/2.0/link"
	targetNamespace="http://www.mycompany.com/2.0/xhtml"
	elementFormDefault="qualified">
	
	<xs:import namespace="http://www.mycompany.com/2.0/structuredtext"
schemaLocation="StructuredText.xsd"/>
	<xs:import namespace="http://www.mycompany.com/2.0/link"
schemaLocation="Link.xsd"/>
	
	<xs:redefine schemaLocation="XHTML.xsd">
		<xs:complexType name="InlineContentType" mixed="true">
			<xs:complexContent>
				<xs:extension
base="xhtml:InlineContentType">
					<xs:choice>
						<xs:element
ref="txt:KeyTerm"/>
						<xs:element
ref="txt:KeyDate"/>
						<xs:element
ref="link:CrossRef"/>
					</xs:choice>
				</xs:extension>
			</xs:complexContent>
		</xs:complexType>
	</xs:redefine>
</xs:schema>

StructuredText.xsd
==================
<xs:import namespace="http://www.mycompany.com/2.0/xhtml"
schemaLocation="XHTMLExtension.xsd"/>
...snip...
<xs:element name="KeyDate">
	<xs:complexType>
		<xs:simpleContent>
			<xs:extension base="xs:string">
				<xs:attribute name="date" type="xs:date"
use="required"/>
			</xs:extension>
		</xs:simpleContent>
	</xs:complexType>
</xs:element>

...snip...


XHTML.xsd
=========
...snip...
<xs:element name="p" type="xhtml:InlineContentType"/>

<xs:complexType name="InlineContentType" mixed="true">
	<xs:choice>
		<xs:group ref="xhtml:InlineGroup" minOccurs="0"
maxOccurs="unbounded"/>
	</xs:choice>
	<xs:attributeGroup ref="xhtml:CommonAttGroup"/>
</xs:complexType>

<xs:group name="InlineGroup">
	<xs:choice>
		<xs:element ref="xhtml:span" minOccurs="0"
maxOccurs="unbounded"/>
		<xs:element ref="xhtml:em" minOccurs="0"
maxOccurs="unbounded"/>
		<xs:element ref="xhtml:strong" minOccurs="0"
maxOccurs="unbounded"/>
		<xs:element ref="xhtml:code" minOccurs="0"
maxOccurs="unbounded"/>
		<xs:element ref="xhtml:acronym" minOccurs="0"
maxOccurs="unbounded"/>
		<xs:element ref="xhtml:abbr" minOccurs="0"
maxOccurs="unbounded"/>
	</xs:choice>
</xs:group>
...snip...
Received on Monday, 15 December 2003 18:59:25 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:40 GMT