[xsl] Unicode and child element

Subject: [xsl] Unicode and child element
From: "Pankaj Chaturvedi" <pankaj.chaturvedi@xxxxxxxxx>
Date: Thu, 28 Aug 2008 17:51:49 +0530
Hi all,

I have a markup which looks like below:

<booktitle>Rethinking Ethnicity: cross&hyphen;national Arguments and
Explorations 
	<edition>2nd edn</edition>
</booktitle>





XSLT
=======

<xsl:function name="my:reverse-string">
	<xsl:param name="arg"/>
		<xsl:sequence
select="replace(codepoints-to-string(string-to-codepoints($arg)),
'\[#x([0-9A-Za-z]+)\]', '&#xE000;#x$1;')"/>
</xsl:function>


<xsl:template match="edition" mode="New-one">
<xsl:copy>
<xsl:choose>
	<xsl:when test="name(parent::booktitle)">
		<!--  Do something  -->
	<xsl:value-of select="my:reverse-string(string(.))"/>
	</xsl:when>
	<xsl:otherwise>
	<!--  Do something  -->
	</xsl:otherwise>
</xsl:choose>
</xsl:copy>
</xsl:template>



<xsl:template match="booktitle" mode="New-one">
		<xsl:copy>
		<xsl:attribute name="dummy">book_title</xsl:attribute>
		<xsl:copy-of select="@*"/>
		<xsl:apply-templates mode="New-one"/>
		<xsl:text>. </xsl:text>
		</xsl:copy>
</xsl:template>




If I use the above snippet in XSLT, I get the result

<booktitle dummy="booktitle">Rethinking Ethnicity: cross[#x002d]national
Arguments and Explorations 
	<edition>2nd edn</edition>
</booktitle>


Please notice: [#x002d] and I want it to be &#x002d; (I understand that it
is one a same thing but I need unicodes to be &___; format. That's the
reason of using above function).

If I change <xsl:apply-templates mode="New-one"/> in "booktitle" template to
<xsl:apply-templates/> then the unicodes appeared as desired but with
missing child <edition> element.

<booktitle dummy="booktitle">Rethinking Ethnicity: cross[#x002d]national
Arguments and Explorations 
	2nd edn
</booktitle>

Is there is a way to get the both (Unicode and child <edition>) correctly as
following:

<booktitle dummy="booktitle">Rethinking Ethnicity: cross&#x002d;national
Arguments and Explorations 
	<edition>2nd edn</edition>
</booktitle>

	
I've done it earlier but seems to be completely lost today (may be tired).

Any suggestion will be highly appreciated.


Best,

Pankaj Chaturvedi

============================================================================
================


Confidentiality Notice:" This message and any attachment(s)
contained here are information that is confidential, proprietary to
IDS Infotech Ltd. and its customers.
Contents may be privileged or otherwise protected by law. The
information is solely intended for the individual or the entity it
is addressed to. If you are not the intended recipient of this
message, you are not authorized to read, forward, print, retain,
copy or disseminate this message or any part of it. If you have
received this e-mail in error, please notify the sender immediately
by return e-mail and delete it from your computer."

Current Thread