Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - Tricky XSLT question involving variables, serializing, processing instructions >Thread Next - Re: Tricky XSLT question involving variables, serializing, processing instructions Re: Tricky XSLT question involving variables, serializing, processing instructionsTo: NULL Date: 4/2/2009 2:35:00 PM Stryder wrote:
> What I want to do is to make a deep copy of children of <level> up to
> and not including <dont-touch-me> excluding <applied-name>, replace
> <link-to link-ref=""> with <link-to-bwd link-to-frag="@link-ref"> ,
> serialize it all and store it in a processing instruction.
You will to abandon the copy-of approach and instead use the identity
transformation template and add a template for transforming link-to
elements into link-to-bwd elements.
I have also use a mode to separate that approach from other templates
you might have:
<xsl:template match="level">
<xsl:variable name="make_me_a_pi">
<xsl:apply-templates select="node()[not(self::applied-name)
and not(self::dont-touch-me) and not(preceding-sibling::dont-touch-me)]"
mode="m1"/>
</xsl:variable>
<xsl:element name="level">
<xsl:copy-of select="@*"/>
<xsl:processing-instruction name="a_pi"
select="saxon:serialize($make_me_a_pi, 'serializer')"/>
</xsl:element>
</xsl:template>
<xsl:template match="@* | node()" mode="m1">
<xsl:copy>
<xsl:apply-templates select="@* | node()" mode="m1"/>
</xsl:copy>
</xsl:template>
<xsl:template match="link-to" mode="m1">
<link-to-bwd link-to-frag="{@link-ref}">
<xsl:apply-templates select="@* | node()" mode="m1"/>
</link-to-bwd>
</xsl:template>
--
Martin Honnen
http://JavaScript.FAQTs.com/
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
