【发布时间】:2016-03-04 13:23:21
【问题描述】:
我是 XSLT 的新手。我正在尝试从 XSLT 生成文本文件。当我使用 XALAN 解析器对输入 XML 运行 XSLT 时,生成的文本文件没有输出。
这是 XSLT
<xsl:stylesheet version="2.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:output method="text" />
<xsl:template match="/">
<xsl:variable name="cities" as="xs:string*">
<xsl:sequence select="addressbook/address/city" />
<xsl:sequence select="'Virginia'" />
</xsl:variable>
<xsl:text>These are some of the cities:

</xsl:text>
<xsl:value-of select="$cities" separator="
" />
</xsl:template>
这是 XML
<?xml version="1.0" ?>
<addressbook>
<address>
<name>Peter Thompson</name>
<stree>3456 South Blvd.</stree>
<city>Chicago</city>
<state>IL</state>
<zip-code>34678</zip-code>
</address>
<address>
<name>Jason Thompson</name>
<stree>3456 Fort Main</stree>
<city>South Carolina</city>
<state>NC</state>
<zip-code>67878</zip-code>
</address>
我尝试这样编译:
java -classpath ~/Downloads/xalan/xalan.jar org.apache.xalan.xslt.Process -in cities.xml -xsl cities.xsl -out citiesop.txt
cities.txt 文件仅由输出生成:
这些是一些城市。
请帮助我了解这里出了什么问题。
【问题讨论】: