xsl-list
[Top] [All Lists]

[xsl] Special characters and Transformation

2006-05-05 02:20:29
Hello,

I have two questions:

1) If I have an XML input file like this:

<root>
        <Text>
                <junk>xxx</junk>
                <tag>Als die ersten St&#228;dte zu einer Gr&#246;&#223;e 
heranwuchsen</tag>
                <junk2>xxx</junk2>
        </Text>
</root>

I would like to skip the <junk> only transform the <tag>; however the output 
shall still have the special character as it is there in the input file. 
Unfortunately the special characters get translated into the proper German 
characters.

That is:
<root>
        <Text>
                <tag>Als die ersten Städte zu einer Größe heranwuchsen</tag>
        </Text>
</root>


This is my XSLT:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
        <xsl:output method="text" version="1.0" encoding="UTF-8" indent="yes"/>
        <xsl:template match="/">
                <xsl:element name="root">
                        <xsl:for-each select="Text">
                                <xsl:element name="Text">
                                        <xsl:element name="tag">
                                                <xsl:value-of select="tag"/>
                                        </xsl:element>
                                </xsl:element>
                        </xsl:for-each>
                </xsl:element>
        </xsl:template>
</xsl:stylesheet>

How can I avoid it?

2) If I had a namespace on the root:

<root xmlns="http://www.fo.com";>
        <Text>
                <junk>xxx</junk>
                <tag>Als die ersten St&#228;dte zu einer Gr&#246;&#223;e 
heranwuchsen</tag>
                <junk2>xxx</junk2>
        </Text>
</root>

The way I do it (not shown here) is that I get the namespace behind each single 
tag.  But how do I modify my XSL so that the output is like this:

<root xmlns="http://www.fo.com";>
        <Text>
                <tag>Als die ersten St&#228;dte zu einer Gr&#246;&#223;e 
heranwuchsen </tag>
        </Text>
</root>

Many Thanks for help,
Houman

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--