View Single Post
  #3 (permalink)  
Old April 4th, 2007, 02:37 PM
mhkay's Avatar
mhkay mhkay is offline
Wrox Author
Points: 18,481, Level: 59
Points: 18,481, Level: 59 Points: 18,481, Level: 59 Points: 18,481, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,960
Thanks: 0
Thanked 292 Times in 287 Posts
Default

<xsl:template match="*"> -- * means for all the elements
  <xsl:element name="{local-name()}" namespace="preferred-uri"> -- means element name is always local-name
    <xsl:copy-of select="@*"/> -- means what ?
    <xsl:apply-templates/> -- means what ?
  </xsl:element>
</xsl:template>

If you don't understand this code then you probably ought to take a couple of days off coding and read a good XSLT book (I can recommend one...).

It's a variant on a very commonly used template rule (known as the "identity template") which copies elements unchanged from the input to the output - typically it's supplemented by other template rules that make small changes to specific elements. In this case the xsl:element instruction creates a new element with the same local name as the original but a different namespace URI. The copy-of instruction copies all the attributes unchanged, and the apply-templates call says "process the children" (if you don't know this one then you REALLY should be reading rather than coding!)

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote