473,397 Members | 2,028 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,397 software developers and data experts.

Unicode (UTF-16) question

Hi (xsl novice here),

I have a file called myResources.xml that contains some strings that
will be localized.

In myXSL.xsl file, I read the strings from here to output as html.
myXSL.xsl is saved as UTF16.

myResources.xml is currently saved as ASCII.

Things work fine now.

But...when I change myResources.xml and save it as UTF16 (and put the
proper header <?xml version="1.0" encoding="UTF-16"?> at the top),
then things don't work any more.

The html that is generated is missing the strings that were supposed
to be substituted from myResources.xml.

It worked as ascii, but when I saved/switched myResources.xml to
UTF16, the substitutions stopped working.

myXSL.xsl is doing something like this:

<stuff deleted>

<xsl:variable name="translationsFile" select="concat($webRoot,
'/xsl/','myResources.xml')"/>
<xsl:variable name="translations"
select="document($translationsFile)"/>
<xsl:param name="isolang" select="'en'"/>

<xsl:variable name="reportTitleText">
<xsl:choose>
<xsl:when test="count($translations/LocalizedResources/resource[lang($isolang)]/displayText[@category='REPORT_TITLE'])
&gt; 0">
<xsl:copy-of select="$translations/LocalizedResources/resource[lang($isolang)]/displayText[@category='REPORT_TITLE']"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>My Default Report String</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
--------------
myResources.xml snippet below
<resource xml:lang="en">
<!-- Resources for viewing a report -->
<displayText category="REPORT_TITLE">Final Report</displayText>
etc.
-----------
Thanks for any suggestions.
Rob Cox
ro*****@dell.com
Jul 20 '05 #1
3 1414
Hi Rob,

It sounds as though when you are saving myResources.xml as UTF-16 it isn't
actually being encoded properly as UTF-16. Have you checked that document
loads and parses after saving it?

Depending on your transformation engine - this might explain why the
document() function is apparently bringing back nothing.
(http://www.w3.org/TR/xslt#document - in particular "If there is an error in
processing the fragment identifier, the XSLT processor may signal the error;
if it does not signal the error, it must recover by returning an empty
node-set."). In other words, if the document() function is failing to load
the document because it is improperly encoded then it may be just returning
an empty node-set - which might explain the behaviour you are seeing.

Cheers
Marrow
http://www.marrowsoft.com - home of Xselerator (XSLT IDE and debugger)
http://www.topxml.com/Xselerator
"Rob Cox" <ro*****@dell.com> wrote in message
news:b0**************************@posting.google.c om...
Hi (xsl novice here),

I have a file called myResources.xml that contains some strings that
will be localized.

In myXSL.xsl file, I read the strings from here to output as html.
myXSL.xsl is saved as UTF16.

myResources.xml is currently saved as ASCII.

Things work fine now.

But...when I change myResources.xml and save it as UTF16 (and put the
proper header <?xml version="1.0" encoding="UTF-16"?> at the top),
then things don't work any more.

The html that is generated is missing the strings that were supposed
to be substituted from myResources.xml.

It worked as ascii, but when I saved/switched myResources.xml to
UTF16, the substitutions stopped working.

myXSL.xsl is doing something like this:

<stuff deleted>

<xsl:variable name="translationsFile" select="concat($webRoot,
'/xsl/','myResources.xml')"/>
<xsl:variable name="translations"
select="document($translationsFile)"/>
<xsl:param name="isolang" select="'en'"/>

<xsl:variable name="reportTitleText">
<xsl:choose>
<xsl:when test="count($translations/LocalizedResources/resource[lang($isolang)]/displa
yText[@category='REPORT_TITLE']) &gt; 0">
<xsl:copy-of select="$translations/LocalizedResources/resource[lang($isolang)]/displayTex
t[@category='REPORT_TITLE']"/> </xsl:when>
<xsl:otherwise>
<xsl:text>My Default Report String</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
--------------
myResources.xml snippet below
<resource xml:lang="en">
<!-- Resources for viewing a report -->
<displayText category="REPORT_TITLE">Final Report</displayText>
etc.
-----------
Thanks for any suggestions.
Rob Cox
ro*****@dell.com

