RE: recursive interleaving -- is it possible

This should work for question a and question b :

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
elementFormDefault="qualified">
	<!--
	
	
		Part a of your question
	-->
	<xsd:element name="primitive">
		<xsd:complexType>
			<xsd:attribute name="name" type="xsd:string"/>
		</xsd:complexType>
		<xsd:key name="primitive_key">
			<xsd:selector xpath="."/>
			<xsd:field xpath="@name"/>
		</xsd:key>
	</xsd:element>
	<!--
	
	
	
		Part b of your question
	-->
	<xsd:element name="functionOf">
		<xsd:complexType>
			<xsd:choice>
				<xsd:element ref="functionOf"/>
				<xsd:element name="primitive">
					<xsd:complexType>
						<xsd:attribute name="name"/>
					</xsd:complexType>
				</xsd:element>
			</xsd:choice>
		</xsd:complexType>
		<xsd:keyref name="functionOf_keyref" refer="primitive_key">
			<xsd:selector xpath="//primitive"/>
			<xsd:field xpath="@name"/>
		</xsd:keyref>
	</xsd:element>
	<xsd:element name="recursiveFunction">
		<xsd:complexType>
			<xsd:sequence>
				<xsd:element ref="functionOf"/>
			</xsd:sequence>
		</xsd:complexType>
	</xsd:element>
</xsd:schema>




For question c :
You should modify the definition of element "functionOf" and add the
definition of "injectionOf" :
	<xsd:element name="functionOf">
		<xsd:complexType>
			<xsd:choice>
				<xsd:element ref="injectionOf"/>
				<xsd:element name="primitive">
					<xsd:complexType>
						<xsd:attribute name="name"/>
					</xsd:complexType>
				</xsd:element>
			</xsd:choice>
		</xsd:complexType>
		<xsd:keyref name="functionOf_keyref" refer="primitive_key">
			<xsd:selector xpath="//primitive"/>
			<xsd:field xpath="@name"/>
		</xsd:keyref>
	</xsd:element>
	
	<xsd:element name="injectionOf">
		<xsd:complexType>
			<xsd:choice>
				<xsd:element ref="functionOf"/>
				<xsd:element name="primitive">
					<xsd:complexType>
						<xsd:attribute name="name"/>
					</xsd:complexType>
				</xsd:element>
			</xsd:choice>
		</xsd:complexType>
		<xsd:keyref name="functionOf_keyref" refer="primitive_key">
			<xsd:selector xpath="//primitive"/>
			<xsd:field xpath="@name"/>
		</xsd:keyref>
	</xsd:element>

For questions d and e ... it's more expensive :o)

hope this can help.
Freddy.



-----Message d'origine-----
De : Ziv Hellman [mailto:ziv@unicorn.com]
Envoy? : jeudi 15 mars 2001 21:42
? : xmlschema-dev@w3.org
Objet : recursive interleaving -- is it possible



Hi ,

I am new to the list, and I have a rather complex assignment to complete
in XML. Any help the good folks out there can give me will be
appreciated.

I need to compose an XML schema which will enable the following elements
to be considered valid in instance documents:

	a)	for starters, a standard definition of a sequence of
“primitive” elements which in instance documents will look like

		<primitive name=”foo”>
			whatever
		</primitive>

		with foo a unique ID name. This I can handle.

	b)	Now a recursive definition, which will permit all of the
following elements to be valid in instance documents:

		<recursiveFunction name=”bar”>
			<functionOf>
				<primitive name=”foo”/>
			</functionOf>
		</recursiveFunction>

		<recursiveFunction name=”bar”>
			<functionOf>
				<functionOf>
					<primitive name=”foo”/>
				</functionOf>
			</functionOf>
		</recursiveFunction>

		<recursiveFunction name=”bar”>
			<functionOf>
				<functionOf>
					…
					<functionOf>
						<primitive name=”foo”/>
					</functionOf>
				…
				</functionOf>
			</functionOf>
		</recursiveFunction>

		to any depth, with foo a reference to an already defined
primitive

	c)	Even further, enabling a recursive definition with
“interleaved” tags, such as 

		<recursiveFunction name=”bar”>
			<functionOf>
				<injectionOf>
					<primitive name=”foo”/>
				</injectionOf>
			</functionOf>
		</recursiveFunction>

		<recursiveFunction name=”bar”>
			<functionOf>
				<injectionOf>
					…
					<functionOf>
						<primitive name=”foo”/>
					</functionOf>
				…
				</injectionOf>
			</functionOf>
		</recursiveFunction>

		to any depth and sequence of interleaving

	d)	Further, to enable the identifying names of the
recursive elements to be generated automatically by the structure, so
that 

		<recursiveFunction >
			<functionOf>
				<injectionOf>
					<primitive name=”foo”/>
				</injectionOf>
			</functionOf>
		</recursiveFunction>

		is automatically assigned an ID name f [ g [ foo] ] ], 

		<recursiveFunction >
			<injectionOf>
				<functionOf>
					<injectionOf>
						<primitive name=”foo”/>
					</injectionOf>
				</functionOf>
			</injectionOf>
		</recursiveFunction>

		is automatically assigned the name g[ f[ g[ foo] ] ]

		and so forth.


	e)	Finally, to enable the element declaration

		<recursiveFunction >
			<functionOf>
				<recursiveFunction name=” f [ g [ foo] ]
]”/>
			</functionOf>
	  	</recursiveFunction>

		and that should be considered equivalent to

		<recursiveFunction >
			<functionOf>
				<functionOf>
					<injectionOf>
						<primitive name=”foo”/>
					</injectionOf>
				</functionOf>
			</functionOf>
	  	</recursiveFunction>


	I think most readers should gather what I mean from all these
examples. As I said, any assistance here would be appreciated.


	Regards,

	Ziv


========================================================================= 
Ce message et toutes les pi?ces jointes sont propri?t? de VALTECH et 
susceptibles de contenir des informations confidentielles ? l'intention 
exclusive de ses destinataires. Si vous avez re?u ce message par erreur 
ou si celui ci vous est parvenu incomplet ou alt?r?, merci d'en avertir 
l'exp?diteur par retour.Toute utilisation, diffusion ou publication non 
express?ment autoris?e par nous par ?crit est strictement interdite. 
 -------------------------------------------------------------------------- 
This message and any attachments are Valtech property and may contain 
iconfidential information intended solely for the addressees. If your are 
not the intended recipient of this message or if you have received it 
uncomplete or altered, please notify the author by replying to his e-mail 
immediately. Any unauthorised use, diffusion or dissemination not 
expressly authorised by us in writing is strictly prohibited. 
========================================================================= 
Copyright Valtech 2000 

Received on Friday, 16 March 2001 07:58:13 UTC