Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - Re: Tricky XSLT question involving variables, serializing, processing instructions [Thread Next] Re: Tricky XSLT question involving variables, serializing, processing instructionsTo: NULL Date: 4/2/2009 8:24:00 AM On Apr 2, 8:34=A0am, Martin Honnen <mahotr...@yahoo.de> wrote:
> 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=3D""> with <link-to-bwd link-to-frag=3D"@link-ref"> ,
> > serialize it all and store it in a processing instruction. =A0
>
> 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:
>
> =A0 =A0 =A0<xsl:template match=3D"level">
> =A0 =A0 =A0 =A0 =A0<xsl:variable name=3D"make_me_a_pi">
> =A0 =A0 =A0 =A0 =A0 =A0 =A0<xsl:apply-templates select=3D"node()[not(self=
::applied-name)
> and not(self::dont-touch-me) and not(preceding-sibling::dont-touch-me)]"
> mode=3D"m1"/>
> =A0 =A0 =A0 =A0 =A0</xsl:variable>
> =A0 =A0 =A0 =A0 =A0<xsl:element name=3D"level">
> =A0 =A0 =A0 =A0 =A0 =A0 =A0<xsl:copy-of select=3D"@*"/>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0<xsl:processing-instruction name=3D"a_pi"
> select=3D"saxon:serialize($make_me_a_pi, 'serializer')"/>
> =A0 =A0 =A0 =A0 =A0</xsl:element>
> =A0 =A0 =A0</xsl:template>
>
> =A0 =A0 =A0<xsl:template match=3D"@* | node()" mode=3D"m1">
> =A0 =A0 =A0 =A0<xsl:copy>
> =A0 =A0 =A0 =A0 =A0<xsl:apply-templates select=3D"@* | node()" mode=3D"m1=
"/>
> =A0 =A0 =A0 =A0</xsl:copy>
> =A0 =A0 =A0</xsl:template>
>
> =A0 =A0 =A0<xsl:template match=3D"link-to" mode=3D"m1">
> =A0 =A0 =A0 =A0<link-to-bwd link-to-frag=3D"{@link-ref}">
> =A0 =A0 =A0 =A0 =A0<xsl:apply-templates select=3D"@* | node()" mode=3D"m1=
"/>
> =A0 =A0 =A0 =A0</link-to-bwd>
> =A0 =A0 =A0</xsl:template>
>
> --
>
> =A0 =A0 =A0 =A0 Martin Honnen
> =A0 =A0 =A0 =A0http://JavaScript.FAQTs.com/
Very nice! Thanks so much. I'm a bit of a newbie and didn't know
about modes but now I do.
Thanks again.
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
