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

RE: xsl value-of

Subject: RE: xsl value-of
From: "Matias Woloski" <woloski@xxxxxxxx>
Date: Tue, 2 Apr 2002 15:49:19 -0300
xsl value of concat
Jeni and Joerg, thank you very much for your help.
It finally worked!
I've used
<xsl:key name="labels" match="label" use="concat(../../@id, '_', @id)"/>

I didn't understand why I have to put only label and not label/text()

thanks again,
Matias

> -----Original Message-----
> From: Jeni Tennison [mailto:jeni@xxxxxxxxxxxxxxxx]
> Sent: martes, 02 de abril de 2002 15:32
> To: Matias Woloski
> Cc: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re:  xsl value-of
> 
> 
> Hi Matias,
> 
> > I created a key in the top of the document
> >
> > <xsl:key name="labels" match="xml/group/questionAnswered/label/text()"
> > use="concat(xml/group/@id, '_', 
> xml/group/questionAnswered/label/@id)" />
> 
> Hmm... OK, this is the problem.
> 
> Keys build up named tables of nodes and values which enable you to
> quickly get at a set of nodes that are associated with a particular
> value.
> 
> When an XSLT processor builds up one of these tables, it goes through
> the document and finds all the nodes that match the pattern held in
> the match attribute. With your definition, a processor would locate
> all the text nodes in the document that are children of a label
> element that is a child of a questionAnswered element that is a child
> of a group element that is a child of an xml element.
> 
> (By the way 'xml' is an illegal name for an element -- XML parsers
> should object to you using it.)
> 
> When it finds a matching node, the XSLT processor evaluates the
> expression held in the use attribute to create a value for the node,
> by which the node is indexed. When it evaluates this expression, it
> uses the node that it's indexing as the current node -- so any
> relative paths are evaluated relative to the matched node.
> 
> In your case, the expression is:
> 
>   concat(xml/group/@id, '_', xml/group/questionAnswered/label/@id)
> 
> The current node is a text node under a label element. You're asking
> the processor to concatenate the id of the group element of the xml
> element *child* of the *text node* with an underscore and the id of
> the label element of the ... of the xml element *child* of the *text
> node*. Text nodes don't have children, so these paths are doomed to
> failure.
> 
> What you're trying to do is index the text node by the id of the text
> node's *ancestor* group element, concatenated with an underscore and
> the id of the text node's *parent* label element. So what you need is:
> 
> <xsl:key name="labels" match="xml/group/questionAnswered/label/text()"
>          use="concat(ancestor::group/@id, '_', parent::label/@id)" />
> 
> Personally, since the label element doesn't hold mixed content, and
> since the label elements don't occur anywhere aside from within
> questionAnswered elements that are children of group elements that are
> children of xml elements, I'd use the definition:
> 
> <xsl:key name="labels" match="label"
>          use="concat(ancestor::group/@id, '_', @id)" />
> 
> The fact that the label elements don't contain mixed content means
> that getting the value of a label element gives you exactly the same
> as getting the value of the label element's text node child. The fact
> that you're interested in all label elements means that there's no
> need to add all that checking of ancestor elements to the match
> pattern -- not having to check that the label element is a child of
> questionAnswered and so on will save the processor a little bit of
> work. The definition looks easier, too!
> 
> The rest of the code should work fine.
> 
> 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.