首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >XSL-FO提取量

XSL-FO提取量
EN

Stack Overflow用户
提问于 2017-09-27 15:37:14
回答 1查看 138关注 0票数 0

我在XML中有这样的代码:

代码语言:javascript
复制
 <InvoiceList>
   <Invoice>
     <InvoiceAmount WithVATBool="false" VATAmount="96.2" VATPercentage="1" WithVAT="9716.19">9619.99</InvoiceAmount>
   </Invoice>
 </InvoiceList>

我想提取这个数量的9619.99和下面的内部FOP:

代码语言:javascript
复制
<xsl:value-of select="//Task/InvoiceList/Invoice/InvoiceAmount"/>

在我的模板9619.99196.2上给了我这个

是否知道如何提取它,因为我尝试了substring-after,然后我得到了NaN。

谢谢!

正在使用的样式表:

代码语言:javascript
复制
    <?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>

我已经删除了所有不必要的表..

EN

回答 1

Stack Overflow用户

发布于 2017-09-27 16:35:50

您的XML中是否有196.2出现在其他地方?//Task/InvoiceList/Invoice/InvoiceAmount正在选择文档中的每个Task/InvoiceList/Invoice/InvoiceAmount,您可以看到它们的值连接在一起。

如果看不到更多的XML,就很难再说更多了,但是应该将//Task/InvoiceList/Invoice/InvoiceAmount简化为XPath,它将相对于当前的InvoiceAmount节点选择您想要的data。这可能和将XPath更改为Task/InvoiceList/Invoice/InvoiceAmount一样简单,但是,同样,如果没有看到更多的XML,我们就无法判断。

<xsl:variable name="timeBase" select="number(//TimeBase/@Val)"/>类似:如果文档中有多个TimeBase,您可能会得到意想不到的结果。

最后,exclude-result-prefixes="fo"不会做任何事情,因为您首先生成的是fo名称空间中的一个元素。排除sexsl前缀会更有用。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46442042

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档