Convert all node's attributes into child nodes

前端 未结 1 1858
逝去的感伤
逝去的感伤 2020-12-02 02:53

is there a way to convert all nodes\' attributes into child Nodes using XSLT 1.0 ? It must run flawlessly with PHP\'s xsltProcessor. The attributes

相关标签:
1条回答
  • 2020-12-02 03:25

    Tested on Oxygen/XML using Saxon6.5:

    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
      <xsl:output method="xml" indent="yes"/>
    
      <xsl:template match="node()">
        <xsl:copy>
          <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
      </xsl:template>
    
      <xsl:template match="@*">
        <xsl:element name="{name()}"><xsl:value-of select="."/></xsl:element>
      </xsl:template>
    
    </xsl:stylesheet>
    

    This is based on using an identity template for element nodes and a template that converts attributes to elements.

    0 讨论(0)
提交回复
热议问题