Xml XSL中的动态父标题?

Xml XSL中的动态父标题?,xml,xslt,Xml,Xslt,我有一组几个.XML文件,这些文件将使用XSLTproc处理成一个.CSV文件 我已经设法找到了如何构建动态子标题,但是我可以对父标题也这样做吗 以下是到目前为止我得到的信息: XML: XSL: 如果父标题ArrayOfVW\u Retailer\u Consumer\u Meter\u Details\u地址更改为其他内容,我需要在XSL中更改什么才能使其工作? 谢谢大家! 这个怎么样: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999

我有一组几个.XML文件,这些文件将使用XSLTproc处理成一个.CSV文件

我已经设法找到了如何构建动态子标题,但是我可以对父标题也这样做吗

以下是到目前为止我得到的信息:

XML:

XSL:

如果父标题ArrayOfVW\u Retailer\u Consumer\u Meter\u Details\u地址更改为其他内容,我需要在XSL中更改什么才能使其工作? 谢谢大家!

这个怎么样:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:output method="text" encoding="UTF-8" />

  <xsl:variable name="q" select="'&quot;'" />
  <xsl:variable name="d" select="','" />

  <xsl:template match="/*">
    <xsl:for-each select="*[1]">
      <xsl:apply-templates select="*" mode="header" />
      <xsl:text>&#xA;</xsl:text>
    </xsl:for-each>
    <xsl:for-each select="*">
      <xsl:apply-templates select="*" mode="data" />
      <xsl:text>&#xA;</xsl:text>
    </xsl:for-each>
  </xsl:template>

  <xsl:template match="*" mode="header">
    <xsl:if test="position() &gt; 1"><xsl:value-of select="$d" /></xsl:if>
    <xsl:value-of select="concat($q, name(), $q)" />
  </xsl:template>

  <xsl:template match="*" mode="data">
    <xsl:if test="position() &gt; 1"><xsl:value-of select="$d" /></xsl:if>
    <xsl:value-of select="concat($q, ., $q)" />
  </xsl:template>
</xsl:stylesheet>

这给了我编译错误:files1.xsl第24行元素if xsl:if:无法编译测试表达式“position gt 1”,这是一个输入错误。固定的
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

  <xsl:template match="/*">
    <xsl:for-each select="*[1]/*">
      <xsl:text>"</xsl:text>
      <xsl:value-of select="name()" />
      <xsl:text>"</xsl:text>
      <xsl:if test="position() != last()">,</xsl:if>
      <xsl:if test="position() = last()">
        <xsl:text> </xsl:text>
      </xsl:if>
    </xsl:for-each>
    <xsl:apply-templates />
  </xsl:template>

  <xsl:template match="/impex">
    <xsl:apply-templates select="VW_Retailer_Consumer_Meter_Details_Addresses[1]" mode="header" />
    <xsl:apply-templates select="VW_Retailer_Consumer_Meter_Details_Addresses" />
  </xsl:template>

  <xsl:template match="*" mode="header">
    <xsl:text>"</xsl:text>
    <xsl:value-of select="$headerVal" />
    <xsl:text>"</xsl:text>
  </xsl:template>

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

  <xsl:template match="*">
    <xsl:text>"</xsl:text>
    <xsl:value-of select="." />
    <xsl:text>"</xsl:text>
    <xsl:choose>
      <xsl:when test="position()=last()">
        <xsl:text> </xsl:text>
      </xsl:when>
      <xsl:otherwise>,</xsl:otherwise>
    </xsl:choose>
  </xsl:template>
</xsl:stylesheet>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:output method="text" encoding="UTF-8" />

  <xsl:variable name="q" select="'&quot;'" />
  <xsl:variable name="d" select="','" />

  <xsl:template match="/*">
    <xsl:for-each select="*[1]">
      <xsl:apply-templates select="*" mode="header" />
      <xsl:text>&#xA;</xsl:text>
    </xsl:for-each>
    <xsl:for-each select="*">
      <xsl:apply-templates select="*" mode="data" />
      <xsl:text>&#xA;</xsl:text>
    </xsl:for-each>
  </xsl:template>

  <xsl:template match="*" mode="header">
    <xsl:if test="position() &gt; 1"><xsl:value-of select="$d" /></xsl:if>
    <xsl:value-of select="concat($q, name(), $q)" />
  </xsl:template>

  <xsl:template match="*" mode="data">
    <xsl:if test="position() &gt; 1"><xsl:value-of select="$d" /></xsl:if>
    <xsl:value-of select="concat($q, ., $q)" />
  </xsl:template>
</xsl:stylesheet>