1
我想优化一个xsl,因为修改我的数据需要很长的时间。元素内容的XSTL过滤器
我sourcedata(我不能修改)的样子:
<catalog>
<product>
<prodid>12345</prodid>
.....
</proudct>
<product_group_map>
<prodid>12345</prodid>
<groupid>2435</groupid>
</product_group_map>
</catalog>
我要与产品的地方得到这些组id。我做了什么到现在看起来是这样的:
<xsl:variable name="id"><xsl:value-of select="prodid"/></xsl:variable>
<xsl:variable name="grId">
<xsl:for-each select="../product_group_map">
<xsl:if test="prodid = $id">
<xsl:value-of select="groupid"/>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<!-- the actual print of the values -->
<xsl:value-of select="concat($id, $separator, $grId)"/>
所以进程中运行o^2。对于700万件不合格的产品。有其他方法可以匹配所需的groupId吗? 我觉得是这样的:如果XML是这样的
<catalog>
<product>
<prodid>12345</prodid>
.....
</proudct>
<product_group_map prodId="12345">
<groupid>2435</groupid>
</product_group_map>
</catalog>
我可以使用选择这样的:
<!--allready in product with the path -->
<xsl:variable name="id"><xsl:value-of select="prodid"/></xsl:variable>
<xsl:variable name="groupid"><xsl:value-of select="../product_group_map[@prodid = $prodId]/groupid"/></xsl:variable>