A
Alex Sab
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>
<Modelrocesses>
<Noderocess Node:template="nodeID" Node:nodeId="nodeID2">
<Node:Name Node:Comment="">Overwrite</Node:Name>
<Node:Name99 Node:Comment="">Overwrite</Node:Name99>
</Noderocess>
</Modelrocesses>
Noderocess 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 Noderocess 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="Noderocess"/>
<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
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>
<Modelrocesses>
<Noderocess Node:template="nodeID" Node:nodeId="nodeID2">
<Node:Name Node:Comment="">Overwrite</Node:Name>
<Node:Name99 Node:Comment="">Overwrite</Node:Name99>
</Noderocess>
</Modelrocesses>
Noderocess 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 Noderocess 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="Noderocess"/>
<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