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.



 

Comments:

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

Posted by Jake on July 20, 2007 at 07:49 PM MDT #

Hey Jake, I think you meant to comment on this post, http://blogs.oracle.com/xmlpublisher/2007/07/09/ ?

Posted by Tim Dexter on July 26, 2007 at 04:55 AM MDT #

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.

Posted by watch macgruber online on February 21, 2010 at 03:29 AM MST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Follow bipublisher on Twitter Find Us on Facebook BI Publisher Youtube ChannelDiscussion Forum

Join our BI Publisher community to get the most and keep updated with the latest news, How-to, Solutions! Share your feedback and let us hear your voice @bipublisher on Twitter, on our official Facebook page, and Youtube!

Search

Archives
« July 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  
       
Today