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

Re: key() question?

Subject: Re: key() question?
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Wed, 10 Jul 2002 10:58:21 +0100
Re:  key() question?
Hi Steven,

> 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"/>

[A // beginning a pattern (match attribute) is always superfluous --
you're matching "any contentModel element that is a descendant of the
root node" when you may as well match "any contentModel element" since
all elements must be descendants of the root node by definition.]

> 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.

If you're looking at a contentModel element, then you can find all the
element elements that have the same name as that contentModel element
using your contentmodelbychildren key with the value of the ename
attribute on the contentModel element:

  key('contentmodelbychildren', @ename)

If there are no element elements returned by the key, then the element
is never referred to from within a content model.

So you can collect all the contentModel elements that don't return any
nodes when their ename attribute is passed to the
'cotentmodelbychildren' key:

  /dtd/contentModel[not(key('contentmodelbychildren', @ename))]
  
Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.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.