• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

replace OutputFormat.setPreserveSpace by JAXP

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic