XSLT Template and Inline XSLT

Inline XSLT Sample:
  
<xsl:variable name="unique-countries" select="//cities/city[not(country=preceding-sibling::city/country)]/country" />
<countries>
    <xsl:for-each select="$unique-countries">
         <country>
              <name>
                  <xsl:value-of select="current( )"/>
              </name>
              <xsl:for-each select="//city[country=current()]">
                  <city><xsl:value-of select="name" /></city>
              </xsl:for-each>
         </country>
    </xsl:for-each>
</countries>

XSLT Template:

<xsl:template name="fndTemplate">
      <xsl:variable name="unique_ref2" select="Loop[not(REF/ReferenceIden=preceding-sibling::Loop/REF/ReferenceIden)]" />
      <xsl:variable name="ref_count" select="count($unique_ref2)"/>
      <xsl:variable name="cust_ref">
       <xsl:choose>
        <xsl:when test="$ref_count='1'">
                <xsl:value-of select="$unique_ref2[1]/REF/ReferenceIden/text( )"/>
        </xsl:when>
        <xsl:otherwise>
                <xsl:value-of select="'ZZZ'"/>
        </xsl:otherwise>
       </xsl:choose>
      </xsl:variable>
     
      <xsl:element name="ns0:fnd">
          <xsl:element name="datatype:cust_ref">
               <xsl:value-of select="$cust_ref"/>
          </xsl:element>
      </xsl:element>
</xsl:template>


<xsl:template name="refremarkTemplate">
      <xsl:param name="para_po"/>
      <xsl:variable name="ref_CO" select="REF[ReferenceIdenQualifier='CO']/ReferenceIden"/>
      <xsl:variable name="ref_CR" select="REF[ReferenceIdenQualifier='CR']/ReferenceIden"/>
     
      <xsl:element name="remark">
          <xsl:value-of select="concat('OC# ',$ref_CO,' / PO# ',$ref_CR,' / BEG# ',$para_po)"/>
      </xsl:element>
</xsl:template>

今天开发中写的三个脚本。

你可能感兴趣的:(template)