Wednesday, February 10, 2010

Aha! BI Publisher - using XML element value in text form field options

This is exactly what I need!!! I spent hours trying to figure out how I can change background table cell using XML data element dynamically instead of using static colors.

This code below is to use XML data element value in the text form editor:

<xsl:value-of select="{XML_ELEMENT}">
Note: replace {XML_ELEMENT} above with the actual element tag in your XML.

Ok, now I know that I can use XML value in my text editor, then I can continue with shading background color in my table cell. I have fld_Y_XML_COLOR_1 as my XML element and its value as actual color name like "lightgrey" or RGB code like "#CCCCCC" (It works both ways).

Note: I am adding if statement below to only shade with a background color when the xml value exists. If xml value has null value, you end up with blackout cells.

<?if:fld_Y_XML_COLOR_1 != ''?> <xsl:attribute xdofo:ctx="block" name="background-color"> <xsl:value-of select="fld_Y_XML_COLOR_1"/> </xsl:attribute> <?end if?>
I have fun playing with it, so here is my end result:

No comments:

Post a Comment