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

Copying all comments [xsltproc 1.0]

Subject: Copying all comments [xsltproc 1.0]
From: pankaj.c@xxxxxxxxxxxxxxxxxx
Date: Mon, 4 Oct 2010 17:05:03 +0530
 Copying all comments [xsltproc 1.0]
Input:
====
<!--<query id="Q26">ED: &#x00C8; stata cambiata valutazione in 
accertamento perch&eacute; in altri capitoli viene citato 
l&rsquo;accertamento come prima fase del processo di assistenza 
infermiersitica. Ok?</query>-->

Output
====
&lt;query id="Q26"&gt;ED: &amp;#x00C8; stata cambiata valutazione in 
accertamento perch&amp;#x00E9; in altri capitoli viene citato 
l&amp;#x2019;accertamento come prima fase del processo di assistenza 
infermiersitica. Ok?&lt;/query&gt;

Desired output:
========
<query id="Q26">ED: &#x00C8; stata cambiata valutazione in accertamento 
perch&eacute; in altri capitoli viene citato l&rsquo;accertamento come 
prima fase del processo di assistenza infermiersitica. Ok?</query>


Tried XSLT:
=======
    <xsl:for-each select="//comment()">
     <xsl:choose>
            <xsl:when test="substring(.,2,8)='query id'">
                    <xsl:text>&#x0000A;</xsl:text>
                     <xsl:value-of select="."/>
            </xsl:when>
   </xsl:choose>
  </xsl:for-each>


I even tried different manipulation (substring(), substring-after() etc)to 
get this done, for instance below one.

    <xsl:for-each select="//comment()">
        <xsl:choose>
            <xsl:when test="substring(.,2,8)='query id'">
            <xsl:text>&#x0000A;</xsl:text>
               <xsl:element name="query">
                   <xsl:value-of select="."/>
                </xsl:element>
                <xsl:value-of select="."/>
        </xsl:when>
        </xsl:choose>
    </xsl:for-each>

Just to add, notice &#x00C8; changing to  &amp;#x00C8; and similarly &gt; 
&lt; (thats what xsl:value-of does. :-( ). Would have been much easier 
with 2.0 with the use of 
<xsl:sequence 
select="replace(codepoints-to-string(string-to-codepoints($arg)), 
'\[#x([0-9A-Za-z]+)\]', '&#xE000;#x$1;')"/> and replace() function.
and so on,
but alas I am using 1.0. Is there a way to get this done in 1.0?

Thanks for hints.

Pankaj 

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.