removeLinksAttachments.xslt 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: AGS
  5. (C) Copyright IBM Corp. 2005, 2008
  6. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. -->
  8. <xsl:stylesheet version="1.0"
  9. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  10. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  11. exclude-result-prefixes="xsl xtsext">
  12. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  13. <xsl:template match="*">
  14. <xsl:apply-templates select="options" mode="copy"/>
  15. </xsl:template>
  16. <xsl:template match="*" mode="copy">
  17. <xsl:choose>
  18. <xsl:when test="local-name()='item' and attribute::*[local-name()='type']='bus:memoPartAgentObject' ">
  19. <!-- do we need to copy this - is there an attachment for it -->
  20. <xsl:variable name="attachmentSearchPath" select="./*[local-name()='searchPath']"/>
  21. <xsl:if test="/root/memo/attachment[./attachmentSearchPath=$attachmentSearchPath]/item/searchPath!='' ">
  22. <xsl:call-template name="copyNode"/>
  23. </xsl:if>
  24. </xsl:when>
  25. <xsl:when test="local-name()='item' and attribute::*[local-name()='type']='bus:objectLink' ">
  26. <!-- do we need to copy this - is there a link for it -->
  27. <xsl:variable name="linkSearchPath" select="./*[local-name()='searchPath']"/>
  28. <xsl:if test="/root/memo/link[./linkSearchPath=$linkSearchPath]/item/searchPath!='' ">
  29. <xsl:call-template name="copyNode"/>
  30. </xsl:if>
  31. </xsl:when>
  32. <xsl:otherwise>
  33. <xsl:call-template name="copyNode"/>
  34. </xsl:otherwise>
  35. </xsl:choose>
  36. </xsl:template>
  37. <xsl:template name="copyNode">
  38. <xsl:copy>
  39. <!-- copy all the attributes across -->
  40. <xsl:copy-of select="@*"/>
  41. <!-- decide if we need to add the selectAll element or not attribute -->
  42. <xsl:for-each select="node()">
  43. <xsl:apply-templates mode="copy" select="."/>
  44. </xsl:for-each>
  45. </xsl:copy>
  46. </xsl:template>
  47. <!-- -->
  48. <xsl:template match="text()" mode="copy">
  49. <xsl:param name="name"/>
  50. <xsl:value-of select="."/>
  51. </xsl:template>
  52. </xsl:stylesheet>