dita_enter_to_ph.xsl 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns:xs="http://www.w3.org/2001/XMLSchema"
  4. xmlns:system_cache__appinfo="http://biuro.biall-net.pl/xmlschema_procesy5/default_db_xml_cache/appinfo.xsd"
  5. exclude-result-prefixes="xs"
  6. version="2.0">
  7. <xsl:template match="*" mode="PROCES_TO_DITA_STRIP_HTML"/>
  8. <xsl:template match="text()" mode="PROCES_TO_DITA_STRIP_HTML">
  9. <xsl:param name="limit"/>
  10. <xsl:variable name="parse_content">
  11. <xsl:choose>
  12. <xsl:when test=".='&#xD;'"/>
  13. <xsl:otherwise><xsl:call-template name="system_cache__appinfo:escaped_html_to_xml" exclude-result-prefixes="#all" extension-element-prefixes="">
  14. <xsl:with-param name="html" select="."/>
  15. </xsl:call-template></xsl:otherwise>
  16. </xsl:choose>
  17. </xsl:variable>
  18. <xsl:apply-templates select="$parse_content" mode="CONVERT_HTML_TO_DITA_CONTENT"/>
  19. </xsl:template>
  20. <xsl:template match="text()" mode="PROCES_TO_DITA_STRIP_HTML_TITLE">
  21. <xsl:param name="limit"/>
  22. <xsl:variable name="parse_title">
  23. <xsl:choose>
  24. <xsl:when test=".='&#xD;'"/>
  25. <xsl:otherwise><xsl:call-template name="system_cache__appinfo:escaped_html_to_xml" exclude-result-prefixes="#all" extension-element-prefixes="">
  26. <xsl:with-param name="html" select="."/>
  27. </xsl:call-template></xsl:otherwise>
  28. </xsl:choose>
  29. </xsl:variable>
  30. <xsl:copy-of select="$parse_title"/>
  31. </xsl:template>
  32. <xsl:template match="*" mode="enter_to_ph">
  33. <xsl:param name="count"/>
  34. <xsl:param name="element"/>
  35. <xsl:variable name="current" select="."/>
  36. <xsl:variable name="surround_with">
  37. <xsl:choose>
  38. <xsl:when test="$element='p'"><xsl:value-of select="'codeblock'"/></xsl:when>
  39. <xsl:when test="$element='bodydiv'"><xsl:value-of select="'p'"/></xsl:when>
  40. <xsl:otherwise><xsl:value-of select="'codeblock'"/></xsl:otherwise>
  41. </xsl:choose>
  42. </xsl:variable>
  43. <xsl:choose>
  44. <xsl:when test=" contains( text(),'&#13;')">
  45. <xsl:for-each select="tokenize( text(),'&#13;')">
  46. <xsl:element name="{$surround_with}"><!-- to jest przetwarzane jak jest tekst lamany -->
  47. <xsl:value-of select="."/>
  48. </xsl:element>
  49. </xsl:for-each>
  50. </xsl:when>
  51. <xsl:otherwise>
  52. <xsl:choose>
  53. <xsl:when test="$count &gt;1">
  54. <codeblock>
  55. <!--<xsl:attribute name="DDxpath" select="@xpath"/>-->
  56. <!--DN(<xsl:value-of select="$element"/>)-->
  57. <!--count:<xsl:value-of select="$count"/>-->
  58. <xsl:copy-of select=" text()"/>
  59. </codeblock>
  60. </xsl:when>
  61. <xsl:otherwise>
  62. <xsl:apply-templates mode="enter_to_ph_text">
  63. <xsl:with-param name="element" select="$element"/>
  64. </xsl:apply-templates>
  65. <!--<xsl:copy-of select=" text()"/>-->
  66. </xsl:otherwise>
  67. </xsl:choose>
  68. </xsl:otherwise>
  69. </xsl:choose>
  70. </xsl:template>
  71. <!-- dodanie enterow dla tabel w ktorych wyrazy sa dluzsze niz 10 znakow -->
  72. <xsl:template match="text()" mode="enter_to_ph_text">
  73. <xsl:param name="element" required="yes"/>
  74. <xsl:choose>
  75. <xsl:when test="$element='entry'">
  76. <xsl:for-each select="tokenize(.,' ')">
  77. <xsl:value-of select="' '"/>
  78. <xsl:variable name="phrase" select="."/>
  79. <xsl:for-each select="1 to string-length(.)">
  80. <xsl:if test="position() mod 12 = 0"><xsl:value-of select="' -'"/></xsl:if>
  81. <xsl:value-of select="substring($phrase,position(),1)"/>
  82. </xsl:for-each>
  83. </xsl:for-each>
  84. </xsl:when>
  85. <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise>
  86. </xsl:choose>
  87. </xsl:template>
  88. <xsl:template match="*" mode="dita_content_clean">
  89. <xsl:value-of select="text()"/>
  90. <xsl:apply-templates mode="dita_content_clean"/>
  91. </xsl:template>
  92. <xsl:template match="text()" mode="dita_content_clean">
  93. <xsl:value-of select="."/>
  94. </xsl:template>
  95. </xsl:stylesheet>