Jul 20 '05 #2
On 20 Oct 2004, Rob Cox wrote:
I have a file called myResources.xml that contains some strings that
will be localized.

In myXSL.xsl file, I read the strings from here to output as html.
myXSL.xsl is saved as UTF16.


Use UTF-8 instead of UTF-16 - especially when your final goal is HTML.
UTF-16 isn't currently a good idea for HTML.
http://ppewww.ph.gla.ac.uk/~flavell/...checklist.html

--
Top-posting.
What's the most irritating thing on Usenet?

Jul 20 '05 #3
On Wed, 20 Oct 2004, Andreas Prilop wrote:
On 20 Oct 2004, Rob Cox wrote:
I have a file called myResources.xml that contains some strings that
will be localized.

In myXSL.xsl file, I read the strings from here to output as html.
myXSL.xsl is saved as UTF16.
Use UTF-8 instead of UTF-16 - especially when your final goal is HTML.
UTF-16 isn't currently a good idea for HTML.


As far as what is served-out to the web is concerned, I would agree
with you...

But to some extent it's the hon Usenaut's own private affair how they
choose to store their data internally, if they have a good way to
recode it into an appropriate form for serving out to the web.
http://ppewww.ph.gla.ac.uk/~flavell/...checklist.html


Well, that page aims specifically at the use of HTML served as
text/html in a WWW context for browsing with HTML-ish browsers.

There's a brief note about XHTML/1.0 served out under Appendix C,
but I don't go any more-deeply into XML issues. It'd be interesting,
seeing that we're on an XML group, if XML practitioners would care
to review it and see how it matches their own views of the
practicalities.
Jul 20 '05 #4

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

Similar topics

6
by: Spamtrap | last post by:
I only work in Perl occasionaly, and have been searching for a solution for a conversion, and everything I found seems much too complex. All I need to do is take a simple text file and copy...
4
by: Amir | last post by:
Hello. Can someone help me with the diff between UTF8 and Unicode encoding ? I know both use 8 bits, both can use more then 2 Bytes (?) Thanks.
4
by: FE-FR | last post by:
Hi, I would like to know if I can display unicode characters with VB6. For example with a Label or textbox control. If it is not possible directly, are there anu workaround ? APIs, ... ...
2
by: Rob | last post by:
Hello, We are in the process of writing an application that is unicode compliant. The question that I have is what unicode font should be used for all of our forms? Currently we are using...
5
by: fidtz | last post by:
The code: import codecs udlASCII = file("c:\\temp\\CSVDB.udl",'r') udlUNI = codecs.open("c:\\temp\\CSVDB2.udl",'w',"utf_16") udlUNI.write(udlASCII.read()) udlUNI.close()
5
by: goldtech | last post by:
Hi, I have a regular expression test in a script. When a unicode character get tested in the regex it gives an error: UnicodeError: ASCII decoding error: ordinal not in range(128) Question:...
11
by: John Nagle | last post by:
I passed a dict for the "env" variable to Popen with Unicode strings for the dictionary values. Got: File "D:\Python24\lib\subprocess.py", line 706, in _execute_child TypeError: environment...
1
by: Server Applications | last post by:
Hello I am trying to build a system where I can full-text index documents with UTF8 or UTF16 data using Oracle Text. I am doing the filtering in a third-party component outside the database, so...
4
by: billsahiker | last post by:
Where do I find the unicode values for math operators like equal, minus and plus sign and how to I check if the value of a byte array is one of these operators? I populate the byte array from a...
29
by: Ioannis Vranos | last post by:
Hi, I am currently learning QT, a portable C++ framework which comes with both a commercial and GPL license, and which provides conversion operations to its various types to/from standard C++...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.