Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
|
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML 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 November 17th, 2003, 01:40 PM
Authorized User
 
Join Date: Nov 2003
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default ✓ not output correctly from DOM parser

Need a small help again.

in my original XMl file, I have an entity &10003;
It represents(ALT 10003) a check symbol(a box).

But the output XMl file from my DOMparser represents it as a question mark(?), which is NOT what I want.

I'm using DOM parser with JAXP API to parse the XML file.

Could you help me why does my parser doesn't output correct character for this particular entity only?

Any suggestion is grately appreciated.

-Srivalli.


 
Old November 18th, 2003, 02:09 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 147
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to armmarti
Default

Probably the editor you're using to see your output confuses you(doesn't support the encoding you specified in the XML declaration). Check this first or try some editor which allows hexadeciamal view.

Regards,
Armen
 
Old November 18th, 2003, 04:50 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Or your file is not encoded properly. Show some code.

Joe (MVP - xml)
 
Old November 18th, 2003, 10:31 AM
Authorized User
 
Join Date: Nov 2003
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi joefawcett,armmarti....

http://xml.coverpages.org/xml-ISOents.txt

This link has a character equivalent for check character, which is x2713 and it uses the encoding scheme of ISO 10646.

Here is the statement in my DTD...
----------------------------------
<!ENTITY check "#x2713;">
what I have above in quotations is &_#_x_2_7_1_3_;
(WITH OUT underscores)

This is a statement in input XML file...
------------------------------------
The foll &check; owing is


This is my Output XML file when viewed in EditPlus-a text editor....
---------------------------
The foll ? owing is


Here is the code in my java file where I didnot explicitly specify any output encoding type....
--------------------------------------------------
DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
factory.setValidating(true);
factory.setIgnoringElementContentWhitespace(true);
DocumentBuilder builder=factory.newDocumentBuilder();
currDocument=builder.parse(f);

TransformerFactory tf=TransformerFactory.newInstance();
Transformer t = tf.newTransformer(new StreamSource("transformoutput.xsl"));
t.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, "nmstat.dtd");

FileWriter fileOut = new FileWriter("outputAnno.xml");
t.transform(new DOMSource(document), new StreamResult(fileOut));


This is the code in transformoutput.xsl...
----------------------------------------------
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<xsl:copy-of select="node()"/>
</xsl:template>
</xsl:stylesheet>
-----------------------------------------------

Could you help me figuring out the problem.
Thank you very much.

-Srivalli.

 
Old November 19th, 2003, 09:16 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 147
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to armmarti
Default

Hi,

UTF-16 is an encoding of ISO 10646, so you must specify the encoding for the output document. Add this top-level element to your stylesheet:

Code:
<xsl:output method="xml" version="1.0" encoding="UTF-16"/>
Then, any editor(viewer, browser, etc.) which supports UTF-16 must show that character in a proper way.

Regards,
Armen





Similar Threads
Thread Thread Starter Forum Replies Last Post
Need "&" and "<!-- -->" in the output sunrain XSLT 2 January 19th, 2007 05:29 PM
Include & Output (possibly) Help MargateFan XSLT 2 June 14th, 2006 05:28 AM
input in html & output in jsp Befekadu Pro JSP 0 March 28th, 2005 10:28 AM
not able to write check box output into table knight Classic ASP Databases 5 June 7th, 2004 11:40 PM
XML DOM parser in java... recommend, plz sonicDace XML 0 February 3rd, 2004 02:38 PM





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