2013-11-02 5 views
0

У меня есть XML, как это:Как включить XInclude для XSLT в webstorm?

<?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 не выполняет actualy включать. Как включить его? Я запускаю его в Windows 8, последней версии java.

ответ

0

Используйте реализацию XSLT из XInclude:

<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> 

Список литературы

Смежные вопросы