xsl-list
[Top] [All Lists]

RETAINING THE ENTITY NAMES IN THE RESULTING TREE

2004-08-06 01:28:08
Greetings all.

My task is transforming the XML into another XML tree. During the transformation I am loosing the generic names of the special characters. For example, in my source xml I have an entity called "α" but in the resulting tree I am getting only junk characters instead. But I need to maintain the 'α' as is in the resulting xml.

I am using Saxon 8.0 for this transformation, and the codes are given below:

MY INPUT XML (main.xml)
<?xml version="1.0"?>
<?xml-stylesheet href="main.xsl" type="text/xsl"?>
<!DOCTYPE root SYSTEM "ent.dtd">
<root>
<center><h2>sss</h2></center>
<center><h2>&alpha;</h2></center>
<center><h2>&beta;</h2></center>
<center><h2>&ndash;</h2></center>
</root>

MY XSL (data.xsl)
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version='1.0'>
<xsl:output method="xml" indent="yes"/>
<xsl:template match="root">
<html>
<body>
<xsl:for-each select="center/child::*">
<center>
<xsl:element name="{name(.)}">
<xsl:if test="@*">
<xsl:attribute name="{name(@*)}"><xsl:value-of select="string(@*)"/></xsl:attribute>
</xsl:if>
<xsl:apply-templates/>
</xsl:element>
</center>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>


MY RESULTING XML
<?xml version="1.0" encoding="UTF-8"?>
<html>
<body>
<center>
<h2>sss</h2>
</center>
<center>
<h2>α</h2>
</center>
<center>
<h2>β</h2>
</center>
<center>
<h2>â€"</h2>
</center>
</body>
</html>

MY COMMAND LINE ARGUMENT
E:\>java -jar saxon8.jar -ds data.xml main.xsl

Please advice, how to retain the generic entity names in the resulting xml.


Thanks and regards
Arul Kumar



<Prev in Thread] Current Thread [Next in Thread>