Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding FO blocks through <XSL:If> statements?

Status
Not open for further replies.

jfrost10

Programmer
Jun 3, 2001
2,004
CA
Hey guys,

Here's the sitch:

I pass my xsl an xml documen that looks something like this:

<Char Value=&quot;S&quot; Bold=&quot;True&quot; />
<Char Value=&quot;o&quot; Bold=&quot;True&quot; />
<Char Value=&quot;s&quot; Italic=&quot;True&quot; />

What I want to do in my xsl is something like this:
<xsl:if test=&quot;Bold='True'&quot;>
<fo:block font-weight=&quot;bold&quot;></fo:block>
</xsl:if>

Of course, if that code was working, i wouldn't be posting
;)

Anyone have any insight on how I can check a property of my xml node, and assign an fo property to that nodes value?

Thanks,

Jack
 
To check the node attribute you can use the @ character, like:
Code:
<xsl:if test=&quot;@Bold='True'&quot;>
   <fo:block font-weight=&quot;bold&quot;></fo:block>
</xsl:if>

Secondly, be sure you add the FO namespace at the beginning of your stylesheet, or you'll get plenty error messages.
[red]Nosferatu[/red]
We are what we eat...
There's no such thing as free meal...
once stated: methane@personal.ro
 
Hey Nos,

Thanks man, thats definatley a step in the right direction for me.

Question though: whatever I want shown needs to be within the fo:block tags, right (I could be wrong)? So how would I go about something adding fo:block attributes for multiple attributes.

i.e.
<xsl:if test = &quot;@Bold='True'&quot;>
Add the font-weight property to the fo block
</xsl:if>
<xsl:if test = &quot;@Italic='True'&quot;>
Add an italic property (whatever that is) to the SAME
fo:block
</xsl:if>
<xsl:if test = &quot;@Underline='True'&quot;>
see above, but some underline attribute, again to the
same fo:block
</xsl:if

Thanks again!

Jack
 
No problem Jack...

>> Question though: whatever I want shown needs to be within the fo:block tags, right (I could be wrong)?

Everything that's btw. those tags gets formatted with the rules there.

I am not sure about this, but what about adding those ifs within the <fo:block> element?
I really don't know much about fo, but this is the way I'd do it...

Or else, you can try to combine the if statements with and.

Code:
<xsl:if test = &quot;@Bold='True' and @Italic='True'&quot;>
    Add the font-weight property to the fo block
</xsl:if>

or, imbricate the if's... :) [red]Nosferatu[/red]
We are what we eat...
There's no such thing as free meal...
once stated: methane@personal.ro
 
I tried doing that already, but it doesn't seem to like it

I can do

<fo:block
xsl:do something in one line

but if I try this:
<fo:block
<xsl:if test=this>
do this
</xsl:if>

the rest of the fo block displays black (instead of the normal color scheme that my editor gives it), leading me to think that it doesn't like extra < or > tags within the block.

I could do the And thing, but then I'd have to have an and for every combination

Bold Italics Underlined
Bold
Bold Underlined
Bold Italics
Italics Underlined
etc.

and that could get a bit messy.

sigh...</me grumbles about my users>

btw, the suggestion you gave initially worked, and I can actually get bold output on my pdf! So thanks for that, it was great to finally see some progress!
:)

Jack
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top