[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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/
|
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
|