简体   繁体   English

XSL-FO提取量

[英]XSL-FO Extracting amount

I have this inside XML: 我在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: 我想提取此金额9619.99以及FOP中的以下内容:

<xsl:value-of select="//Task/InvoiceList/Invoice/InvoiceAmount"/>

Is giving me this on my template 9619.99196.2 在我的模板9619.99196.2上给了我

Any idea how to extract this because I tried with substring-after and then I get NaN. 任何想法如何提取这一点,因为我与子-后尝试,然后我得到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? 您是否有196.2出现在XML的其他地方? //Task/InvoiceList/Invoice/InvoiceAmount is selecting every Task/InvoiceList/Invoice/InvoiceAmount in your document, and you are seeing the concatenation of their values. //Task/InvoiceList/Invoice/InvoiceAmount选择文档中的每个Task/InvoiceList/Invoice/InvoiceAmount ,您将看到它们的值的串联。

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. 没有看到更多XML,很难说更多,但是您应该将//Task/InvoiceList/Invoice/InvoiceAmount到XPath,以选择相对于当前data节点所需的InvoiceAmount 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. 就像将XPath更改为Task/InvoiceList/Invoice/InvoiceAmount一样简单,但是同样,如果看不到更多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. 您有与<xsl:variable name="timeBase" select="number(//TimeBase/@Val)"/>类似的东西<xsl:variable name="timeBase" select="number(//TimeBase/@Val)"/>如果文档中有多个TimeBase ,则可能会得到意外的结果。

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. 最后, exclude-result-prefixes="fo"不会做任何事情,因为生成的第一件事是fo命名空间中的一个元素。 It would be more useful to exclude the s and exsl prefixes. 排除sexsl前缀会更有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM