|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Exclude Attributes from select?
At 00/10/13 13:29 +0200, Linda van den Brink wrote:
> If i use <xsl:copy-of select="@*">, is there a possibility, > to exclude some attributes? I very much apologize if this sounds pedantic, but the incorrect answer to this question was given twice by different people, so I will respond to each with the same answer in case people hunt down one thread but not the other. The self:: axis cannot be used as shown above, because the principal node type along the self:: axis is element and when only a name is given in the node test only nodes of the principal type are returned. One might ask "since I'm on the attribute axis, why isn't the attribute the principal node type in the predicate" ... the answer is because XSLT states that if an axis is allowed to have elements along it, as does the self:: axis, then the element is the principal node type. Therefore, since there are no elements on the attribute axis, nothing is ever returned from the self:: axis in the above expression. The only way I can see to exclude particular attributes is with the name() function. An illustration is below. I hope this helps, and again, sorry for duplication but I understand one's intuition to try the above and I think it is important to cover the bases. ...................... Ken p.s. for those of you who have the Eighth Edition of our book, the summary is on page 70. T:\ftemp>type test.xsl
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:dummy="dummy"
exclude-result-prefixes="dummy"
version="1.0"><xsl:output method="text"/> <dummy:data> <hello att1="att1-val" att2="att2-val" att3="att3-val"/> </dummy:data> <xsl:template match="/"> <!--root rule-->
<xsl:for-each select="document('')//hello">
<xsl:text>Using self::</xsl:text>
<xsl:for-each select="@*[not(self::att2)]" xml:space="preserve">
<xsl:value-of select="name(.)"/>-<xsl:value-of select="."/>
</xsl:for-each>
<xsl:text>
Using self::</xsl:text>
<xsl:for-each select="@*[name(.)!='att2']" xml:space="preserve">
<xsl:value-of select="name(.)"/>-<xsl:value-of select="."/>
</xsl:for-each>
</xsl:for-each>
</xsl:template></xsl:stylesheet> T:\ftemp>xt test.xsl test.xsl
Using self::
att1-att1-valatt2-att2-val att3-att3-val Using self::
att1-att1-valatt3-att3-val T:\ftemp>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
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
|

Cart








