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

Re: Dynamically selecting Attributes

Subject: Re: Dynamically selecting Attributes
From: Mike Brown <mike@xxxxxxxx>
Date: Mon, 16 Oct 2000 13:55:25 -0600 (MDT)
xpath selecting attributes
suresh talluri wrote:
> I recently came across this piece of code in this emailing list,can someone
> explain me wot excalty does this special characters do..

Sigh... I'll bite. You need to do some more reading.

Go to http://www.skew.org/xml/links/ and look at the section marked
'Specifications - XML and XSLT' and 'Tutorials - XML and XSLT'. In
particular you need to understand XSLT, and to understand XSLT you have to
understand XPath.

> <xsl:template match="find">

Assuming the 'xsl' prefix maps to the correct namespace URI, this encloses
an XSLT template that is a suitable match for an element node named
'find'. If the XSLT processor encounters such a node, there is a good
chance that the instructions in this template will be executed.

> <xsl:value-of select="//record/@*[name()=current()/@target]"/>

This is an XSLT instruction to create a text node in the result tree.
The character data in the text node will be the string-value of the first
node in the node-set identified by the XPath expression

  //record/@*[name()=current()/@target]

 /@*    : attributes with any name, in any namespace, belonging to...
 record : elements named record, that are...
 //     : descendants of the root node.

 [ foo ] : narrows down the set to just those for which foo is true.
 name()  : name of the context node (attribute name, in this case).
 =       : equality comparison operator.
 /@target : attributes named target, that are children of...
 current() : the current node (the one that was current before this
             instruction was instantiated, as opposed to the context node).

As per XPath rules, the comparison of a string (as returned by the name()
function) and a node-set (as identified by @target) will be handled
as a stringwise comparison, as if it were name()=string(current()/@target).

The concept of string-value and the interaction of the string() function
on node-sets is explained in the XPath Recommendation.

Hopefully someone will get something out of this.

   - Mike
____________________________________________________________________
Mike J. Brown, software engineer at         My XML/XSL resources:
webb.net in Denver, Colorado, USA           http://www.skew.org/xml/


 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.