This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

key() question?


Hi all,

I'm trying to wrap my brains across a problem which I assume I must be solving using nasty key() tricks.

Here's how my input file looks like:

<contentModel ename="document">
<group>
<element name="header"/>
<separator type=","/>
<element name="body"/>
<separator type=","/>
<element name="footer"/>
<occurrence type="?"/>
</group>
</contentModel>
<attlist ename="document">
<attributeDecl aname="id" ename="document" atype="ID"/>
<attributeDecl aname="xml:lang" ename="document" atype="NMTOKEN"/>
</attlist>
<contentModel ename="header">
<group>
<element name="title"/>
<separator type=","/>
<element name="subtitle"/>
<occurrence type="?"/>
<separator type=","/>
<element name="version"/>
<occurrence type="?"/>
<separator type=","/>
<element name="type"/>
<occurrence type="?"/>
<separator type=","/>
<element name="authors"/>
<occurrence type="?"/>
<separator type=","/>
<element name="notice"/>
<occurrence type="*"/>
<separator type=","/>
<element name="abstract"/>
<occurrence type="?"/>
</group>
</contentModel>
<attlist ename="header">
<attributeDecl aname="id" ename="header" atype="ID"/>
<attributeDecl aname="xml:lang" ename="header" atype="NMTOKEN"/>
</attlist>

and much more like this, so in essence I have plenty of <contentModel> and <attlist> elements which contain content model defitions composed of <element>s, <group>s and the like. Think DTDs but in an XML syntax.

I have some keys declared for easy access to the attributes declared for a specific element, and to retrieve the contentModels in which an element is referred to:

<xsl:key name="attlistbyname" match="/dtd/attlist" use="@ename"/>
<xsl:key name="contentmodelbychildren" match="//contentModel" use="descendant::element/@name"/>

The problem with DTDs without an accompagnying instance is that you are not able to devise which element is the root element. As a rule of thumb in my situation, I define root elements as <contentModel> elements which have no <element> counterpart, i.e. the 'document' contentModel in this case: you find a <contentModel ename="document"> without an <element name="document"/> that refers to it inside some other <contentModel>.

My question is how I can easily locate <contentModel> elements which don't have an <element> counterpart bearing an attribute 'name' with the contentModel/@ename as its value.

Anyone an idea?

</Steven>
--
Steven Noels http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
stevenn@outerthought.org stevenn@apache.org


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]