HI Jean-Francois,
please post a small Java program that creates a small DOM, for example a
document with only a root element, that has a text node child with say
a '>' and a  '\n' in it.  Also your code to serializer the DOM so I can see
how the 
 comes about.

I'm willing to investigate, but I'm not willing to spend time trying to
create the testcase.

Thanks,
- Brian
- - - - - - - - - - - - - - - - - - - -
Brian Minchau, Ph.D.
XSLT Development, IBM Toronto
e-mail:        [EMAIL PROTECTED]



                                                                           
             Jean-Francois                                                 
             Beaulac                                                       
             <jean-francois.be                                          To 
             [EMAIL PROTECTED]         Brian Minchau/Toronto/[EMAIL PROTECTED]  
   
             >                                                          cc 
                                                                           
             06/08/2007 04:43                                      Subject 
             PM                        RE: Serializing a DOM tree to XML   
                                       file, customize entities            
                                       replacement                         
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           




Hi,

Is that option supposed to change the String the transformer will use to
replace line separators? I just tried it and it changes nothing at all, my
XML output is still filled with &#13; strings.

What I am looking for would be a way to disable output escaping for
everything, except the characters I listed in my first post.

If I add the processing instruction in my DOM using:

ProcessingInstruction pi =
doc.createProcessingInstruction(Result.PI_DISABLE_OUTPUT_ESCAPING, "");
root.getParentNode().insertBefore(pi, root);

I get the desired result, but then I would need to manually escape all the
<
> & ' " characters.


Thank you

-----Original Message-----
From: Brian Minchau [mailto:[EMAIL PROTECTED]
Sent: June 8, 2007 4:16 PM
To: Jean-Francois Beaulac
Subject: Re: Serializing a DOM tree to XML file, customize entities
replacement

Hi Jean-Francois,

I think there are solutions to this, but all of them are Xalan specific.

I assume that you are running your DOM through the identity transformation
in order to serialize it.  This is the most portable way to do it.

Once you get your Transformer object, even though it is the identity
transform, you can set some properties via JAXP.  I suggest you try this:

javax.xml.transform.Transformer t = ...
t.setOutputProperty("{http://xml.apache.org/xalan}line-separator","; ");


If you had a stylesheet this could be done like this:
      <xsl:out   xalanPrfx:line-separator=" "
xmlns:xalanPrfx="http://xml.apache.org/xalan"; />
but you don't have a stylesheet.
Still JAXP lets you over-ride xsl:output attribute values, and I think this
should work even when there is no stylesheet.


So my suggestion is to not output the '\n'  but to output a space.   Of
course if you want something else like  "-EndOfLine-" then do this:

t.setOutputProperty("{http://xml.apache.org/xalan}line-separator","-EndOfLin

e-");

Hope this does the job for you.


- Brian
- - - - - - - - - - - - - - - - - - - -
Brian Minchau, Ph.D.
XSLT Development, IBM Toronto
e-mail:        [EMAIL PROTECTED]




             Jean-Francois
             Beaulac
             <jean-francois.be                                          To
             [EMAIL PROTECTED]         [email protected]
             >                                                          cc

             06/08/2007 03:01                                      Subject
             PM                        Serializing a DOM tree to XML file,
                                       customize entities replacement










Hi,

I am currently building a DOM tree using the Xerces implementation and then
write it to a String using the Xalan transformer.  I currently have a
problem with line breaks (I use System.getProperty("line.separator")) in
the
text nodes being replaced by the entity &#13;. The application I am trying
to then send the XML message to does not transform that entity back into a
line break.

Is there a way to tell Xalan to use either a custom set of entities, or to
remove specific entities from this automatic treatment or am I force the
reparse manually the result to replace the &#13; back to a normal line
separator. Having a way to tell the transformer to use a custom set of
entities would be my best option since the application I communicate with
only threats:

- &lt;
- &gt;
- &amp;
- &apos;
- &quot;

Thank you

================================
Jean-Francois Beaulac
[EMAIL PROTECTED]








Reply via email to