Schema: Change properties of inherited elements without listing them again

Alex Sab

Usenet Archive
Joined
Apr 5, 2004
Messages
3
Reaction score
0
Hi,
I am having trouble describing in a schema that elements can be mandatory in one part and not mandatory in another part of the xml document. Here is a sample xml file

<Model:Templates>
<Node:Template Node:nodeId="nodeID">
<Node:Name Node:Comment="">Name</Node:Name>
<Node:Name2 Node:Comment="">Name</Node:Name2>
...
<Node:Name100 Node:Comment="">Name</Node:Name100>
</Node:Template>
</Model:Templates>
<Model:processes>
<Node:process Node:template="nodeID" Node:nodeId="nodeID2"> <Node:Name Node:Comment="">Overwrite</Node:Name> <Node:Name99 Node:Comment="">Overwrite</Node:Name99> </Node:process> </Model:processes>

Node:process has exactly the same contents except that the childs are not mandatory. I call it the "mandatory difference"

What I would like to have and can not accomplish with schemas:

1. Node:Template and Node:process should both be Node:Node, but schema should still state that "mandatory difference"

2. Describe in the schema the "mandatory difference" without the need to repeat all Node:Name´s with some trick like "group, extension, restriction, all". I tried them all but did not succeed.

I think the main problem is that changing the mandatory is only possible in the name-elements, so changing this property always requires to list the name-elements again. I thought the minOccurence of the <all> element could globaly state the mandatory property but unfortunately it did not.

Here is an example for <all>

<group name="NodeGroup">
<!--minOccurs does not help here-->
<all minOccurs="0">
<element name="Name" type="string"/>
<element name="Name2" type="string"/>
...
<element name="Name3" type="string"/>
</all>
</group>
<element name="Node" type="Node:Node"/>
<complexType name="Node">
<group ref="Node:NodeGroup"/>
</complexType>
<element name="Template" type="Node:Template"/>
<complexType name="Template">
<group ref="Node:NodeGroup"/>
</complexType>
<element name="Process" type="Node:process"/>
<complexType name="Process">
<complexContent>
<restriction base="Node:Node">
<!--minOccurs does not help here-->
<group ref="Node:NodeGroup" minOccurs="0"/>
<attribute name="nodeId" type="string" use="required"/> <attribute name="template" type="string" use="optional"/> </restriction> </complexContent> </complexType> <complexType name="AttrElement"> <simpleContent> <extension base="string"> <attribute name="Comment" type="string" use="optional"/> </extension> </simpleContent> </complexType>

Is there any way to accomplish this?

Alex
 

C. M. Sperberg-McQueen

Usenet Archive
Joined
Jul 2, 2003
Messages
95
Reaction score
0
Hi,
I am having trouble describing in a schema that elements can be mandatory in one part and not mandatory in another part of the xml document. ... ...
Node:process has exactly the same contents except that the childs are not mandatory. I call it the "mandatory difference"

What I would like to have and can not accomplish with schemas:

Well, actually, you can. What you are looking for, I think, is that in one context an element should have one type (in which things are mandatory), and in another the same element (or: an element with the same name) should have a similar type (in which things are optional). Since XML Schema allows local bindings of element names to types, this is not hard to do.

A simple example of the problem and some discussion of how to address it are given at http://www.w3.org/2000/04/26-csrules.html

I hope this helps.

-C. M. Sperberg-McQueen
World Wide Web Consortium
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,042
Messages
3,104,223
Members
248,131
Latest member
Tonypshaw1

Latest Threads

Top