【发布时间】:2021-09-21 15:06:00
【问题描述】:
XSLT 新手,我正在尝试使用下面的 xsl 文件,我想在该文件中选择基于同一 XSL 中另一个变量的特定代码。使用 Saxon-He-10.5 版本的 jar。有人可以帮我完成这个 xsl 转换。我想在 output.xml 中打印所选代码的标题
<xsl:transform version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xpath-default-namespace="http://test.org/test"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:lookup="http://lookup.data"
exclude-result-prefixes="fn lookup xsl xsi">
<xsl:variable name="key1" select=""status1""/>
<xsl:output omit-xml-declaration="yes" method="xml"/>
<xsl:variable name="header">
<sections>
<code key="status1" code="123" title="STATUS1"/>
<code key="status2" code="456" title="STATUS2"/>
</sections>
</xsl:variable>
<xsl:variable name="data" select="$header/sections/code[@key="status1"]" />
<xsl:variable name="data1" select="$header/sections/code[@key=$key1]" />
<xsl:template match="/">
:<xsl:value-of select="$header" />:
:<xsl:value-of select="$data" />:
:<xsl:value-of select="$data/@title" />:
:<xsl:value-of select="$data1/@title" />:
</xsl:template>
</xsl:transform>
使用命令提示符尝试转换如下:
java -cp saxon-he-10.5.jar net.sf.saxon.Transform Response.xml test.xsl > output.xml
【问题讨论】:
-
它不依赖于 XML 文件,所以没有提到相同的。所需的输出 xml 我想要它的简单标题文本。