[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|