• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

formatted XML Ouput  RSS feed

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi
I have the following XML File
<root>
<TAG>some value</TAG>
<TAG>another value</TAG>
</root>
the i wrote a XSLT Script

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:for-each select="/root">
<NEWTAG><xsl:value-of select="TAG"</NEWTAG>
<xsl:foreach/>
</xsl:template >
</xsl:stylesheet>

The ouput is
<NEWTAG>some value</NEWTAG><NEWTAG>another value</NEWTAG>
The formation get lost.
this is for the XML Parser ok - but for Humand its really hard to read when ther are more TAGS - the will be written all in one line
but i want the output to be
<NEWTAG>some value</NEWTAG>
<NEWTAG>another value</NEWTAG>/pre>

how ca i do that ?
by the way , if i use DOM and Java to create new elements the ouput is allright -but this has nothing to do with my question i think
Bye,
Holger
[This message has been edited by Holger Prause (edited January 18, 2001).]
[This message has been edited by Holger Prause (edited January 18, 2001).]
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How 'bout if you insert an empty <BR/> or a <p/> element just before <xsl:foreach/> ?? I am assuming the output type is HTML/XHTML and not an XML, since if it were to be an XML, that's how it is actually stored. There may/may not be any linebreaks!

------------------
Ajith Kallambella M.
Sun Certified Programmer for the Java2 Platform.
 
Holger Prause
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the ouput Type is XML
is ther really no possebility to print XML formatted out ?
 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might have to write a small utility yourself to do this.
Since XML is data representation, formatting has no scope inside the XML document. All whitespaces that do not belong to any element context are ignored making the entire document a cryptic stream of tightly bound tag sequence!.... that's the way it is


------------------
Ajith Kallambella M.
Sun Certified Programmer for the Java2 Platform.
 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On a related note, several browsers display XML documents with nice formatting. IE 5.5 onwards has built in XML support so that you can even drill-up and drill-down various levels of nesting. That's what I use to inspect large XML documents.
Ofcourse, if you're in side a program and want to inspect an XML stream, then the situation is different.

------------------
Ajith Kallambella M.
Sun Certified Programmer for the Java2 Platform.
 
Holger Prause
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok thx for your answers -

>since XML is data representation, formatting has no scope inside >the XML document. All whitespaces that do not belong to any >element context are
>ignored making the entire document a cryptic >stream of tightly bound tag sequence!.... that's the way it is
Ok i understand.Thank for your explanation.
>On a related note, several browsers display XML documents with >nice formatting. IE 5.5 onwards has built in XML support so that >you can even drill-up
> and drill-down various levels of nesting. >That's what I use to inspect large XML documents.
Thx for the tip i'll use vmware and explorer to view the code

bye,
Holger
 
BWA HA HA HA HA HA HA! Tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!