Posted to tcl by mjanssen at Sat Feb 09 16:32:02 GMT 2008view raw

  1. package require tdom
  2. set xml {
  3. <A> <B a="4">test</B><B>test2</B></A>
  4. }
  5. set xslt {
  6. <xsl:stylesheet version="1.0"
  7. xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  8. <xsl:template match="//B">
  9. <xsl:element name="MyB">
  10. <xsl:copy-of select="@*"/>
  11. <xsl:apply-templates/>
  12. </xsl:element>
  13. </xsl:template>
  14. <xsl:template match="*">
  15. <xsl:element name="{local-name()}">
  16. <xsl:copy-of select="@*"/>
  17. <xsl:apply-templates/>
  18. </xsl:element>
  19. </xsl:template>
  20. </xsl:stylesheet>
  21. }
  22.  
  23. dom parse $xml doc
  24. dom parse $xslt xsltdoc
  25.  
  26. [$doc xslt $xsltdoc] asXML