[jdom-interest] FW: How to preserve entities using DOM?

Shance Ordell sordell at rightworks.com
Fri Oct 20 17:23:33 PDT 2000


I'm using Sun's JAXP.JAR to parse an XSL file. I submitted the questions
below to XML-INTEREST at SUN.COM. To date, I have not received any reply.

I'm wondering if this is something that has been addressed in JDOM? Or if
anyone on this list knows the answer to my questions below? Or if anyone on
this list knows were to go to get my questions answered?

Thanks in advance.

-----Original Message-----
From: Shance Ordell 
Sent: Friday, October 20, 2000 5:14 PM
To: 'XML technologies in the Java Platform'
Subject: RE: How to preserve entities using DOM?


I realized that as I was parsing the DOM I could pass the current attribute
value to a method that would convert the value to " " if the current
value equaled "160". 

The same can be done for text nodes. The value of the text node can be
passed to this method. When the method encounters a value of "160" it
returns " " instead. 

Once the method returns I print the value of the node just to make sure. And
it does look correct.

I then cast my document as an XmlDocument so that I can call the
XmlDocument.write() method to write the document to disk. 

The problem is that the " " gets converted to " ".

When viewed in a browser I see " ". It appears that the browser
converts the "&" to an "&" and then returns " " instead of
interpretting this as a non-breaking space.

Now that I've figured out how to get the value correct in the DOM, how do I
get it to disk in exactly the same format?

-----Original Message-----
From: Shance Ordell [mailto:sordell at RIGHTWORKS.COM]
Sent: Thursday, October 19, 2000 10:09 AM
To: XML-INTEREST at JAVA.SUN.COM
Subject: FW: How to preserve entities using DOM?


> I am using DOM to parse our XSL files. These XSL files have numeric
> character references or pre-defined entities in them.
>
> For example, most of the XSL files have the   numeric character
> reference which represents a non-breaking space.
>
> The problem is when I parse the document with numeric character references
> or pre-defined entities using DOM the numeric character references or
> pre-defined entities are converted to their actual character equivalent.
> This occurs if the numeric character references or pre-defined entities
> are part of a text node or part of an attribute value. When I write the
> DOM out to file using XmlDocument.write the numeric character references
> or pre-defined entities no longer exist.
>
> This type of modification is not desired. Does anyone know how to preserve
> this information when going from an XSL file, to DOM, and back to an XSL
> file?

-----------------------------------------------------
xml-interest: A list for discussing XML technologies in the Java Platform.
To post, mailto:xml-interest at java.sun.com
Archives at: http://archives.java.sun.com/xml-interest.html
To unsubscribe, mailto:listserv at java.sun.com the following message;
signoff xml-interest.



More information about the jdom-interest mailing list