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

Re: key() question?

Subject: Re: key() question?
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Wed, 10 Jul 2002 03:11:34 -0700 (PDT)
type of key bord
--- Steven Noels <stevenn at outerthought dot org> wrote:
>
> 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?
> 


Hi Steve,

To find all such contentModel, use the following XPath expression:

/dtd/contentModel[not(@ename = /dtd/contentModel/group/element/@name)]


Cheers,
Dimitre Novatchev.

__________________________________________________
Do You Yahoo!?
Sign up for SBC Yahoo! Dial - First Month Free
http://sbc.yahoo.com

 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.