[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

key() question?

Subject: key() question?
From: Steven Noels <stevenn@xxxxxxxxxxxxxxxx>
Date: Wed, 10 Jul 2002 11:40:33 +0200
 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@xxxxxxxxxxxxxxxx                      stevenn@xxxxxxxxxx


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



Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.