[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: how to match attributes in templates?
Hi Alice,
Alice Fan wrote: this is what i'm doing to copy all nodes except for a specific element name. how do i specify a specific attribute inthe if statement? Well, you can find an example of how to copy all nodes in the XSLT spec (in the identity transform described at http://www.w3.org/TR/xslt#copying) and you can build on this to match and trap a specific attribute (or element) <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <!-- copy all nodes... --> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <!-- ...except this one --> <xsl:template match="@id" /> </xsl:stylesheet> This is somewhat similar to what you were trying to do, but matching templates by pattern is more fun (and more in the spirit of XSLT) than coding xsl:if statements. But if you do want to use explicit logic rather than pattern matching, you can use: <xsl:if test="not(self::someelement)">...</xsl:if> if you know the element name at build time, or use: <xsl:if test="not(localname() = $targetNodeName)">...</xsl:if> if the element name will be set at run time. Francis. 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
|