473,396 Members | 1,726 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

xml charset translation with xsl

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="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>

<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

May 24 '06 #1
2 1293
re************@gmail.com 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="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>

<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 &permil; is ‰
or (hex) &#x2030;. Note the 'x'.

--
Johannes Koch
In te domine speravi; non confundar in aeternum.
(Te Deum, 4th cent.)
May 24 '06 #2
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

May 24 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: CJ Oxx | last post by:
I have a problem with browser charset recognition when using PHP 4.1.2 (this is the PHP version which our hosting company provides). For charset recognition, I use the following meta-tag: <meta...
12
by: lawrence | last post by:
How do I get PHP to tell the server that when I echo text to the screen, I need for the text to be sent as UTF-8? How does Apache know the right encoding when all the text is being generated by...
0
by: Matt | last post by:
Short Description: The Translation Hub is not picking up the TNS names file. I'm using Oracle 9ids. It doesn't work for any users and it has never worked since it's been installed. Long...
40
by: Chiwa | last post by:
Hey, Expression: Math.floor(x * 100) / 100 x= 4.1 gives 4.09, why in gods name? While other values for x don't give a problem. Thx in advance
5
by: Haines Brown | last post by:
I suspect this is a FAQ, but as a guide to my further investigation, I wondered what the options are for providing readers of my web pages with the ability to translate the pages into their own...
7
by: Steven T. Hatton | last post by:
Is there anything that gives a good description of how source code is converted into a translation unit, then object code, and then linked. I'm particularly interested in understanding why putting...
7
by: gmclee | last post by:
Hi there, I am writing a program to load HTML from file and send it to IE directly. I've met some problem in charset setting. Most of HTML have charset "us-ascii", for some reason, some UNICODE...
3
by: mistral | last post by:
how to set correct charset type for multi-language website? Site is on cms, and same headers are dynamically generated for all pages. The recommened charset type is <meta http-equiv="Content-Type"...
0
by: Stef Mientki | last post by:
hello, I've build a translation tool, to translate all strings in a python source file. As a extra gadget I added translation through Babel Fish, using beautifulsoup. Although it works...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.