Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 1st, 2005, 05:31 AM
Authorized User
 
Join Date: Jan 2004
Posts: 66
Thanks: 0
Thanked 0 Times in 0 Posts
Default UTF Output Problems

Hi Folks,

Me again!!

I have a strange problem, relating to yesterday's post. Using the same xml and stylesheets:

Xml file to be transformed:

<rs:data>
    <z:row CarVidNo="33445566" CarRegNo="345rtgy" CarMake="Renault" CarModel="Clio" CarColour="Blue" CarEngine="1.2" CarPrice="5000"/>
    <z:row CarVidNo="55667788" CarRegNo="SXI 6002" CarMake="Vauxhall" CarModel="Corsa" CarColour="White" CarEngine="1.1" CarPrice="1000"/>
</rs:data>

Stylesheets to perform transformations:

<xsl:import href="copy.xslt"/>

    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" />


      <xsl:template match="*[z:row]">


                <xsl:apply-templates/>

      </xsl:template>


        <xsl:template match="s:Schema">
                <xsl:for-each select="z:row">
                    <xsl:apply-templates />
                </xsl:for-each>
        </xsl:template>


        <xsl:template match="z:row/@*">
          <xsl:element name="{name( )}">
                <xsl:value-of select="." />
          </xsl:element>
        </xsl:template>


        <xsl:template match="z:row">
          <xsl:element name="Cars">
                <xsl:apply-templates select="z:row"/>
          </xsl:element>
        </xsl:template>
</xsl:stylesheet>

And here is the copy stylesheet:

<xsl:template match="node( ) | @*">
  <xsl:copy>
    <xsl:apply-templates select="@* | node( )"/>
  </xsl:copy>
</xsl:template>

However, even though output is specied as UTF-8, the output I am getting is in UTF-16 format.

Out of interest, would this interfer with the way the transformed XML would respond to DOM parsing? I am trying to get info out of the file using DOM and it is falling over when I try to use this code:

psParentNode = pxmlDOM.documentElement.firstChild.childNodes.Item (1).nodeName

I am at a loss to explain this - any ideas?

Cheers,

Morris

 
Old June 1st, 2005, 09:05 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

>However, even though output is specied as UTF-8, the output I am getting is in UTF-16 format.

This generally means either (a) you are not serializing the result using the XSLT serializer, but using the DOM serializer, or (b) you are serializing the result using the XSLT serializer, but sending the result to a "character" rather than "byte" destination, which means that the final encoding of characters to bytes is not being done by the XSLT serializer. This is all a question of how the transformation is invoked from the API. I've only ever seen this on Microsoft environments, not in Java, because Java doesn't tend to encode output as UTF-16 unless you ask for it explicitly.


Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
URLEncoding(UTF-8) creating problems in Tomcat 6.0 SambaLH BOOK: Expert One-on-One J2EE Design and Development 0 September 19th, 2008 08:49 AM
text output problems dextermagnific XSLT 1 August 10th, 2006 12:31 PM
UTF-8 sebastian Classic ASP Basics 0 March 16th, 2005 08:22 AM
problems with stored proc and output parameters zieg42 VB.NET 2002/2003 Basics 1 June 12th, 2004 07:11 AM
UTF-8 msxml lpinho XML 4 January 28th, 2004 06:10 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.