【发布时间】:2017-02-17 10:18:17
【问题描述】:
您好,我有一个样式表,它采用来自ant xslt task 的参数。但是参数中充满了转义序列,例如<tag-name>等...
这是参数$fileset-xml: link 的原始表示,它是这个的直接输出:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:saxon="http://saxon.sf.net/" version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:param name="fileset-xml"/>
<!-- -->
<!-- -->
<xsl:template match="/theRoot">
<root>
<xsl:value-of select="$fileset-xml"/>
</root>
</xsl:template>
<!-- -->
<!-- -->
</xsl:stylesheet>
我的意图是使用该参数生成 xml 格式的输出,但函数 saxon:parse($fileset-xml) 不喜欢这种格式的参数。我想如果我们用它们的渲染值替换转义字符,我会得到一个有效的 xml 文件,但是怎么做呢?
处理器是saxonb9-1-0-8j
EDITION_1
作为@MartinHonnen 评论的附录:
处理器:
<classpath location="../../infrastructure/SaxonEE9-7-0-11J/saxon9ee.jar:/net.sf.saxon.TransformerFactoryImpl"/>
XSLT:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0">
<xsl:output method="xml" indent="yes"/>
<xsl:param name="fileset-xml"/>
<xsl:variable name="file-set-xml" select="parse-xml(parse-xml-fragment('<a/>'))"/>
<!-- -->
<!-- -->
<xsl:template match="/theRoot">
<root>
<xsl:copy-of select="$file-set-xml"/>
</root>
</xsl:template>
<!-- -->
<!-- -->
</xsl:stylesheet>
还有错误:
[xslt] : Fatal Error! Error checking type of the expression 'funcall(parse-
xml-fragment, [literal-expr(<a/>)])'. Cause: Error checking type of the expressi
on 'funcall(parse-xml-fragment, [literal-expr(<a/>)])'.
【问题讨论】:
-
那么
saxon:parse($fileset-xml)到底是哪条错误消息? -
该错误消息并非来自撒克逊人。上一个问题在这里报告了一个非常相似的错误消息:stackoverflow.com/questions/15812382/… 问题在于用户实际上正在运行 Xalan。