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

RE: understanding attributes and predicates

Subject: RE: understanding attributes and predicates
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 1 Feb 2008 22:10:05 -0000
RE:  understanding attributes and predicates
> When I select specific par elements with a predicate, as in 
> the template below, I get the attribute name, attribute 
> value, and the text node of the <par> element.
> 
> <xsl:template match="par[@class='stem_mc']">
>    <!-- List the attribute names and values. --> 
> <xsl:for-each select='@*'>
>    attribute name: <xsl:value-of select="name()"/> attribute 
> value: <xsl:value-of select="."/> </xsl:for-each>
>    </xsl:template>
> 
> 
> I just wonder what is going on. Is it the "for-each 
> select='@*'" or the "value-of select="." that is returning 
> the text node of the par element?

I don't know exactly what's going on, but what I would expect to happen is
this:

(a) when you get to a par element with class="stem_mc", you output all the
attribute names and values

(b) when you get to a par element without class="stem_mc", you output the
text value of the element.

That's because there are built-in template rules in every stylesheet that
look like this:

<xsl:template match="*">
  <xsl:apply-templates/>
</xsl:template>

<xsl:template match="text()">
  <xsl:value-of select="."/>
</xsl:template>

When you get to a par element that doesn't match par[@class='stem_mc'],
these built-in template rules cause the text nodes within the element to be
output.

If this explanation doesn't seem to fit what you're observing, then I've
probably misunderstood your explanation about what's in your stylesheet.
Submit a *complete* stylesheet and show its output.

Michael Kay
http://www.saxonica.com/

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.