syms.xsl 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?xml version="1.0"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. version="1.0">
  4. <xsl:output method="text" encoding="UTF-8"/>
  5. <xsl:variable name="api" select="document('libxml2-api.xml')"/>
  6. <xsl:template match="/">
  7. <xsl:text>#
  8. # Officially exported symbols, for which header
  9. # file definitions are installed in /usr/include/libxml2
  10. #
  11. # Automatically generated from symbols.xml and syms.xsl
  12. #
  13. # Versions here are *fixed* to match the libxml2 version
  14. # at which the symbol was introduced. This ensures that
  15. # a new client app requiring symbol foo() can't accidentally
  16. # run with old libxml2.so not providing foo() - the global
  17. # soname version info can't enforce this since we never
  18. # change the soname
  19. #
  20. </xsl:text>
  21. <xsl:apply-templates select="/symbols/release"/>
  22. </xsl:template>
  23. <xsl:template match="release">
  24. <xsl:variable name="prev"
  25. select="preceding-sibling::release[position()=1]"/>
  26. <xsl:text>LIBXML2_</xsl:text>
  27. <xsl:value-of select="string(@version)"/>
  28. <xsl:text> {
  29. global:
  30. </xsl:text>
  31. <xsl:for-each select="symbol">
  32. <xsl:if test="string(preceding-sibling::symbol[position()=1]/@file) != string(@file)">
  33. <xsl:text>
  34. # </xsl:text>
  35. <xsl:value-of select="@file"/>
  36. <xsl:text>
  37. </xsl:text>
  38. </xsl:if>
  39. <xsl:apply-templates select="."/>
  40. </xsl:for-each>
  41. <xsl:text>} </xsl:text>
  42. <xsl:if test="$prev">
  43. <xsl:text>LIBXML2_</xsl:text>
  44. <xsl:value-of select="$prev/@version"/>
  45. </xsl:if>
  46. <xsl:text>;
  47. </xsl:text>
  48. </xsl:template>
  49. <xsl:template match="symbol">
  50. <xsl:variable name="name" select="string(.)"/>
  51. <xsl:variable name="file" select="string(@file)"/>
  52. <xsl:choose>
  53. <xsl:when test="@removed">
  54. <xsl:text># </xsl:text>
  55. <xsl:value-of select="$name"/>
  56. <xsl:text>; removed in </xsl:text>
  57. <xsl:value-of select="@removed"/>
  58. <xsl:text>
  59. </xsl:text>
  60. </xsl:when>
  61. <xsl:otherwise>
  62. <!-- make sure we can find that symbol exported from the API list -->
  63. <xsl:variable name="def"
  64. select="$api/api/files/file[@name = $file]/exports[@symbol = $name]"/>
  65. <xsl:if test="string($def/@symbol) != $name">
  66. <xsl:message terminate="yes">
  67. <xsl:text>Failed to find definition in libxml2-api.xml:</xsl:text>
  68. <xsl:value-of select="$name"/>
  69. </xsl:message>
  70. </xsl:if>
  71. <xsl:text> </xsl:text>
  72. <xsl:value-of select="$name"/>
  73. <xsl:text>;</xsl:text>
  74. <xsl:if test="$def/@type = 'variable'">
  75. <xsl:text> # variable</xsl:text>
  76. </xsl:if>
  77. <xsl:if test="@comment">
  78. <xsl:text># </xsl:text>
  79. <xsl:value-of select="@comment"/>
  80. <xsl:text>
  81. </xsl:text>
  82. </xsl:if>
  83. <xsl:text>
  84. </xsl:text>
  85. </xsl:otherwise>
  86. </xsl:choose>
  87. </xsl:template>
  88. </xsl:stylesheet>