(变量)文件过早结束
(Variables) Premature end of file
您好,我是 XSLT 的新手,目前我尝试捕获两个变量,一个来自数据库,另一个是我自己的 Head-controlled 循环过程的 NULL 变量。我在这里没有找到任何可以帮助我解决这个问题的东西所以这是我的代码:
<?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
不等于 2000,等于 2001。问题是他跳出守则,我不知道为什么或在哪里......
这是我的错误:
net.sf.saxon.trans.XPathException: org.xml.sax.SAXParseException; Premature end of file.
我希望这里有人可以帮助我。
要关闭此 post,这是我的解决方案:
我的代码:
<?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 >= $Counted">
<xsl:processing-instruction name="ConditionState">
2000
</xsl:processing-instruction>
</xsl:if>
<xsl:if test="not($Counter >= $Counted) or $Counter = $Counted">
<xsl:processing-instruction name="ConditionState">
2001
</xsl:processing-instruction>
</xsl:if>
</root>
</xsl:template>
</xsl:stylesheet>
我将数据库数据写入外部 xml 文件,然后读取该文件以获取用于转换的数据。
您好,我是 XSLT 的新手,目前我尝试捕获两个变量,一个来自数据库,另一个是我自己的 Head-controlled 循环过程的 NULL 变量。我在这里没有找到任何可以帮助我解决这个问题的东西所以这是我的代码:
<?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
不等于 2000,等于 2001。问题是他跳出守则,我不知道为什么或在哪里......
这是我的错误:
net.sf.saxon.trans.XPathException: org.xml.sax.SAXParseException; Premature end of file.
我希望这里有人可以帮助我。
要关闭此 post,这是我的解决方案:
我的代码:
<?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 >= $Counted">
<xsl:processing-instruction name="ConditionState">
2000
</xsl:processing-instruction>
</xsl:if>
<xsl:if test="not($Counter >= $Counted) or $Counter = $Counted">
<xsl:processing-instruction name="ConditionState">
2001
</xsl:processing-instruction>
</xsl:if>
</root>
</xsl:template>
</xsl:stylesheet>
我将数据库数据写入外部 xml 文件,然后读取该文件以获取用于转换的数据。