Excel生成XML的XSLT处理

Excel生成XML的XSLT处理,xml,xslt,Xml,Xslt,我尝试从excel中生成的XML格式: ... <Column255>1</Column255> <Column256>1</Column256> </Row> <Row> <Column1>1</Column1> <Column2>1</Column2> <Column3>1</Column3> ... 。。。

我尝试从excel中生成的XML格式:

...
    <Column255>1</Column255>
    <Column256>1</Column256>
</Row>
<Row>
    <Column1>1</Column1>
    <Column2>1</Column2>
    <Column3>1</Column3>
...
。。。
1.
1.
1.
1.
1.
...
(这种情况持续了很长时间)

最终将256x256网格映射为以下格式:

<map_point>    
   <x>0</x>
   <y>0</x>
   <value>1</value>
</map_point>

<map_point>    
   <x>0</x>
   <y>1</x>
   <value>1</value>
</map_point>

0
0
1.
0
1.
1.
我该怎么做


我的粗略计划是对每一行的每一个使用
,并将其写入
x
坐标,然后我被列标记都不同的问题难住了,所以我现在不能对每一行使用
来获得我的
y
坐标

我将使用模板并在参数中向下传递行号。大概是这样的:

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

  <xsl:template match="/">
    <map>
      <xsl:apply-templates select="*/Row" />
    </map>
  </xsl:template>

  <xsl:template match="Row">
    <xsl:apply-templates select="*[starts-with(local-name(), 'Column')]">
      <!-- position() will be 1 for the first row, 2 for the second ... -->
      <xsl:with-param name="rowNumber" select="position() - 1" />
    </xsl:apply-templates>
  </xsl:template>

  <xsl:template match="*">
    <xsl:param name="rowNumber" />
    <map_point>
      <x><xsl:value-of select="$rowNumber" /></x>
      <!-- for the column number, strip off the leading "Column" from the
           element name, convert the rest to a number and subtract 1 -->
      <y><xsl:value-of select="substring(local-name(), 7) - 1" /></y>
      <value><xsl:value-of select="." /></value>
    </map_point>
  </xsl:template>

</xsl:stylesheet>

好的,太好了。我的程序的下一步是编写函数,根据每个地图点的值来描述我的地图。这样做的最佳方法是什么?这是否能够集成到这个具有不同输出的XSLT文档中,或者我从这个XSLT得到的结果是否需要通过一个新的程序来实现?在上下文中,我们计划用每个点的向量场来扩展这个概念,以描述基于重力的粒子在空间中的运动。代表行星/恒星等的值。