首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >(变量)文件过早结束

(变量)文件过早结束
EN

Stack Overflow用户
提问于 2019-07-15 17:28:41
回答 1查看 280关注 0票数 0

您好,我是XSLT新手,目前我尝试捕获两个变量,一个来自数据库,另一个是我自己的头部控制循环进程的NULL变量。我在这里没有找到任何帮助我解决这个问题的东西,所以这是我的代码:

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output media-type="text/xml" method="xml"></xsl:output>
    <xsl:template match="/">
        <root>
            <xsl:variable name="Counter" select="document('context:Counter')"></xsl:variable>
            <xsl:variable name="Counted">
                <xsl:value-of>0</xsl:value-of>
            </xsl:variable>
            <Counter>
                <xsl:value-of select="$Counter"></xsl:value-of>
            </Counter>
            <Counted>
                <xsl:value-of select="$Counted"></xsl:value-of>
            </Counted>
            <xsl:if test="not($Counted = $Counter)">
                <xsl:processing-instruction name="ConditionState">
                    2000
                </xsl:processing-instruction>
            </xsl:if>
            <xsl:if test="$Counted = $Counter">
                <xsl:processing-instruction name="ConditionState">
                    2001
                </xsl:processing-instruction>
            </xsl:if>
        </root>
    </xsl:template>
</xsl:stylesheet>

对于我的情况,我希望ConditionState在not equals上是2000,在equals上是2001。问题是他跳出了代码而我不知道为什么或者在哪里..。下面是我的错误:

代码语言:javascript
复制
net.sf.saxon.trans.XPathException: org.xml.sax.SAXParseException; Premature end of file.

我希望这里有人能帮我这个忙。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-07-17 18:39:16

要结束这篇文章,这里是我的解决方案:

我的代码:

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?><?xe.source ../Data/DBO_Output.xml#root?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output media-type="text/xml" method="xml"></xsl:output>
    <xsl:template match="/">
        <root>
            <xsl:variable name="Counter">
                <xsl:value-of select="./root"></xsl:value-of>
            </xsl:variable>
            <xsl:variable name="Counted" select="0">
            </xsl:variable>
            <Counter>
                <xsl:value-of select="$Counter"></xsl:value-of>
            </Counter>
            <Counted>
                <xsl:value-of select="$Counted"></xsl:value-of>
            </Counted>
            <xsl:if test="$Counter &gt;= $Counted">
                <xsl:processing-instruction name="ConditionState">
                    2000
                </xsl:processing-instruction>
            </xsl:if>
            <xsl:if test="not($Counter &gt;= $Counted) or $Counter = $Counted">
                <xsl:processing-instruction name="ConditionState">
                    2001
                </xsl:processing-instruction>
            </xsl:if>
        </root>
    </xsl:template>
</xsl:stylesheet>

我将数据库数据写入外部xml文件,然后读取该文件以获取转换所需的数据。

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

https://stackoverflow.com/questions/57036863

复制
相关文章

相似问题

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