Subject: [xsl] following-sibling on attributes From: "Vidar S. Ramdal" <vidar@xxxxxxxx> Date: Fri, 05 Sep 2003 13:08:51 +0200 |
I have an XML fragment like this: <TEXT i="1" b="1">Lorem ipsum dolor sit amet</TEXT>
I have started off with this XSLT: <!-- Matches any TEXT that has one or more attributes --> <xsl:template match="TEXT[attribute::node()]"> <xsl:apply-templates select="attribute::node()[1]"> <xsl:with-param name="content" select="text()"/> </xsl:apply-templates> </xsl:template>
<!-- Recursive template that deals with attribute nodes --> <xsl:template match="TEXT/attribute::node()"> <xsl:param name="content"/> <xsl:variable name="newcontent"> <xsl:element name="{local-name(.)}"> <xsl:copy-of select="$content"/> </xsl:element> </xsl:variable> <xsl:choose> <!-- Problem: This is never true --> <xsl:when test="preceding-sibling::node()"> <xsl:apply-templates select="preceding-sibling::node()[1]"> <xsl:with-param name="content" select="$newcontent"/> </xsl:apply-templates> </xsl:when> <xsl:otherwise> <xsl:copy-of select="$newcontent"/> </xsl:otherwise> </xsl:choose> </xsl:template>
The result I get with the above XML and stylesheet is <b>Lorem ipsum dolor sit amet</b> while I want <i><b>Lorem ipsum dolor sit amet</b></i>
-- Vidar S. Ramdal <vidar@xxxxxxxx> Idium AS - http://www.idium.no Tlf. +47 22 00 84 31 / Fax: +47 22 00 84 01 A: Top posting. Q: What is the most annoying thing on usenet and in e-mail?
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] XMLSS XSL question, Emmanuil Batsis (Man | Thread | RE: [xsl] following-sibling on attr, Michael Kay |
RE: [xsl] Landscape print control, Andrew Welch | Date | Re: [xsl] following-sibling on attr, Dimitre Novatchev |
Month |