我有这样的xml:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<?xml-stylesheet type="text/xsl" href="index.xsl"?>
<content>
<include xmlns="http://www.w3.org/2001/XInclude" href="static.xml" parse="xml"/>
<user authorizeds="false"/>
</content>
但是webstorm XSLTRunner不执行实际包含。如何启用它? 我在Windows 8上运行它,最新的java版本。
答案 0 :(得分:1)
使用XInclude的XSLT实现:
<content xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="example.xml"/>
<user authorizeds="false"/>
</content>
将模板添加到现有样式表中:
<!-- ==============================================================
XInclude implementation
Implements XInclude by processing the entire doc
to produce a single result tree with all the includes resolved
and then applies the normal template processing to that document.
==============================================================-->
<xsl:template match="/">
<xsl:choose>
<xsl:when test="//xi:include">
<xsl:variable name="resolved-doc">
<xsl:apply-templates mode="xinclude"/>
</xsl:variable>
<xsl:apply-templates select="$resolved-doc" mode="normal"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="/" mode="normal">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="node()" mode="xinclude">
<xsl:copy
><xsl:call-template name="xinclude-copy-attributes"
/><xsl:apply-templates select="node()" mode="xinclude"
/></xsl:copy>
</xsl:template>
<xsl:template match="xi:include" mode="xinclude">
<xsl:variable name="xpath" select="@href"/>
<xsl:choose>
<xsl:when test="$xpath != ''">
<xsl:message>Including <xsl:value-of
select="$xpath"/></xsl:message>
<xsl:apply-templates
select="xptrf:resolve-xpointer-url(.)" mode="xinclude"/>
</xsl:when>
<xsl:otherwise>
<xsl:message>Xinclude: Failed to get a value for the href= attribute
of xi:include element.</xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
<强>参考强>