Re: [xsl] exclude-result-prefixes

Subject: Re: [xsl] exclude-result-prefixes
From: Mike Brown <mike@xxxxxxxx>
Date: Mon, 19 Aug 2002 10:34:50 -0600 (MDT)
Tevoi Andrea wrote:
> I have an xml that contains prefixes and namespaces.
> I would like to do an xsl that outputs the same xml but without all prefixes.

A variation on the identity transform described in the XSLT 1.0 spec, under
Copying, would do the trick. For the root node, comments and PIs you will copy
them through. For elements and attributes you'll create a new element or
attribute without copying the namespace nodes that are attached to them.

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

  <xsl:output method="xml" indent="no"/>

  <xsl:template match="/|comment()|processing-instruction()">
    <xsl:copy>
      <!-- go process children (applies to root node only) -->
      <xsl:apply-templates/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="*">
    <xsl:element name="{local-name()}">
      <!-- go process attributes and children -->
      <xsl:apply-templates select="@*|node()"/>
    </xsl:element>
  </xsl:template>

  <xsl:template match="@*">
    <xsl:attribute name="{local-name()}">
      <xsl:value-of select="."/>
    </xsl:attribute>
  </xsl:template>

</xsl:stylesheet>

   - Mike
____________________________________________________________________________
  mike j. brown                   |  xml/xslt: http://skew.org/xml/
  denver/boulder, colorado, usa   |  resume: http://skew.org/~mike/resume/

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread