[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

distorting special characters

Subject: distorting special characters
From: "Pramodh Peddi" <peddip@xxxxxxxxxxxxxxxx>
Date: Tue, 4 Nov 2003 11:53:12 -0500
bytearrayoutputstream to file
Hi,
I am desparately looking for a solution for my problem.
This problem is occuring ONLY on UNIX machines. It is working fine on
Windows machines.
I am using Java1.4.1's Transformer to transform my xml files. The xml file
has &#8482; (TM symbol). And it spits out some funky chars in place of this
TM character. There are many such special chars in the source xml file (like
copyright, registered mark, etc).

In the application, I am trying to preserve the encoding. If I don't do
that, it is spitting out "?" marks in place of special chars.

I would appreciate any help. I am desperate for any advices and suggestions.

Source xml looks like this (i extracted a part of it to make it small):
****************source xml*********************
<content>
    <category name = "MavicaCLIE&#8482;"/>
</content>
*********************************************

This is what i get out of the transformation process:
---------------------------------------------------------------------
<content>
    <container>MavicaCLIEâÂ"¢</container>
</content>
--------------------------------------------------------------------

And the stylesheet looks like following:
=============================================
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="text"/>

<xsl:template match="/product_metadata">

<content>

   <container>

    <xsl:value-of select="category/@name" disable-output-escaping="yes"/>

</container>

</content>

</xsl:template>

</xsl:stylesheet>

==============================================

This is what I am doing in the application (source xml file has
"windows-1252" encoding):
**********************************************************************
ByteArrayOutputStream rawfileOutputStream =

new ByteArrayOutputStream();


// get the file

filePath = (String) taxKeyIt.next();

file = (SftpFile) taxFileMap.get(filePath);

filePath = ServiceUtils.getFileNameFromURL(filePath);

if (filePath != null) {

sftp.get(filePath, rawfileOutputStream);

rawfileOutputStream.close();

}


String content = new String(rawfileOutputStream.toByteArray(),
"windows-1252");


log.info("initialContent: " + content);


content = this.removeDTDFromMetadata(content);


// transform the file

TransformerFactory tFactory = TransformerFactory.newInstance();

Transformer transformer = tFactory.newTransformer(new StreamSource(new
URL(this.taxXSLT).openStream()));


ByteArrayInputStream rawfileInputStream = new
ByteArrayInputStream(content.getBytes("windows-1252"));

ByteArrayOutputStream transformedFileOutputStream = new
ByteArrayOutputStream();


File transformedFile = new File("../server/ic/deploy/data.war/" +
this.taxXSLTResult);

FileOutputStream out = new FileOutputStream(transformedFile);


transformer.transform(

new StreamSource(new InputStreamReader(rawfileInputStream)),

new StreamResult(new OutputStreamWriter(out, "UTF-8")));

rawfileInputStream.close();

transformedFileOutputStream.close();

// move file up to data dir

}

****************************************************************************
***

Thanks,

pramodh.


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.