markupTemplates.xsl 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. BI and PM: qs
  5. (C) Copyright IBM Corp. 2001, 2017
  6. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. -->
  8. <!--
  9. Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
  10. Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
  11. -->
  12. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  13. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt">
  14. <xsl:output method="xml" encoding="UTF-8" indent="no"/>
  15. <!-- generate text for simple element -->
  16. <xsl:template match="*" mode="markup">
  17. <xsl:text>&lt;</xsl:text>
  18. <xsl:value-of select="name()"/>
  19. <xsl:apply-templates select="@*" mode="markup"/>
  20. <xsl:text>/&gt;</xsl:text>
  21. </xsl:template>
  22. <!-- generate text for an element with children or text -->
  23. <xsl:template match="*[* | text()]" mode="markup">
  24. <xsl:text>&lt;</xsl:text>
  25. <xsl:value-of select="name()"/>
  26. <xsl:apply-templates select="@*" mode="markup"/>
  27. <xsl:text>&gt;</xsl:text>
  28. <xsl:apply-templates select="* | text()" mode="markup"/>
  29. <xsl:text>&lt;/</xsl:text>
  30. <xsl:value-of select="name()"/>
  31. <xsl:text>&gt;</xsl:text>
  32. </xsl:template>
  33. <!-- generate text for an attribute -->
  34. <xsl:template match="@*" mode="markup">
  35. <xsl:text>&#32;</xsl:text>
  36. <xsl:value-of select="name()"/>
  37. <xsl:text>="</xsl:text>
  38. <xsl:value-of select="xtsext:xmlencode( string( . ) )"/>
  39. <xsl:text>"</xsl:text>
  40. </xsl:template>
  41. <!-- generate text -->
  42. <xsl:template match="text()" mode="markup">
  43. <xsl:value-of select="xtsext:xmlencode( string( . ) )"/>
  44. </xsl:template>
  45. </xsl:stylesheet>