我有一大堆的XML文档在这里笔者选择了代表一组这样的笛卡尔点:
<row index="0">
<col index="0">0</col>
<col index="1">0</col>
<col index="2">1</col>
<col index="3">1</col>
</row>
这等于点(0,0)和(1,1)。
我想改写这个作为
<set>
<point x="0" y="0"/>
<point x="1" y="1"/>
</set>
然而,我无法弄清楚如何在XSLT比硬编码为每个可能的情况下创建这个,其他 - 例如用于4点集:
<set>
<point>
<xsl:attribute name="x"><xsl:value-of select="col[@index = 0]"/></xsl:attribute>
<xsl:attribute name="y"><xsl:value-of select="col[@index = 1]"/></xsl:attribute>
</point>
<point>
<xsl:attribute name="x"><xsl:value-of select="col[@index = 1]"/></xsl:attribute>
<xsl:attribute name="y"><xsl:value-of select="col[@index = 2]"/></xsl:attribute>
</point>
...
必须有一个更好的方式来做到这一点? 总之,我想创建类似的元件<point x="..." y="..."/>
其中x和y是偶数/奇数索引col
元素。