File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

replace OutputFormat.setPreserveSpace by JAXP

 
Tom John
Greenhorn
Posts: 29
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to translate "OutputFormat.setPreserveSpace()" into JAXP?

I'm working on the code implemented by the old Xerce.jar&Xalan.jar.
Now I need to adapt these code by JAXP.

I faced these lines as below:
===============implemented by the old Xerce.jar&Xalan.jar====================
Document doc = ...;
OutputFormat format = new OutputFormat(doc);
format.format.setIndenting(true);
format.setPreserveSpace(true);
format.setLineWidth(65);


Now I can successfully translate the method "setIndenting" by the following
==============================implemented by the JAXP========================
TransformerFactory tfactory = TransformerFactory.newInstance();
Transformer serializer= tfactory.newTransformer();
serializer.setOutputProperty(OutputKeys.INDENT, "yes");
...

Now I don't know how to translate the method of "setPreserveSpace" in JAXP?
I also don't know how to translate the method of "setLineWidth" in JAXP?

Looking forword your help!

Thanks in advance!
 
Paul Clapham
Sheriff
Pie
Posts: 20187
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do those things do? (Yes, I suppose I could google for it, but it would be more convenient for potential answerers if they didn't have to do that.)
 
Tom John
Greenhorn
Posts: 29
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul, can you help me?

I googled my questions already..
But I can't find out any answer...
 
Paul Clapham
Sheriff
Pie
Posts: 20187
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didn't mean for you to search for the answer. I meant for you to tell us what the question means. What does "setPreserveSpace" do?
 
Tom John
Greenhorn
Posts: 29
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul, actually, I also don't know what's the setPreserveSpace.

I only know it's a old method in class org.apache.xml.serialize.OutputFormat which is from old Xerce.jar.

I guess can we translate this method by DocumentBuilderFactory.setIgnoringElementContentWhitespace(false) in JAXP???
 
Paul Clapham
Sheriff
Pie
Posts: 20187
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Tom John:
Paul, actually, I also don't know what's the setPreserveSpace.

I only know it's a old method in class org.apache.xml.serialize.OutputFormat which is from old Xerce.jar.
Pity you didn't keep the documentation when you downloaded that, then. I could only find documentation for what I suppose is a newer version, and it doesn't have that method. You could try removing it from your code to see what difference that makes. Then you might be able to figure out what it does.
I guess can we translate this method by DocumentBuilderFactory.setIgnoringElementContentWhitespace(false) in JAXP???
Nope. Your original question was about serializing XML. That's taking data from some internal format and producing an XML document from it. You can't equate that to something that a parser does, namely taking an XML document and producing some internal format from it. Besides which "ignoring element-content whitespace" sounds exactly opposite to "preserve space" to me.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic