【发布时间】:2019-10-02 15:17:13
【问题描述】:
当我在https://xslttest.appspot.com/ 上运行我的 XSLT 代码时,我遇到了这个 SaxonApiException。它返回此错误:
net.sf.saxon.s9api.SaxonApiException: 样式表编译时报错
我尝试了另一个在线测试器https://www.freeformatter.com/xsl-transformer.html,但我得到了同样的错误。 我试图拆分我的 XSLT 代码。第一部分是在工资中提取邮政编码的过程,第二部分是在地址中提取邮政编码的过程。 两者在分开时都有效,所以我认为我在“选择”元素中犯了一个错误,但找不到它。
这是我的 XSLT 代码...
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/EmployeeUDM_Response/Return/Employee">
<xsl:for-each select="./Wages/Wage">
<xsl:choose>
<xsl:when test="DissimelarZipCode != ''">
<xsl:value-of select="DissimelarZipCode" />
</xsl:when>
<otherwise>
<xsl:for-each select="./Addresses/Address" />
<!-- year -->
<xsl:sort select="substring(StartDate, 1, 4)" order="descending" data-type="number"/>
<!-- month -->
<xsl:sort select="substring(StartDate, 6, 2)" order="descending" data-type="number"/>
<!-- day -->
<xsl:sort select="substring(StartDate, 9, 2)" order="descending" data-type="number"/>
<xsl:if test="position() = 1">
<xsl:value-of select="./ZipCode" />
</xsl:if>
</otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
...还有我的 XML 文件
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl"?>
<EmployeeUDM_Response xmlns:ns0="http://ESB/Schemas/v2/EmployeeUDM">
<Header Type="Employee" Source="Biztalk ESB" />
<Return>
<Employee>
<Wages>
<Wage>
<StartDate>2019-04-22T00:00:00.0000000+02:00</StartDate>
<EndDate>2019-05-01T00:00:00.0000000+02:00</EndDate>
<DissimelarZipCode>5430 NU</DissimelarZipCode>
</Wage>
</Wages>
<Addresses>
<Address>
<StartDate>2014-01-01T00:00:00.0000000+02:00</StartDate>
<EndDate></EndDate>
<ZipCode>6099 EB</ZipCode>
</Address>
<Address>
<StartDate>2015-01-01T00:00:00.0000000+02:00</StartDate>
<EndDate></EndDate>
<ZipCode>5487 YR</ZipCode>
</Address>
</Addresses>
</Employee>
</Return>
</EmployeeUDM_Response>
我希望输出工资中的邮政编码(本例中为 5430 NU),或者,如果工资中的邮政编码为空,则输出地址中的邮政编码,开始日期最晚(本例中为 5487 年)
【问题讨论】:
标签: xslt-1.0 biztalk biztalk-2013