Subject: RE: [xsl]Select nodes without match From: cknell@xxxxxxxxxx Date: Thu, 24 Aug 2006 09:16:14 -0400 |
> Is there a command like a go-to in xsl for doing this? Answer: No, "go-to" is from a different processing model. You'll need to find another means. > if i make a template with match it destroy the object .cap Answer: No, it won't destroy anything. You haven't shown us your XML, so I'll invent some that has the relevant properties and write an XLST template that should give you what you want. ------- INPUT DOCUMENT--------- <?xml version="1.0"?> <root-node> <box id="ball.cap">Pittsburgh Pirates</box> <box id="pennant">Pittsburgh Pirates</box> </root-node> -------- STYLESHEET------------- <?xml version="1.0"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:strip-space elements="*" /> <xsl:output method="xml" indent="yes" encoding="UTF-8" /> <xsl:template match="/"> <xsl:apply-templates /> </xsl:template> <xsl:template match="root-node"> <root-node> <xsl:apply-templates /> </root-node> </xsl:template> <xsl:template match="box"> <xsl:choose> <xsl:when test="ends-with(@id,'.cap')"> <box> <xsl:attribute name="width" select="'2%'" /> <xsl:for-each select="@*"> <xsl:if test="not(local-name(.) = 'id')"> <xsl:copy-of select="." /> </xsl:if> </xsl:for-each> <xsl:value-of select="." /> </box> </xsl:when> <xsl:otherwise><xsl:copy-of select="." /></xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet> --------OUTPUT DOCUMENT----------- <?xml version="1.0" encoding="UTF-8"?> <root-node> <box width="2%">Pittsburgh Pirates</box> <box id="pennant">Pittsburgh Pirates</box> </root-node> Charles Knell cknell@xxxxxxxxxx - email -----Original Message----- From: <m.core@xxxxxxxxxxxxxxxx> Sent: Thu, 24 Aug 2006 12:15:37 +0200 To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: [xsl]Select nodes without match Hi all, i have an xml tree and i need with xsl to be placed in a particular node without using the match statement. For explain me well: in the html version of the page i have a box in wich you can write; i need to resize that box and for doing this i write: <xsl:when test="utils:endsWith(@id, '.cap')"> <xsl:attribute name="width">2%</xsl:attribute> </xsl:when> but i need to place this code in a template that put me in the right nodes that contains .cap and i don't want this... How can i do? thx for replies. Matteo
Current Thread |
---|
<- Previous | Index | Next -> |
---|---|---|
[xsl]Select nodes without match, m.core | Thread | RE: RE: [xsl]Select nodes without m, cknell |
Re: [xsl] [XSLT, Version 1] Stylesh, Robert Koberg | Date | RE: [xsl] Using attributes with XPa, Mike Ferrando |
Month |