[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re[2]: applying code from inside the comment

Subject: Re[2]: applying code from inside the comment
From: Alexey Nickolaenkov <nikolaenkov@xxxxxxxxxxxx>
Date: Tue, 16 Jan 2007 20:12:17 +0300
Re[2]:  applying code from inside the comment
>> I've encountered the following problem:
>> 
>> input
>> 
>> <?xml version="1.0"?>
>> <A>
>> <!--<B>hello world</b>-->
>> <C>this should remain also</C>
>> </A>
>> 
>> I've tried different ways to convert comment into code. But 
>> none of them works and I dont have any clues. Can you help me?

MK> I'm not sure what you want to do with the comment. But the important thing
MK> is to note that the comment is just text. It doesn't contain an element
MK> node, it just contains text with a strong resemblance to element markup. If
MK> the structure is potentially more complex than your example, then perhaps
MK> you should consider extracting the text of the comment and parsing it as an
MK> XML document:

MK> <xsl:template match="comment()">
MK>   <xsl:apply-templates select="saxon:parse(.)"/>
MK> </xsl:template>


Thank you very much, Michael. This works great. The only thing you
have to make sure when making saxon:parse that you providing it with
valid xml. Great extension. Thank you once again. Here's the code
I've come up with.

<xsl:template match="//comment()[contains(.,'drive_panel')]">
    <xsl:variable name="comment">
        &lt;comment&gt;
                <xsl:value-of select="."/>
        &lt;/comment&gt;
    </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>



-- 
Alexey                            mailto:alexey.nikolaenkov@xxxxxxxxxxxx

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.