Advertisement
Guest User

XSLT Converter Code

a guest
May 25th, 2018
2,479
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 1.08 KB | None | 0 0
  1. <?xml version="1.0"?>
  2. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  3.  
  4.     <xsl:output indent="yes" method="xml" encoding="utf-8" omit-xml-declaration="yes"/>
  5.  
  6.     <!-- Stylesheet to remove all namespaces from a document -->
  7.     <!-- NOTE: this will lead to attribute name clash, if an element contains
  8.        two attributes with same local name but different namespace prefix -->
  9.     <!-- Nodes that cannot have a namespace are copied as such -->
  10.  
  11.     <!-- template to copy elements -->
  12.     <xsl:template match="*">
  13.         <xsl:element name="{local-name()}">
  14.             <xsl:apply-templates select="@* | node()"/>
  15.         </xsl:element>
  16.     </xsl:template>
  17.  
  18.     <!-- template to copy attributes -->
  19.     <xsl:template match="@*">
  20.         <xsl:attribute name="{local-name()}">
  21.             <xsl:value-of select="."/>
  22.         </xsl:attribute>
  23.     </xsl:template>
  24.  
  25.     <!-- template to copy the rest of the nodes -->
  26.     <xsl:template match="comment() | text() | processing-instruction()">
  27.         <xsl:copy/>
  28.     </xsl:template>
  29.  
  30. </xsl:stylesheet>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement