SplitByValue函数使用XSLT映射

时间:2011-09-12 07:47:59

标签: xslt mapping

如何使用XSLT进行splitbyvalue函数?

2 个答案:

答案 0 :(得分:1)

<xsl:template match="/">
<ACCOUNT>
<xsl:for-each select="descendant::RefCode[text() = 'WBS']">
  <item>
    <BItemNum><xsl:value-of select="ancestor::ItemDetail/descendant::BLineItemNum"/></BItemNum>
  </item>
</xsl:for-each>
</ACCOUNT>
</xsl:template> 

答案 1 :(得分:1)

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" indent="yes"/>

    <xsl:template match="/">
        <ACCOUNT>
            <xsl:apply-templates select="//RefCoded/RefCode[. = 'WBS']"/>
        </ACCOUNT>
    </xsl:template>

    <xsl:template match="RefCode">
        <item>
            <BItemNum>
                <xsl:value-of select="../../../../LineItemNum/BLineItemNum"/>
            </BItemNum>
        </item>
    </xsl:template>
</xsl:stylesheet>

输出:

<ACCOUNT>
  <item>
    <BItemNum>00001</BItemNum>
  </item>
  <item>
    <BItemNum>00001</BItemNum>
  </item>
  <item>
    <BItemNum>00002</BItemNum>
  </item>
  <item>
    <BItemNum>00002</BItemNum>
  </item>
</ACCOUNT>