R
Rabe
Hi all,
here a little brain-twister (starting to spoil my weekend
if I do not find a solution ... ;-) )
What I want to do is to find a XML-Schema expression that builds
a grammar for the following XML document (fragment):
<grouping_document>
<app_list>
<app id="id1">Program 1</app>
<app id="id2">Program 2</app>
<app id="id3">Program 3</app>
<!-- etc. -->
</app_list>
<grouping app_ref="id1 id3">
<!-- stuff for the referenced apps -->
</grouping>
<grouping app_ref="id2">
<!-- stuff for the referenced apps -->
</grouping>
</grouping_document>
The <grouping_document> describes some information that may be valid for
one or more applications. So it starts with a list of application definitions
whereas the key issue is that only the listed ids are allowed to appear as
values of attribute app_ref in the element <grouping>.
A valid DTD for this is
<!DOCTYPE grouping_document [
<!ELEMENT grouping_document ( app_list, grouping+ )>
<!ELEMENT app_list (app+)>
<!ELEMENT app (#PCDATA)>
<!ATTLIST app id ID #REQUIRED>
<!-- etc. -->
<!ELEMENT grouping (grouping_element+)>
<!ATTLIST grouping app_ref IDREFS #REQUIRED>
<!-- etc. -->
]>
But how to express these ID/IDREFS expressions in suitable in XML-Schema syntax?
(I do not have a problem with the standard key/keyref expressions. Where I'm
failing is the formulation of a list of references as value of a simple attribute.)
Here's what I have tried:
<xsd:complexType name="GroupingType">
<xsd:sequence>
<xsd:element name="app_list" type="AppListType">
<xsd:key name="AppKey">
<xsd:selector xpath="app"/>
<xsd:field xpath="@id"/>
</xsd:key>
</xsd:element>
<xsd:element name="grouping" type="GroupingType"/>
</xsd:sequence>
</xsd:complexType>
<!-- etc. -->
<complexType name="GroupingType">
<sequence>
<element name="grouping_element">
<!-- etc. -->
</element>
</sequence>
<attribute name="id">
<simpleType name="AppIdList">
<list itemType="string"/>
</simpleType>
<keyref name="aref" refer="jrn:AppKey">
<field xpath="@app_id"/>
</keyref>
</attribute>
</complexType>
It's wrong, I know ...
But perhaps someone has a little tip for me?
Many thanks for your efforts!
Rabe
here a little brain-twister (starting to spoil my weekend
if I do not find a solution ... ;-) )
What I want to do is to find a XML-Schema expression that builds
a grammar for the following XML document (fragment):
<grouping_document>
<app_list>
<app id="id1">Program 1</app>
<app id="id2">Program 2</app>
<app id="id3">Program 3</app>
<!-- etc. -->
</app_list>
<grouping app_ref="id1 id3">
<!-- stuff for the referenced apps -->
</grouping>
<grouping app_ref="id2">
<!-- stuff for the referenced apps -->
</grouping>
</grouping_document>
The <grouping_document> describes some information that may be valid for
one or more applications. So it starts with a list of application definitions
whereas the key issue is that only the listed ids are allowed to appear as
values of attribute app_ref in the element <grouping>.
A valid DTD for this is
<!DOCTYPE grouping_document [
<!ELEMENT grouping_document ( app_list, grouping+ )>
<!ELEMENT app_list (app+)>
<!ELEMENT app (#PCDATA)>
<!ATTLIST app id ID #REQUIRED>
<!-- etc. -->
<!ELEMENT grouping (grouping_element+)>
<!ATTLIST grouping app_ref IDREFS #REQUIRED>
<!-- etc. -->
]>
But how to express these ID/IDREFS expressions in suitable in XML-Schema syntax?
(I do not have a problem with the standard key/keyref expressions. Where I'm
failing is the formulation of a list of references as value of a simple attribute.)
Here's what I have tried:
<xsd:complexType name="GroupingType">
<xsd:sequence>
<xsd:element name="app_list" type="AppListType">
<xsd:key name="AppKey">
<xsd:selector xpath="app"/>
<xsd:field xpath="@id"/>
</xsd:key>
</xsd:element>
<xsd:element name="grouping" type="GroupingType"/>
</xsd:sequence>
</xsd:complexType>
<!-- etc. -->
<complexType name="GroupingType">
<sequence>
<element name="grouping_element">
<!-- etc. -->
</element>
</sequence>
<attribute name="id">
<simpleType name="AppIdList">
<list itemType="string"/>
</simpleType>
<keyref name="aref" refer="jrn:AppKey">
<field xpath="@app_id"/>
</keyref>
</attribute>
</complexType>
It's wrong, I know ...
But perhaps someone has a little tip for me?
Many thanks for your efforts!
Rabe