小编sav*_*ruk的帖子

从<xsl:for-each>内部调用模板

我有一个像下面的xsl:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:xs="http://www.w3.org/2001/XMLSchema"
                xmlns:nsm="http://192.137.81.132/deneme/sample.xsd"
               exclude-result-prefixes="nsm">

    <xsl:output method="text"/>
    <xsl:param name="fieldOf">address</xsl:param>
    <xsl:param name="inputId" select="concat($fieldOf,'/value')"/>

    <xsl:variable name="vXpathExpression" select="concat('global/fieldset/field/', $inputId)"/>
    <!-- these fields are from xml file-->

    <xsl:template match="/">
        <xsl:value-of select="$vXpathExpression"/>: <xsl:text/>
        <xsl:for-each select="document('sample.xsd')/xs:schema/xs:complexType[@name='fieldtype']/xs:choice/child::*">

        </xsl:for-each>

        <xsl:call-template name="getNodeValue">
            <xsl:with-param name="pExpression" select="$vXpathExpression" />
        </xsl:call-template>
    </xsl:template>

    <xsl:template name="getNodeValue">
        <xsl:param name="pExpression"/>
        <xsl:param name="pCurrentNode" select="."/>

        <xsl:choose>
            <xsl:when test="not(contains($pExpression, '/'))">
                <xsl:value-of select="$pCurrentNode/*[name()=$pExpression]"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:call-template name="getNodeValue">
                    <xsl:with-param name="pExpression" select="substring-after($pExpression, '/')"/>
                    <xsl:with-param name="pCurrentNode" select="$pCurrentNode/*[name()=substring-before($pExpression, '/')]"/>
                </xsl:call-template>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)

在这种情况下它有效.但是当我从for-each内部调用模板时,我无法运行它.它什么都没有,没有错误,没有价值.有没有办法解决这个问题?谢谢

编辑:您可能想知道是否每个都有效.确实如此.我可以在每个内部获得属性.

xml xslt xsd

4
推荐指数
1
解决办法
5466
查看次数

是否可以导入.pyo文件

好,

是否可以使用"os.pyo"或"os.pyc"而不是"os.py"导入"os"模块?

谢谢

python

2
推荐指数
1
解决办法
2327
查看次数

标签 统计

python ×1

xml ×1

xsd ×1

xslt ×1