![]() |
|
|
|||||||
![]() |
XML - xml charset translation with xsl |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
Hi,
I would like to translate an XML ISO-8859-1 document in UTF-8. For this I wrote the following XSL <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns <xsl <xsl:template match="*"> <xsl:copy> <xsl:apply-templates/> </xsl:copy> </xsl:template> </xsl:stylesheet> It works fine except that it does not keep the atributes. How can I do a translation with the attributes? Further more I've some permil il the xml. If they are written as & permil; they get translated in a permil char but if they are written as & #2030; which is the permil char in ISO-8859-1 it is transformed in an unknown char. How can I do a traslate from & #2030 to & #8240; (utf-8 permil) or to a permil char? Thank you for your help Michel reynard.michel@gmail.com |
|
|
|
|
#2 |
|
Posts: n/a
|
wrote:
> Hi, > I would like to translate an XML ISO-8859-1 document in UTF-8. > For this I wrote the following XSL > > <?xml version="1.0"?> > <xsl:stylesheet version="1.0" > xmlns > <xsl > > <xsl:template match="*"> > <xsl:copy> > <xsl:apply-templates/> > </xsl:copy> > </xsl:template> > </xsl:stylesheet> > > It works fine except that it does not keep the atributes. > How can I do a translation with the attributes? See the XSLT spec for the identity template (<http://www.w3.org/TR/xslt#copying>). > Further more I've some permil il the xml. If they are written as & > permil; they get translated in a permil char but if they are written as > & #2030; which is the permil char in ISO-8859-1 No, it's not. The XHTML character entity reference ‰ is ‰ or (hex) ‰. Note the 'x'. -- Johannes Koch In te domine speravi; non confundar in aeternum. (Te Deum, 4th cent.) |
|
|
|
#3 |
|
Posts: n/a
|
That is not an identity transformation, you can use something like
below and delete your current template: <xsl:template match="node() | @*"> <xsl:copy> <xsl:apply-templates select="node() | @*"/> </xsl:copy> </xsl:template> to get the same contyent to the output. If you want to convert some character to another then you can add a rule matching text nodes and output the value of the text node through the translate function that converts your character in the initial document to the desired character in the output. Best Regards, George --------------------------------------------------------------------- George Cristian Bina <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger http://www.oxygenxml.com |
|