XSLT为每个对象访问外部的不同标记

XSLT为每个对象访问外部的不同标记,xslt,Xslt,我想根据for循环中的条件输出不同的标记(活动)值。但这种方法无法实现。有什么建议吗 数据: Xslt: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL /Transform"> <xsl:output method="xml" indent="yes" /> <xsl:template match="ss"> <Patie

我想根据for循环中的条件输出不同的标记(活动)值。但这种方法无法实现。有什么建议吗

数据:


Xslt:

<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL /Transform">
    <xsl:output method="xml" indent="yes" />
    <xsl:template match="ss">
        <Patient
            xmlns="http://hl7.org/fhir">
            <identifier>
                <xsl:for-each select="identifier/system/value">
                    <xsl:variable name="aa">
                        <xsl:if test="@value='10'">
                            <xsl:value-of select="active/@value" />
                        </xsl:if>
                    </xsl:variable>
                    <gender value="{$aa}"/>
                </xsl:for-each>
            </identifier>
        </Patient>
    </xsl:template>
</xsl:stylesheet>

输出: 我期望从上述代码中得到的输出

<?xml version="1.0"?>
<Patient
    xmlns="http://hl7.org/fhir">
    <identifier>
        <gender value="123"/>
        <gender value=""/>
        <gender value=""/>
    </identifier>
</Patient>

要使其相对于当前
节点,您需要的语法如下

<xsl:value-of select="../../../active/@value" />
<xsl:value-of select="../../../active/@value" />
<xsl:value-of select="/ss/active/@value" />
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">  
<xsl:output method="xml" indent="yes" />
<xsl:template match="ss">
  <xsl:variable name="active" select="active/@value" />
  <Patient xmlns="http://hl7.org/fhir">
    <identifier>
      <xsl:for-each select="identifier/system/value">
        <xsl:variable name="aa">
          <xsl:if test="@value='10'">
            <xsl:value-of select="$active" />
          </xsl:if>
        </xsl:variable>    
        <gender value="{$aa}"/>         
      </xsl:for-each>        
    </identifier>
  </Patient>
</xsl:template>
</xsl:stylesheet>