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

Re: Specify/determine element's "logical" parent

Subject: Re: Specify/determine element's "logical" parent
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 23 Sep 2004 23:08:55 +0100
determine element in the star
> , but I seem to be headed down a very deep and dark path with XSL.

probably but remember many of us find that walking along such paths is
fun, perhaps you're more of a city dweller and more comfortable
following the crowds?

> I would be happy to RTFM if I could just find the FM

everything is in the Xpath and xslt Recommendations online at w3.org/TR
that's all many of us used, although by now there are plenty of online
tutorials as well. 

> For instance, I do not understand the difference between the two templates
> listed below, which seem equivalent to me.

one has
          <xsl:value-of select="key( 'ids', @parentid )" />
the other has
          <xsl:value-of select="key( 'ids', @parentid )/@id" />

these are not at all equivalent, in both cases the key() will select the
element node with the specified id but in the first case you select the
string value of the element (ie all the character data of all its
descendents) and in the second you select the string value of the id
attribute.

incidentally the xsl:choose can be simplified to

          <xsl:value-of select="key( 'ids', (@parentid|../@id)[last()])/@id" />

so you don't really need the $parent variable at all you can just do

    <xsl:value-of select="@id" /> is [<xsl:value-of select="key( 'ids', (@parentid|../@id)[last()])/@id" />]<br />

> Nor do I understand why when both templates are in a single
> stylesheet, only one (the latter?) seems to get applied.

actually it's an error to have two templates of the same priority
matching the same node, the system may recover by using one of them but
it's best to avoid the error condition.

This error is really enforced by XSLTs processing model, it would be
hard to think of a meaning for applying two templates at the same point
in the input.


David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

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.