X

An Oracle blog about BI Publisher

Dynamic Formatting Again

Question on the forum today asking how you might use some meta information stored in the incomng XML data to format the final output i.e. override any formatting you might have created in the RTF template. I covered how to do this if the XML is actually HTML e.g.

<TEXT><B>Report Title</B></TEXT> 

You can check that out here.


What to do if you have something like the following:

<?xml version='1.0'?>

<POEM>

<TITLE format="bold">The Crazy Dog</TITLE>

<TEXT format="italic">I've seen many strange dogs but this is the one.
you should see some of the things hes done.
I've seen him jump and try to eat sand.
he had a mouth full of dirt as soon as he would land.
if you saw him you'd probably giggle.
if you do you have probably seen him squiggle.
the strange thing is hes never snappy
but he is always happy!
every one knows him now
and he says to you "bow wow!"
</TEXT>
</POEM>


Notice the format attributes specifying how the text shuld be formatted.
We need to use some of the techniques from the HTML formatting article to specify the formatting required using the XSLFO syntax. Keeping things simple we can just use simple conditional 'if' statements to check the value of the 'format' attributes. Using the TITLE element we can use:

<?if:@format='bold'?>
 <xsl:attribute xdofo:ctx="block" name="font-weight">bold</xsl:attribute>
<?end if?>

Similar approach for the italic or any other attribute. You could build a subtemplate to handle all of the possible 'formatting' options to simplify your coding and making it more dynamic. Get ya example files here.


In case you're wondering, the poem is from my son about our new puppy.




Join the discussion

Comments ( 3 )
  • Jake Saturday, July 21, 2007
    Thanks Tim. We carried this project all around the company for 2.5 years because we know it has value, and customers will love it. Jake
  • Tim Dexter Thursday, July 26, 2007
    Hey Jake, I think you meant to comment on this post, http://blogs.oracle.com/xmlpublisher/2007/07/09/ ?
  • watch macgruber online Sunday, February 21, 2010
    Hey there, I tried to contact you about this article but can't seem to reach you. I highly recommend you e mail me whenever you get a moment. Many thanks.
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.