views:

281

answers:

2

I have a crystal report that includes some XML data. This XML string is stored in a database column (Oracle 10g). Right now the report just displays the whole string in one big ugly mess. Is there any good way to either pretty print the xml (put tags on seperate lines, maybe indent nested tags) or even format the xml as I would other data in the report?

My current best idea (where best does not imply good) , is to just do a string replace everywhere I see ><, so that at least each tag will be on a separate line.

What would be awesome is a way to pass that xml string into a subreport and have the subreport use that xml as it's datasource. What would be almost as good, for my purposes, would be a prettyprintXML function somewhere in crystal that would just format the raw xml in a nice way. I have access to Crystal 11. Thank you.

EDIT - I appreciate the help so far, but I already know 37 different ways I could do this outside of Crystal. I am looking for a solution that works within the Crystal Reports design tool itself.

A: 

If you are using this on a web page, I believe that you should be able to format it using a css file. But you may also be able to use XSLT outside of Crystal Reports instead. Below are some links that may help.

Link for Displaying XML with CSS

Link for to a css with crystal reports question on SO

Link of an example of XSLT instead of Crystal Reports

Dusty
I need this to work in crystal reports itself. The report includes data from other tables/columns that are not xml. If I were doing this outside of crystal it would be trivial to just parse the xml and do whatever I wanted with it. but in this case the explicit goal is to produce a crytal report.
Peter Recore
A: 

Send the XML result through an identity transform XSLT with the output indent attribute set to yes.
It will output the same content, but "pretty printed"

<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;

<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

<xsl:template match="node() | @*">
   <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
   </xsl:copy>
</xsl:template>

</xsl:stylesheet>
Mads Hansen
How do I do XSL transforms on a string from within Crystal? To clarify, my question is not just how to pretty print XML - I could do that standing on my head if there were no other constraints. What makes it hard is that I am trying to do it from within Crystal Reports.
Peter Recore