XSL - Switch statement - help needed with syntax - xslt

Kind of a new XSL user and I'm trying to use a switch/choose syntax without much luck. It seems to be defaulting every time to the 'otherwise' section. Here is the code I'm attempting to use:
<xsl:choose>
<xsl:when test="#accountno=264835">
<fo:table-cell padding="2pt"><fo:block text-align="center"><xsl:value-of select="format-number(#previousread * .1, '###,###,##0.000')"/></fo:block></fo:table-cell>
<fo:table-cell padding="2pt"><fo:block text-align="center"><xsl:value-of select="format-number(#current * .1, '###,###,##0.000')"/></fo:block></fo:table-cell>
</xsl:when>
<xsl:when test="#accountno=201631">
<fo:table-cell padding="2pt"><fo:block text-align="center"><xsl:value-of select="format-number(#previousread * .1, '###,###,##0.000')"/></fo:block></fo:table-cell>
<fo:table-cell padding="2pt"><fo:block text-align="center"><xsl:value-of select="format-number(#current * .1, '###,###,##0.000')"/></fo:block></fo:table-cell>
</xsl:when>
<xsl:when test="#accountno=130159">
<fo:table-cell padding="2pt"><fo:block text-align="center"><xsl:value-of select="format-number(#previousread * .1, '###,###,##0.000')"/></fo:block></fo:table-cell>
<fo:table-cell padding="2pt"><fo:block text-align="center"><xsl:value-of select="format-number(#current * .1, '###,###,##0.000')"/></fo:block></fo:table-cell>
</xsl:when>
<xsl:when test="#cycle=5">
<fo:table-cell padding="2pt"><fo:block text-align="center"><xsl:value-of select="format-number(#previousread * .1, '###,###,##0.000')"/></fo:block></fo:table-cell>
<fo:table-cell padding="2pt"><fo:block text-align="center"><xsl:value-of select="format-number(#current * .1, '###,###,##0.000')"/></fo:block></fo:table-cell>
</xsl:when>
<xsl:otherwise>
<fo:table-cell padding="2pt"><fo:block text-align="center"><xsl:value-of select="format-number(#previousread * 748 div 1000, '###,###,##0.000')"/></fo:block></fo:table-cell>
<fo:table-cell padding="2pt"><fo:block text-align="center"><xsl:value-of select="format-number(#current * 748 div 1000, '###,###,##0.000')"/></fo:block></fo:table-cell>
</xsl:otherwise>
</xsl:choose>
Am I not testing the variables correctly? Something else?
Any and all help is greatly appreciated!
Thank you
Edit: more info
Just wondering if I'm testing the variables correctly in the choose/switch statement I guess...
<xsl:choose>
<xsl:when test="#accountno='264835'">
<!-- do something here if account matches 264835 -->
</xsl:when>
<xsl:when test="#accountno='201631'">
<!-- do something here if account matches 201631-->
</xsl:when>
<xsl:when test="#accountno='130159'">
<!-- do something here if account matches 130159 -->
</xsl:when>
<xsl:when test="#cycle='5'">
<!-- do something here if cycle matches 5 -->
</xsl:when>
<xsl:otherwise>
<!-- everything seems to be defaulting here -->
</xsl:otherwise>
</xsl:choose>
More Information: I am not sure about context and that meaning, I assume you're correct that there is an error in there somewhere... This is a little more of the code... hope it helps with context:
<xsl:for-each select="lineitems/servicelocation/group[#chargetype='METERED']/meter/meterread[string-length(#previousdate) > 0]">
<xsl:sort select="concat(substring(#previousdate, 7, 4),substring(#previousdate, 1, 2),substring(#previousdate, 4, 2))" data-type="number"/>
<fo:table-row font-size="8pt">
<fo:table-cell padding="2pt">
<fo:block><xsl:value-of select="../#number"/></fo:block>
</fo:table-cell>
<xsl:choose>
<xsl:when test="#accountno='264835'">
<fo:table-cell padding="2pt"><fo:block text-align="center"><xsl:value-of select="format-number(#previousread * .1, '###,###,##0.000')"/></fo:block></fo:table-cell>
<fo:table-cell padding="2pt"><fo:block text-align="center"><xsl:value-of select="format-number(#current * .1, '###,###,##0.000')"/></fo:block></fo:table-cell>
</xsl:when>
<xsl:when test="#accountno='201631'">
<fo:table-cell padding="2pt"><fo:block text-align="center"><xsl:value-of select="format-number(#previousread * .1, '###,###,##0.000')"/></fo:block></fo:table-cell>
<fo:table-cell padding="2pt"><fo:block text-align="center"><xsl:value-of select="format-number(#current * .1, '###,###,##0.000')"/></fo:block></fo:table-cell>
</xsl:when>
<xsl:when test="#accountno='130159'">
<fo:table-cell padding="2pt"><fo:block text-align="center"><xsl:value-of select="format-number(#previousread * .1, '###,###,##0.000')"/></fo:block></fo:table-cell>
<fo:table-cell padding="2pt"><fo:block text-align="center"><xsl:value-of select="format-number(#current * .1, '###,###,##0.000')"/></fo:block></fo:table-cell>
</xsl:when>
<xsl:when test="#cycle='5'">
<fo:table-cell padding="2pt"><fo:block text-align="center"><xsl:value-of select="format-number(#previousread * .1, '###,###,##0.000')"/></fo:block></fo:table-cell>
<fo:table-cell padding="2pt"><fo:block text-align="center"><xsl:value-of select="format-number(#current * .1, '###,###,##0.000')"/></fo:block></fo:table-cell>
</xsl:when>
<xsl:otherwise>
<fo:table-cell padding="2pt"><fo:block text-align="center"><xsl:value-of select="format-number(#previousread * .748, '###,###,##0.000')"/></fo:block></fo:table-cell>
<fo:table-cell padding="2pt"><fo:block text-align="center"><xsl:value-of select="format-number(#current * .748, '###,###,##0.000')"/></fo:block></fo:table-cell>
</xsl:otherwise>
</xsl:choose>
<fo:table-cell padding="2pt"><fo:block text-align="right"><xsl:value-of select="#billingusage"/></fo:block></fo:table-cell>
</fo:table-row>
</xsl:for-each>
Thank you for your help!

Since you haven't shown us the context for this instruction, this probably means you haven't understood the importance of context, which probably means that you've got the context wrong. But of course this is pure guesswork.
Check that the context item (established by the instructions surrounding this xsl:choose) is the element you think it is.

Related

Smartest way to switch attribute sets in XSLT

I'm currently doing something like this, and it feels like really bad coding style. The structure of the <fo:table-row> and <fo:table-cell> elements is exactly the same, only the xsl:use-attribute-sets is different. What is the smartest way to switch the attribute sets? The XSL version is no limitation.
<xsl:template name="myTemplate">
<xsl:param name="number-of-parts" as="xs:integer"/>
<xsl:choose>
<xsl:when test="$number-of-parts <= 16">
<fo:table-row xsl:use-attribute-sets="__toc__mini__table__row__empty">
<fo:table-cell xsl:use-attribute-sets="__toc__mini__table__row__empty__cell">
<fo:block/>
</fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="__toc__mini__table__row__empty__cell">
<fo:block/>
</fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="__toc__mini__table__row__empty__cell">
<fo:block/>
</fo:table-cell>
</fo:table-row>
</xsl:when>
<!-- If more than 16 languages -->
<xsl:otherwise>
<fo:table-row xsl:use-attribute-sets="__toc__mini__table__row__empty__small">
<fo:table-cell xsl:use-attribute-sets="__toc__mini__table__row__empty__cell__small">
<fo:block/>
</fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="__toc__mini__table__row__empty__cell__small">
<fo:block/>
</fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="__toc__mini__table__row__empty__cell__small">
<fo:block/>
</fo:table-cell>
</fo:table-row>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
The attribute-set mechanism is very static, as you have discovered. If you have a dynamic requirement, I think attribute sets are best avoided (actually, I hardly ever use them myself).
Do something like
<fo:table-cell>
<xsl:sequence select="f:my-attribute-sets('small')">
<fo:block/>
</fo:table-cell>
and generate the attributes from your f:my-attribute-sets function.
Something like this? (Untested because I don't have your input to test with.)
<xsl:template name="myTemplate">
<xsl:param name="number-of-parts" as="xs:integer"/>
<xsl:variable name="table_row_variable">
<xsl:choose>
<xsl:when test="$number-of-parts <= 16">__toc__mini__table__row__empty</xsl:when>
<xsl:otherwise>__toc__mini__table__row__empty__cell__small</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<fo:table-row xsl:use-attribute-sets="{$table_row_variable}">
<fo:table-cell xsl:use-attribute-sets="{$table_row_variable}">
<fo:block/>
</fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="{$table_row_variable}">
<fo:block/>
</fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="{$table_row_variable}">
<fo:block/>
</fo:table-cell>
</fo:table-row>
</xsl:template>

Using a param as the argument to XSL select statement

I am using apache fop to produce a PDF, I have an XSL-FO template that produces a table and I would like to be able to call the template multiple times, with different select parameters.
here is my xsl stylesheet
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:fox="http://xmlgraphics.apache.org/fop/extensions"
version="1.0">
<xsl:output method="html"/>
<xsl:template name="checklist">
<xsl:param name="H1"/>
<xsl:param name="H2"/>
<xsl:param name="H3"/>
<xsl:param name="src"/>
<fo:block width="19cm" >
<fo:table font-size="8pt" table-layout="fixed" width="100%">
<fo:table-column column-width="1.2cm"/>
<fo:table-column column-width="16.5cm"/>
<fo:table-column column-width="1.2cm"/>
<fo:table-header font-weight="bold" background-color="lightgrey">
<fo:table-row>
<fo:table-cell>
<fo:block><xsl:value-of select="$H1"/></fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block text-align="center"><xsl:value-of select="$H2"/></fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block><xsl:value-of select="$H3"/></fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body>
<xsl:apply-templates select="$src" />
</fo:table-body>
</fo:table>
</fo:block>
</xsl:template>
<xsl:template match="item">
<fo:table-row line-stacking-strategy="line-height" margin="0mm" space-before="1mm" background-color="white">
<xsl:variable name="hdr" select="hdr"/>
<xsl:choose>
<xsl:when test="$hdr = 'y'">
<fo:table-cell number-columns-spanned="3" background-color="lightgrey" border="1px solid #b8b6b6">
<fo:block>
<fo:inline>
<xsl:value-of select="id"/> 
<xsl:value-of select="description"/>
</fo:inline>
</fo:block>
</fo:table-cell>
</xsl:when>
<xsl:otherwise>
<fo:table-cell border="1px solid #b8b6b6" vertical-align="middle" text-align="center">
<fo:block line-height="4mm">
<xsl:value-of select="id"/>
</fo:block>
</fo:table-cell>
<fo:table-cell border="1px solid #b8b6b6" padding-left="3pt">
<fo:block>
<xsl:value-of select="description"/>
</fo:block>
</fo:table-cell>
<fo:table-cell border="1px solid #b8b6b6" text-align="center" padding-right="3pt">
<xsl:variable name="outcome" select="outcome"/>
<fo:block color="white">
<!--<fo:external-graphic src="file:///F:/Projects/Active/eCert/src/resources/c1.svg" width="4.0mm" height="4.0mm" content-width="scale-to-fit" content-height="scale-to-fit"/>-->
<xsl:choose>
<xsl:when test="$outcome = 'ok'">
<fo:external-graphic src="file:///F:/Projects/Active/eCert/src/resources/c1n.svg" vertical-align="middle" height="4.0mm" content-height="scale-to-fit"/>
</xsl:when>
<xsl:when test="$outcome = 'c1'">
<fo:external-graphic src="file:///F:/Projects/Active/eCert/src/resources/ok.svg" vertical-align="middle" height="3.9mm" content-height="scale-to-fit"/>
</xsl:when>
<xsl:when test="$outcome = 'c2'">
<fo:external-graphic src="file:///F:/Projects/Active/eCert/src/resources/c2.svg" vertical-align="middle" height="3.8mm" content-height="scale-to-fit"/>
</xsl:when>
<xsl:when test="$outcome = 'c3'">
<fo:external-graphic src="file:///F:/Projects/Active/eCert/src/resources/c3.svg" vertical-align="middle" height="3.7mm" content-height="scale-to-fit"/>
</xsl:when>
<xsl:when test="$outcome = 'fi'">
<fo:external-graphic src="file:///F:/Projects/Active/eCert/src/resources/fi.svg" vertical-align="middle" height="3.6mm" content-height="scale-to-fit"/>
</xsl:when>
<xsl:when test="$outcome = 'nv'">
<fo:external-graphic src="file:///F:/Projects/Active/eCert/src/resources/nv.svg" vertical-align="middle" height="3.5mm" content-height="scale-to-fit"/>
</xsl:when>
<xsl:when test="$outcome = 'na'">
<fo:external-graphic src="file:///F:/Projects/Active/eCert/src/resources/na.svg" vertical-align="middle" height="3.4mm" content-height="scale-to-fit"/>
</xsl:when>
<xsl:when test="$outcome = 'lim'">
<fo:external-graphic src="file:///F:/Projects/Active/eCert/src/resources/lim.svg" vertical-align="middle" height="3.3mm" content-height="scale-to-fit"/>
</xsl:when>
</xsl:choose>
</fo:block>
</fo:table-cell>
</xsl:otherwise>
</xsl:choose>
</fo:table-row>
</xsl:template>
</xsl:stylesheet>
And here is one of the flows that calls the template
<fo:flow flow-name="xsl-region-body">
<fo:block />
<xsl:call-template name="checklist">
<xsl:with-param name="H1" select="'Item No.'"/>
<xsl:with-param name="H2" select="'Description'"/>
<xsl:with-param name="H3" select="'Outcome'"/>
<xsl:with-param name="src" select="'eicr/checklist/item'"/>
</xsl:call-template>
</fo:flow>
When I execute FOP I get the following error ** Can not convert #STRING to a NodeList!**
Parameters H1, H2 and H3 are used as the column headers and that part works fine
The src param is the one that should be used to select the items from from an xml list.
I am new xsl fo so any help or pointers to documentation that can help me achieve the desired result would be appreciated.
Many thanks
Remove the single-quotes around eicr/checklist/item. 'eicr/checklist/item' is a string literal; eicr/checklist/item is a location path that will select elements relative to the context node.
The alternative that I was trying to avoid (because it's more verbose) is to apply templates before or as part of calling the template and then just copying the result to the result tree:
<xsl:with-param name="src">
<xsl:apply-templates select="eicr/checklist/item" />
</xsl:with-param>
<fo:table-body>
<xsl:copy-of select="$src" />
</fo:table-body>
It's a technique that you see in the DocBook XSLT 1.0 stylesheets, e.g.:
https://github.com/docbook/xslt10-stylesheets/blob/6ff683948c5a85949e4b7661f302e8b5f12f7bf2/xsl/fo/block.xsl#L181

XSL fo:block long word not wrap in table cell

I have tried wrap-option="wrap" and zero-width-space in fo:block but it's not working as excepted even I have used hyphenation=" true" is not working for alphanumeric words. Could you please help me to resolve this wrap issue
[Table pdf view]
https://i.stack.imgur.com/Hggq0.png
<fo:table-cell number-columns-spanned="{$colspan}" number-rows-spanned="{$rowspan}" padding-before="4pt" padding-after="1pt" padding-start="4pt" padding-end="4pt">
<fo:block wrap-option="wrap" start-indent="1pt">
<xsl:attribute name="text-align">
<xsl:choose>
<xsl:when test="#align">
<xsl:value-of select="#align"/>
</xsl:when>
<xsl:when test="ancestor::tgroup/colspec[number($entry)]/#align">
<xsl:value-of select="ancestor::tgroup/colspec[number($entry)]/#align"/>
</xsl:when>
<xsl:when test="ancestor::tgroup/#align">
<xsl:value-of select="ancestor::tgroup/#align"/>
</xsl:when>
<xsl:otherwise> left </xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:if test="ancestor::thead">
<xsl:attribute name="font-weight">bold</xsl:attribute>
</xsl:if>
<xsl:apply-templates/>
</fo:block>
<xsl:call-template name="indicateChangesEnd">
<xsl:with-param name="changeType" select="../#changeType"/>
<xsl:with-param name="changeMark" select="../#changeMark"/>
</xsl:call-template>
</fo:table-cell>
xsl:fo
<fo:table-cell padding-after="2pt" padding-before="2pt" number-rows-spanned="1" number-columns-spanned="1" border-top="1px solid black" border-bottom="1px solid black" border-left="1px solid black" border-right="1px solid black">
<fo:block wrap-option="wrap" start-indent="1pt" text-align="left">hhhhhhhhhhhhhhhhhhhhhhhhhvvvvvvyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjgggggggggggggggggggggggg7777777777777777777777777777777777777777</fo:block>
</fo:table-cell>
<fo:table-cell padding-after="2pt" padding-before="2pt" number-rows-spanned="1" number-columns-spanned="1" border-top="1px solid black" border-bottom="1px solid black" border-left="1px solid black" border-right="1px solid black">
<fo:block wrap-option="wrap" start-indent="1pt" text-align="left">hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh</fo:block>
</fo:table-cell>

How to generate a blank table cell in XSL?

why does the table cell disappear when there is no photo existing to generate?
i am using the following code which is not working. What do i need to change if i want to generate a blank table cell if there is no photo existing to generate?
<xsl:for-each select="...............">
<xsl:choose>
<xsl:when test="*">
<xsl:if test=".....">
<xsl:if test=".......">
<fo:table-cell border="solid" text-align="center" font-weight="bold" number-columns-spanned="1">
<fo:block>
<fo:external-graphic src="url('{concat($FILEPATH,.....'])}')"
inline-progression-dimension.maximum="4.1cm" block-progression-dimension.maximum="4cm"
content-width="scale-to-fit" content-height= "scale-to-fit" scaling="uniform"/>
</fo:block>
</fo:table-cell>
</xsl:if>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<fo:table-cell border="solid" text-align="center" font-weight="bold" number-columns-spanned="1">
<fo:block>
<fo:leader/>
</fo:block>
</fo:table-cell>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
Your have <xsl:when test="*"> ... is that node empty? If that is your outside test and passes, but the other IFs (you do not show) do not pass their test, your template yields nothing.
Breaking this down with comments:
<xsl:when test="*">
<xsl:if test=".....">
<!-- If this does not pass, you get nothing -->
<xsl:if test=".......">
<!-- If this does not pass, you get nothing -->
<fo:table-cell border="solid" text-align="center" font-weight="bold" number-columns-spanned="1">
<fo:block>
<fo:external-graphic src="url('{concat($FILEPATH,.....'])}')"
inline-progression-dimension.maximum="4.1cm" block-progression-dimension.maximum="4cm"
content-width="scale-to-fit" content-height= "scale-to-fit" scaling="uniform"/>
</fo:block>
</fo:table-cell>
</xsl:if>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<fo:table-cell border="solid" text-align="center" font-weight="bold" number-columns-spanned="1">
<fo:block>
<fo:leader/>
</fo:block>
</fo:table-cell>
</xsl:otherwise>
Kevin is right, given your example, your when clause is likely satisfied but if one of your if statements evaluates as false, you will get an empty table-cell. My advice is to add the conditions of your if statements to the when clause using logic operators such as AND/OR, for example, say the conditions in your template where like this...
<xsl:when test="$node = 'A'">
<xsl:if test="$node/child = 'B'">
<xsl:if test="not(contains($node/child,'C'))">
<fo:table-cell border="solid" text-align="center" font-weight="bold" number-columns-spanned="1">
...
</fo:table-cell>
</xsl:if>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<fo:table-cell border="solid" text-align="center" font-weight="bold" number-columns-spanned="1">
<fo:block>
<fo:leader/>
</fo:block>
</fo:table-cell>
</xsl:otherwise>
</xsl:choose>
Could be expressed as
<xsl:when test="$node = 'A' AND $node/child = 'B' AND not(contains($node/child,'C'))">
<fo:table-cell border="solid" text-align="center" font-weight="bold" number-columns-spanned="1">
...
</fo:table-cell>
</xsl:when>
<xsl:otherwise>
<fo:table-cell border="solid" text-align="center" font-weight="bold" number-columns-spanned="1">
<fo:block>
<fo:leader/>
</fo:block>
</fo:table-cell>
</xsl:otherwise>
</xsl:choose>
And in doing so, you will make sure that if any of those three logical conditions aren't met, that your otherwise block will be called and the leader should keep the cell from collapsing, rather than the when statement being called despite the fact that your logic conditions aren't technically satisfied, and winding up with an empty cell which will be collapsed by FOP by default. Hope this clears things up a bit for you.

Keep header with first line of next block

At the end of the page, I dont want to have the label of 'examClin' isolated. So if ever, the label arrives at the end of the page, I need ONE and no more than one line of examClin to be attached with the #label of examClin... Or both elements should go to next page.
Am i clear enough?
different elements... we arrive at the end of the page
<fo:table-row>
<fo:table-cell number-columns-spanned="5">
<fo:block space-before="2mm">
<xsl:value-of select="./examClin/#label"/>: </fo:inline>
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell number-columns-spanned="5" padding-top="2mm" padding-bottom="2mm"
padding-left="1mm" padding-right="1mm">
<fo:block white-space-collapse="false" font-style="italic" >
<xsl:value-of select="./examClin/child::text()"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
Put them into a single block (that means you must merge the two table rows into one) and use keep-together.
Thank you Aaron. But then I am afraid that if is a very long text, everything will keep together and not just the first line. As a result, it can leave a long white block on previous page.
I created the following template: the idea is to find what the first line will be: either the 75 first characters but if we find a return carriage before the 75 first characters, we will take the string before the first return carriage.
<xsl:template name="elem3">
<xsl:choose>
<xsl:when test="child::text()">
<xsl:variable name="test0" select="substring(child::text(),1,100000)"/>
<xsl:variable name="test1" select="substring(child::text(),0,75)"/>
<xsl:variable name="test2" select="substring(child::text(),75,100000)"/>
<xsl:variable name="test3" select="substring-before($test2,' ')"/>
<xsl:variable name="test4" select="concat($test1,$test3)"/>
<xsl:variable name="test5" select="substring-after($test2,' ')"/>
<xsl:variable name="test6" select="substring-before($test1,'
')"/>
<xsl:variable name="test7" select="substring-after($test0,'
')"/>
<fo:table-row>
<fo:table-cell number-columns-spanned="5">
<fo:block space-before="2mm">
<fo:inline font-weight="bold"><xsl:value-of select="#label"/>: </fo:inline>
</fo:block>
</fo:table-cell>
</fo:table-row>
<xsl:choose>
<xsl:when test="child::text()">
<fo:table-row keep-with-previous="always">
<fo:table-cell number-columns-spanned="6" padding-top="2mm" padding-left="1mm" padding-right="1mm">
<fo:block white-space-collapse="false" font-style="italic" >
<xsl:choose>
<xsl:when test="contains($test1,'
')"> <xsl:value-of select="$test6"/></xsl:when>
<xsl:otherwise><xsl:value-of select="$test4"/></xsl:otherwise>
</xsl:choose>
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell number-columns-spanned="5" padding-left="1mm" padding-right="1mm">
<fo:block white-space-collapse="false" font-style="italic" >
<xsl:choose>
<xsl:when test="contains($test1,'
')"><xsl:value-of select="$test7"/></xsl:when>
<xsl:otherwise> <xsl:value-of select="$test5"/></xsl:otherwise>
</xsl:choose>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:when>
</xsl:choose>
</xsl:when>
</xsl:choose>
</xsl:template>