0
不重复我有一个包含表单的一些节点传入的XML文档:整合数据和XSLT
<userOptions>
<userOption>
<type>A</type>
<plan>
<frequency>MONTHLY</frequency>
</plan>
<method>
<methodType>X1</methodType>
</method>
</userOption>
<userOption>
<type>B</type>
<plan>
<frequency>QUARTERLY</frequency>
</plan>
<method>
<methodType>X2</methodType>
</method>
</userOption>
<userOption>
<type>A</type>
<plan>
<frequency>3MONTH</frequency>
</plan>
<method>
<methodType>X1-B</methodType>
</method>
</userOption>
</userOptions>
我需要巩固和改造到的东西,看起来像这样的:
<userOptions>
<userOption>
<type>A</type>
<plan>
<frequency>3MONTH</frequency>
<methodType>X1-B</methodType>
</plan>
<plan>
<frequency>MONTHLY</frequency>
<methodType>X1</methodType>
</plan>
<userOption>
<userOption>
<type>B</type>
<plan>
<frequency>QUARTERLY</frequency>
<methodType>X2</methodType>
</plan>
<userOption>
</userOptions>
我目前的转型看起来是这样的:
<userOptions>
<xsl:for-each select="//userOptions">
<userOption>
<type>
<xsl:value-of select="type" />
</type>
<xsl:variable name="currentType" select="type"/>
<xsl:message><xsl:value-of select="$currentType"/></xsl:message>
<xsl:variable name="currentMethod" select="method/methodType"/>
<xsl:message><xsl:value-of select="$currentMethod/></xsl:message>
<plan>
<frequency>
<xsl:value-of select="plan/frequency" />
</frequency>
<method>
<xsl:value-of select="method/methodType" />
</method>
</plan>
<xsl:for-each select="../userOptions[type=$currentType and method/methodType!=$currentMethod]">
<plan>
<frequency>
<xsl:value-of select="plan/frequency" />
</frequency>
<method>
<xsl:value-of select="method/methodType" />
</method>
</plan>
</xsl:for-each>
</userOption>
</xsl:for-each>
</userOptions>
问题是我得到的副本,如:
<userOption>
<type>A</type>
<plan>
<frequency>3MONTH</frequency>
<methodType>X1-B</methodType>
</plan>
<plan>
<frequency>MONTHLY</frequency>
<methodType>X1</methodType>
</plan>
<userOption>
<userOption>
<type>A</type>
<plan>
<frequency>MONTHLY</frequency>
<methodType>X1</methodType>
</plan>
<plan>
<frequency>3MONTH</frequency>
<methodType>X1-B</methodType>
</plan>
<userOption>
我不知道如何巩固记录匹配type
和不同还能避免重复。
我没有可用的'xsl:for-each-group',所以我我会试试这个。 – FrustratedWithFormsDesigner 2012-08-13 15:42:49