Subject: Re[3]: applying code from inside the comment
From: Alexey Nickolaenkov <nikolaenkov@xxxxxxxxxxxx>
Date: Wed, 17 Jan 2007 00:18:19 +0300
|
Tuesday, January 16, 2007, 8:53:10 PM, you wrote:
WP> That's a pretty nice example of micropipelining.
Thank you.
WP> It could be tightened up a bit:
WP> At 12:12 PM 1/16/2007, you wrote:
>><xsl:template match="//comment()[contains(.,'drive_panel')]">
>> <xsl:variable name="comment">
>> <comment>
>> <xsl:value-of select="."/>
>> </comment>
>> </xsl:variable>
>>
>> <xsl:variable name="node-set" select="saxon:parse($comment)" />
>> <xsl:apply-templates select="$node-set"/>
>></xsl:template>
>>
>><xsl:template match="comment">
>> <xsl:apply-templates select="node() except ./text()"/>
>></xsl:template>
WP> <xsl:template match="comment()[contains(.,'drive_panel')]">
WP> <xsl:variable name="comment" select="saxon:parse(.)"/>
WP> <xsl:apply-templates select="$comment except $comment/text()"/>
WP> </xsl:template>
WP> Note: untested. You might have to try "saxon:parse(string())".
Of course it can, but I apply this template against comments of which
xml validity I'm not so sure. Therefore if I do something like
<xsl:variable name="comment" select="saxon:parse(.)"/>
and my comment will contain
<!--
<a>
some node set
</a>
<b>
some other nodeset
</b>
..
-->
I'll receive document has no root element error. That's why
this pipelined workaround is applied.
--
Alexey mailto:alexey.nikolaenkov@xxxxxxxxxxxx
|