ut-d.xsl 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!-- This file is part of the DITA Open Toolkit project hosted on
  3. Sourceforge.net. See the accompanying license.txt file for
  4. applicable licenses.-->
  5. <!-- (c) Copyright IBM Corp. 2004, 2005 All Rights Reserved. -->
  6. <xsl:stylesheet version="2.0"
  7. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  8. xmlns:ditamsg="http://dita-ot.sourceforge.net/ns/200704/ditamsg"
  9. exclude-result-prefixes="ditamsg">
  10. <!-- == User Technologies UNIQUE SUBSTRUCTURES == -->
  11. <!-- imagemap -->
  12. <xsl:template match="*[contains(@class,' ut-d/imagemap ')]" name="topic.ut-d.imagemap">
  13. <div>
  14. <xsl:call-template name="commonattributes"/>
  15. <xsl:call-template name="setidaname"/>
  16. <xsl:apply-templates select="*[contains(@class,' ditaot-d/ditaval-startprop ')]" mode="out-of-line"/>
  17. <!-- the image -->
  18. <img usemap="#{generate-id()}">
  19. <!-- Border attribute defaults to 0 -->
  20. <xsl:apply-templates select="." mode="imagemap-border-attribute"/>
  21. <!-- Process the 'normal' image attributes, using this special mode -->
  22. <xsl:apply-templates select="*[contains(@class,' topic/image ')]" mode="imagemap-image"/>
  23. </img>
  24. <xsl:value-of select="$newline"/>
  25. <map name="{generate-id(.)}" id="{generate-id(.)}">
  26. <xsl:for-each select="*[contains(@class,' ut-d/area ')]">
  27. <xsl:value-of select="$newline"/>
  28. <area>
  29. <!-- if no xref/@href - error -->
  30. <xsl:choose>
  31. <xsl:when test="*[contains(@class,' topic/xref ')]/@href">
  32. <!-- special call to have the XREF/@HREF processor do the work -->
  33. <xsl:apply-templates select="*[contains(@class, ' topic/xref ')]" mode="imagemap-xref"/>
  34. </xsl:when>
  35. <xsl:otherwise>
  36. <xsl:apply-templates select="." mode="ditamsg:area-element-without-href-target"/>
  37. </xsl:otherwise>
  38. </xsl:choose>
  39. <!-- create ALT text from XREF content-->
  40. <!-- if no XREF content, use @HREF, & put out a warning -->
  41. <xsl:choose>
  42. <xsl:when test="*[contains(@class, ' topic/xref ')]">
  43. <xsl:variable name="alttext"><xsl:apply-templates select="*[contains(@class, ' topic/xref ')]/node()[not(contains(@class, ' topic/desc '))]" mode="text-only"/></xsl:variable>
  44. <xsl:attribute name="alt"><xsl:value-of select="normalize-space($alttext)"/></xsl:attribute>
  45. <xsl:attribute name="title"><xsl:value-of select="normalize-space($alttext)"/></xsl:attribute>
  46. </xsl:when>
  47. <xsl:otherwise>
  48. <xsl:apply-templates select="." mode="ditamsg:area-element-without-linktext"/>
  49. </xsl:otherwise>
  50. </xsl:choose>
  51. <!-- if not valid shape (blank, rect, circle, poly); Warning, pass thru the value -->
  52. <xsl:variable name="shapeval"><xsl:value-of select="*[contains(@class,' ut-d/shape ')]"/></xsl:variable>
  53. <xsl:attribute name="shape">
  54. <xsl:value-of select="$shapeval"/>
  55. </xsl:attribute>
  56. <xsl:variable name="shapetest"><xsl:value-of select="concat('-',$shapeval,'-')"/></xsl:variable>
  57. <xsl:choose>
  58. <xsl:when test="contains('--rect-circle-poly-default-',$shapetest)"/>
  59. <xsl:otherwise>
  60. <xsl:apply-templates select="." mode="ditamsg:area-element-unknown-shape">
  61. <xsl:with-param name="shapeval" select="$shapeval"/>
  62. </xsl:apply-templates>
  63. </xsl:otherwise>
  64. </xsl:choose>
  65. <!-- if no coords & shape<>'default'; Warning, pass thru the value -->
  66. <xsl:variable name="coordval"><xsl:value-of select="*[contains(@class,' ut-d/coords ')]"/></xsl:variable>
  67. <xsl:choose>
  68. <xsl:when test="string-length($coordval)>0 and not($shapeval='default')">
  69. <xsl:attribute name="coords">
  70. <xsl:value-of select="$coordval"/>
  71. </xsl:attribute>
  72. </xsl:when>
  73. <xsl:otherwise>
  74. <xsl:apply-templates select="." mode="ditamsg:area-element-missing-coords"/>
  75. </xsl:otherwise>
  76. </xsl:choose>
  77. </area>
  78. </xsl:for-each>
  79. <xsl:value-of select="$newline"/>
  80. </map>
  81. <xsl:apply-templates select="*[contains(@class,' ditaot-d/ditaval-endprop ')]" mode="out-of-line"/>
  82. </div>
  83. </xsl:template>
  84. <!-- Set the border attribute on an imagemap; default is to always use border="0" -->
  85. <xsl:template match="*[contains(@class,' ut-d/imagemap ')]" mode="imagemap-border-attribute">
  86. <xsl:attribute name="border">0</xsl:attribute>
  87. </xsl:template>
  88. <!-- In the context of IMAGE - call these attribute processors -->
  89. <xsl:template match="*[contains(@class, ' topic/image ')]" mode="imagemap-image">
  90. <xsl:call-template name="commonattributes"/>
  91. <xsl:call-template name="setid"/>
  92. <xsl:apply-templates select="@href|@height|@width"/>
  93. <xsl:choose>
  94. <xsl:when test="*[contains(@class, ' topic/longdescref ')]">
  95. <xsl:apply-templates select="*[contains(@class, ' topic/longdescref ')]"/>
  96. </xsl:when>
  97. <xsl:otherwise>
  98. <xsl:apply-templates select="@longdescref"/>
  99. </xsl:otherwise>
  100. </xsl:choose>
  101. <xsl:choose>
  102. <xsl:when test="*[contains(@class,' topic/alt ')]">
  103. <xsl:attribute name="alt"><xsl:apply-templates select="*[contains(@class,' topic/alt ')]" mode="text-only"/></xsl:attribute>
  104. </xsl:when>
  105. <xsl:when test="@alt">
  106. <xsl:attribute name="alt"><xsl:value-of select="@alt"/></xsl:attribute>
  107. </xsl:when>
  108. </xsl:choose>
  109. </xsl:template>
  110. <!-- In the context of XREF - call it's HREF processor -->
  111. <xsl:template match="*[contains(@class, ' topic/xref ')]" mode="imagemap-xref">
  112. <xsl:attribute name="href"><xsl:call-template name="href"/></xsl:attribute>
  113. <xsl:if test="@scope='external' or @type='external' or ((@format='PDF' or @format='pdf') and not(@scope='local'))">
  114. <xsl:attribute name="target">_blank</xsl:attribute>
  115. </xsl:if>
  116. </xsl:template>
  117. <xsl:template match="*" mode="ditamsg:area-element-without-href-target">
  118. <xsl:call-template name="output-message">
  119. <xsl:with-param name="id" select="'DOTX044E'"/>
  120. </xsl:call-template>
  121. </xsl:template>
  122. <xsl:template match="*" mode="ditamsg:area-element-without-linktext">
  123. <xsl:call-template name="output-message">
  124. <xsl:with-param name="id" select="'DOTX045W'"/>
  125. </xsl:call-template>
  126. </xsl:template>
  127. <xsl:template match="*" mode="ditamsg:area-element-unknown-shape">
  128. <xsl:param name="shapeval" select="*[contains(@class,' ut-d/shape ')]/text()"/>
  129. <xsl:call-template name="output-message">
  130. <xsl:with-param name="id" select="'DOTX046W'"/>
  131. <xsl:with-param name="msgparams">%1=<xsl:value-of select="$shapeval"/></xsl:with-param>
  132. </xsl:call-template>
  133. </xsl:template>
  134. <xsl:template match="*" mode="ditamsg:area-element-missing-coords">
  135. <xsl:call-template name="output-message">
  136. <xsl:with-param name="id" select="'DOTX047W'"/>
  137. </xsl:call-template>
  138. </xsl:template>
  139. </xsl:stylesheet>