tags:

views:

172

answers:

3

I have a XML document and I want to rename some elements via XSLT:

<Assert @some attributes here>
  <conent>
    <And>
      <formula>
        <Atom>
          <opr>
...

For example I want to rename <opr> to <op>. I have the following XSLT:

  <xsl:template match="@* | node()">
        <xsl:copy>
            <xsl:apply-templates select="@* | node()"/>
        </xsl:copy>
  </xsl:template>

  <xsl:template match="opr">
    <op>
      <xsl:apply-templates select="@*|node()"/>
    </op>
  </xsl:template>

When I debug the XSLT it just doesnt go inside the "opr" template, it gets matched by the first template. The generatd output is the same as the input. Can any one help me on this?

Thanks

A: 
<xsl:template name="YourNameHere">
        <xsl:copy>
            <xsl:apply-templates select="@* | node()"/>
        </xsl:copy>
  </xsl:template>

  <xsl:template match="opr">
    <op>
      <xsl:call-template name="YourNameHere"/>
    </op>
  </xsl:template>

You'll probably still need something like <xsl:template match="/" /> to get it going.

No Refunds No Returns
No it still doesnt seem to work
A: 

Does this work?

<xsl:template match="*">
     <xsl:copy>
          <xsl:copy-of select="@*" />
          <xsl:apply-templates select="*" />
     </xsl:copy>
</xsl:template>
<xsl:template match="opr">
     <op>
          <xsl:copy-of select="@*" />
          <xsl:apply-templates select="*" />
     </op>
</xsl:template>
Krab
A: 

Do your XML and/or XSLT files declare a default namespace? xmlns="..."?

Christopher Sahnwaldt