Link to home
Start Free TrialLog in
Avatar of pbarry30
pbarry30

asked on

Rendering XML in readable format in HTML

Hi there,
we have CLOB objects in our database which contains XML data. We are reading this data and rendering our HTML pages with XSLT. Since the XML in this case is a data value, it comes encoded in our XML payload (&lt; &gt; instead of '<' and '>'). This is because we are using JAXB to handle the marshalling of our data objects and it encodes the data because it needs to produce well formed XML (at least that is what I am guessing)

So the question is - can I use XSLT to transform this encoded data so that I can put, at a minimum carriage returns before each tag?
What is happening currently is the HTML output is correct (<xsl:output method="html" indent="no"/>) but the XML is unreadable since we cannot enforce presentation - i.e. carriage returns and tabs

Any ideas?
Thanks

Pat
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Hi pbarry30,

you would get carriage returns in XSLT by having
<xsl:text>
</xsl:text>
(on two different lines)
you can also stuff that in a parameter and use it like that

<xsl:output method="html" indent="yes"/>
would already give you some indenting

unless what you are doing is having the XML escaped as pure text
(it seems from your question you do)

then the only thing you can do is stuff the XML wit <br /> for linebreaks and &nbsp; for spaces

Cheers!
Avatar of pbarry30
pbarry30

ASKER

How to I replace say &lt; with <br/>&lt; in XSLT?
ASKER CERTIFIED SOLUTION
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial