I have this inside XML:
<InvoiceList>
<Invoice>
<InvoiceAmount WithVATBool="false" VATAmount="96.2" VATPercentage="1" WithVAT="9716.19">9619.99</InvoiceAmount>
</Invoice>
</InvoiceList>
I want to extract this amount 9619.99 and the following inside FOP:
<xsl:value-of select="//Task/InvoiceList/Invoice/InvoiceAmount"/>
Is giving me this on my template 9619.99196.2
Any idea how to extract this because I tried with substring-after and then I get NaN.
Thanks!
Stylesheet in use:
<?xml version="1.0"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:s="http://www.stylusstudio.com/xquery"
xmlns:fo="http://www.w3.org/1999/XSL/Format" exclude-result-prefixes="fo" xmlns:exsl="http://exslt.org/common" extension-element-prefixes="exsl">
<xsl:output indent="yes" encoding="utf-8"/>
<xsl:variable name="brojac" select="0"/>
<xsl:variable name="timeBase" select="number(//TimeBase/@Val)"/>
<xsl:variable name="filefolder" select="/data/imagepath" />
<xsl:template match="/data">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master
master-name="default-page"
page-height="279.4mm"
page-width="215.9mm"
margin-left="1cm"
margin-right="1cm"
margin-top="0.5cm"
margin-bottom="0.5cm">
<fo:region-body margin-bottom="2cm"/>
<fo:region-after extent="1cm"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="default-page">
<fo:flow flow-name="xsl-region-body">
<xsl:apply-templates select="/data" mode="case_data"/>
<fo:block>
<fo:table
space-after="0.25cm"
table-layout="fixed"
width="100%"
color="black"
font-family="Arial"
font-size="10px"
text-align="center"
height="14px">
<fo:table-column column-width="100%"/>
<fo:table-body>
<fo:table-row height="14px">
<fo:table-cell
font-family="Arial"
font-size="10px"
text-align="center"
color="black"
height="14px">
<fo:block>
Član 1.
</fo:block>
<fo:block text-align="justify">
<xsl:value-of select="//Task/InvoiceList/Invoice/InvoiceAmount" />
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
</xsl:stylesheet>
I've removed all unecessary tables..
Do you have 196.2
appearing elsewhere in your XML? //Task/InvoiceList/Invoice/InvoiceAmount
is selecting every Task/InvoiceList/Invoice/InvoiceAmount
in your document, and you are seeing the concatenation of their values.
Without seeing more of your XML, it's hard to say much more, but you should reduce //Task/InvoiceList/Invoice/InvoiceAmount
to the XPath that will select the InvoiceAmount
that you want relative to the current data
node. It might be as simple as changing the XPath to Task/InvoiceList/Invoice/InvoiceAmount
but, again, we can't tell without seeing more of your XML.
You have something similar with <xsl:variable name="timeBase" select="number(//TimeBase/@Val)"/>
: you might get unexpected results if there is more than one TimeBase
in the document.
Lastly, exclude-result-prefixes="fo"
isn't going to do anything because the first thing that you generate is an element in the fo
namespace. It would be more useful to exclude the s
and exsl
prefixes.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.