You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

191 lines
8.1 KiB

4 years ago
  1. from lxml.includes.tree cimport xmlDoc, xmlNode, xmlDict, xmlChar, const_xmlChar, xmlOutputBuffer
  2. from lxml.includes.xmlerror cimport xmlGenericErrorFunc
  3. from lxml.includes.xpath cimport xmlXPathContext, xmlXPathFunction
  4. from libc.string cimport const_char
  5. cdef extern from "libxslt/xslt.h":
  6. cdef int xsltLibxsltVersion
  7. cdef int xsltMaxDepth
  8. cdef extern from "libxslt/xsltconfig.h":
  9. cdef int LIBXSLT_VERSION
  10. cdef extern from "libxslt/xsltInternals.h":
  11. ctypedef enum xsltTransformState:
  12. XSLT_STATE_OK # 0
  13. XSLT_STATE_ERROR # 1
  14. XSLT_STATE_STOPPED # 2
  15. ctypedef struct xsltDocument:
  16. xmlDoc* doc
  17. ctypedef struct xsltStylesheet:
  18. xmlChar* encoding
  19. xmlDoc* doc
  20. int errors
  21. ctypedef struct xsltTransformContext:
  22. xsltStylesheet* style
  23. xmlXPathContext* xpathCtxt
  24. xsltDocument* document
  25. void* _private
  26. xmlDict* dict
  27. int profile
  28. xmlNode* node
  29. xmlDoc* output
  30. xmlNode* insert
  31. xmlNode* inst
  32. xsltTransformState state
  33. ctypedef struct xsltStackElem
  34. ctypedef struct xsltTemplate
  35. cdef xsltStylesheet* xsltParseStylesheetDoc(xmlDoc* doc) nogil
  36. cdef void xsltFreeStylesheet(xsltStylesheet* sheet) nogil
  37. cdef extern from "libxslt/imports.h":
  38. # actually defined in "etree_defs.h"
  39. cdef void LXML_GET_XSLT_ENCODING(const_xmlChar* result_var, xsltStylesheet* style)
  40. cdef extern from "libxslt/extensions.h":
  41. ctypedef void (*xsltTransformFunction)(xsltTransformContext* ctxt,
  42. xmlNode* context_node,
  43. xmlNode* inst,
  44. void* precomp_unused) nogil
  45. cdef int xsltRegisterExtFunction(xsltTransformContext* ctxt,
  46. const_xmlChar* name,
  47. const_xmlChar* URI,
  48. xmlXPathFunction function) nogil
  49. cdef int xsltRegisterExtModuleFunction(const_xmlChar* name, const_xmlChar* URI,
  50. xmlXPathFunction function) nogil
  51. cdef int xsltUnregisterExtModuleFunction(const_xmlChar* name, const_xmlChar* URI)
  52. cdef xmlXPathFunction xsltExtModuleFunctionLookup(
  53. const_xmlChar* name, const_xmlChar* URI) nogil
  54. cdef int xsltRegisterExtPrefix(xsltStylesheet* style,
  55. const_xmlChar* prefix, const_xmlChar* URI) nogil
  56. cdef int xsltRegisterExtElement(xsltTransformContext* ctxt,
  57. const_xmlChar* name, const_xmlChar* URI,
  58. xsltTransformFunction function) nogil
  59. cdef extern from "libxslt/documents.h":
  60. ctypedef enum xsltLoadType:
  61. XSLT_LOAD_START
  62. XSLT_LOAD_STYLESHEET
  63. XSLT_LOAD_DOCUMENT
  64. ctypedef xmlDoc* (*xsltDocLoaderFunc)(const_xmlChar* URI, xmlDict* dict,
  65. int options,
  66. void* ctxt,
  67. xsltLoadType type) nogil
  68. cdef xsltDocLoaderFunc xsltDocDefaultLoader
  69. cdef void xsltSetLoaderFunc(xsltDocLoaderFunc f) nogil
  70. cdef extern from "libxslt/transform.h":
  71. cdef xmlDoc* xsltApplyStylesheet(xsltStylesheet* style, xmlDoc* doc,
  72. const_char** params) nogil
  73. cdef xmlDoc* xsltApplyStylesheetUser(xsltStylesheet* style, xmlDoc* doc,
  74. const_char** params, const_char* output,
  75. void* profile,
  76. xsltTransformContext* context) nogil
  77. cdef void xsltProcessOneNode(xsltTransformContext* ctxt,
  78. xmlNode* contextNode,
  79. xsltStackElem* params) nogil
  80. cdef xsltTransformContext* xsltNewTransformContext(xsltStylesheet* style,
  81. xmlDoc* doc) nogil
  82. cdef void xsltFreeTransformContext(xsltTransformContext* context) nogil
  83. cdef void xsltApplyOneTemplate(xsltTransformContext* ctxt,
  84. xmlNode* contextNode, xmlNode* list,
  85. xsltTemplate* templ,
  86. xsltStackElem* params) nogil
  87. cdef extern from "libxslt/xsltutils.h":
  88. cdef int xsltSaveResultToString(xmlChar** doc_txt_ptr,
  89. int* doc_txt_len,
  90. xmlDoc* result,
  91. xsltStylesheet* style) nogil
  92. cdef int xsltSaveResultToFilename(const_char *URL,
  93. xmlDoc* result,
  94. xsltStylesheet* style,
  95. int compression) nogil
  96. cdef int xsltSaveResultTo(xmlOutputBuffer* buf,
  97. xmlDoc* result,
  98. xsltStylesheet* style) nogil
  99. cdef xmlGenericErrorFunc xsltGenericError
  100. cdef void *xsltGenericErrorContext
  101. cdef void xsltSetGenericErrorFunc(
  102. void* ctxt, void (*handler)(void* ctxt, char* msg, ...)) nogil
  103. cdef void xsltSetTransformErrorFunc(
  104. xsltTransformContext*, void* ctxt,
  105. void (*handler)(void* ctxt, char* msg, ...) nogil) nogil
  106. cdef void xsltTransformError(xsltTransformContext* ctxt,
  107. xsltStylesheet* style,
  108. xmlNode* node, char* msg, ...)
  109. cdef void xsltSetCtxtParseOptions(
  110. xsltTransformContext* ctxt, int options)
  111. cdef extern from "libxslt/security.h":
  112. ctypedef struct xsltSecurityPrefs
  113. ctypedef enum xsltSecurityOption:
  114. XSLT_SECPREF_READ_FILE = 1
  115. XSLT_SECPREF_WRITE_FILE = 2
  116. XSLT_SECPREF_CREATE_DIRECTORY = 3
  117. XSLT_SECPREF_READ_NETWORK = 4
  118. XSLT_SECPREF_WRITE_NETWORK = 5
  119. ctypedef int (*xsltSecurityCheck)(xsltSecurityPrefs* sec,
  120. xsltTransformContext* ctxt,
  121. char* value) nogil
  122. cdef xsltSecurityPrefs* xsltNewSecurityPrefs() nogil
  123. cdef void xsltFreeSecurityPrefs(xsltSecurityPrefs* sec) nogil
  124. cdef int xsltSecurityForbid(xsltSecurityPrefs* sec,
  125. xsltTransformContext* ctxt,
  126. char* value) nogil
  127. cdef int xsltSecurityAllow(xsltSecurityPrefs* sec,
  128. xsltTransformContext* ctxt,
  129. char* value) nogil
  130. cdef int xsltSetSecurityPrefs(xsltSecurityPrefs* sec,
  131. xsltSecurityOption option,
  132. xsltSecurityCheck func) nogil
  133. cdef xsltSecurityCheck xsltGetSecurityPrefs(
  134. xsltSecurityPrefs* sec,
  135. xsltSecurityOption option) nogil
  136. cdef int xsltSetCtxtSecurityPrefs(xsltSecurityPrefs* sec,
  137. xsltTransformContext* ctxt) nogil
  138. cdef xmlDoc* xsltGetProfileInformation(xsltTransformContext* ctxt) nogil
  139. cdef extern from "libxslt/variables.h":
  140. cdef int xsltQuoteUserParams(xsltTransformContext* ctxt,
  141. const_char** params)
  142. cdef int xsltQuoteOneUserParam(xsltTransformContext* ctxt,
  143. const_xmlChar* name,
  144. const_xmlChar* value)
  145. cdef extern from "libxslt/extra.h":
  146. const_xmlChar* XSLT_LIBXSLT_NAMESPACE
  147. const_xmlChar* XSLT_XALAN_NAMESPACE
  148. const_xmlChar* XSLT_SAXON_NAMESPACE
  149. const_xmlChar* XSLT_XT_NAMESPACE
  150. cdef xmlXPathFunction xsltFunctionNodeSet
  151. cdef void xsltRegisterAllExtras() nogil
  152. cdef extern from "libexslt/exslt.h":
  153. cdef void exsltRegisterAll() nogil
  154. # libexslt 1.1.25+
  155. const_xmlChar* EXSLT_DATE_NAMESPACE
  156. const_xmlChar* EXSLT_SETS_NAMESPACE
  157. const_xmlChar* EXSLT_MATH_NAMESPACE
  158. const_xmlChar* EXSLT_STRINGS_NAMESPACE
  159. cdef int exsltDateXpathCtxtRegister(xmlXPathContext* ctxt, const_xmlChar* prefix)
  160. cdef int exsltSetsXpathCtxtRegister(xmlXPathContext* ctxt, const_xmlChar* prefix)
  161. cdef int exsltMathXpathCtxtRegister(xmlXPathContext* ctxt, const_xmlChar* prefix)
  162. cdef int exsltStrXpathCtxtRegister(xmlXPathContext* ctxt, const_xmlChar* prefix)