Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .gitattributes +5 -0
- omnilmm/lib/python3.10/site-packages/gradio-4.41.0.dist-info/INSTALLER +1 -0
- omnilmm/lib/python3.10/site-packages/gradio-4.41.0.dist-info/METADATA +253 -0
- omnilmm/lib/python3.10/site-packages/gradio-4.41.0.dist-info/RECORD +0 -0
- omnilmm/lib/python3.10/site-packages/gradio-4.41.0.dist-info/REQUESTED +0 -0
- omnilmm/lib/python3.10/site-packages/gradio-4.41.0.dist-info/WHEEL +4 -0
- omnilmm/lib/python3.10/site-packages/gradio-4.41.0.dist-info/entry_points.txt +3 -0
- omnilmm/lib/python3.10/site-packages/gradio-4.41.0.dist-info/licenses/LICENSE +201 -0
- omnilmm/lib/python3.10/site-packages/lxml/ElementInclude.py +244 -0
- omnilmm/lib/python3.10/site-packages/lxml/__init__.py +22 -0
- omnilmm/lib/python3.10/site-packages/lxml/_elementpath.cpython-310-x86_64-linux-gnu.so +3 -0
- omnilmm/lib/python3.10/site-packages/lxml/_elementpath.py +341 -0
- omnilmm/lib/python3.10/site-packages/lxml/apihelpers.pxi +1793 -0
- omnilmm/lib/python3.10/site-packages/lxml/builder.cpython-310-x86_64-linux-gnu.so +3 -0
- omnilmm/lib/python3.10/site-packages/lxml/builder.py +232 -0
- omnilmm/lib/python3.10/site-packages/lxml/classlookup.pxi +580 -0
- omnilmm/lib/python3.10/site-packages/lxml/cleanup.pxi +215 -0
- omnilmm/lib/python3.10/site-packages/lxml/cssselect.py +101 -0
- omnilmm/lib/python3.10/site-packages/lxml/debug.pxi +90 -0
- omnilmm/lib/python3.10/site-packages/lxml/docloader.pxi +178 -0
- omnilmm/lib/python3.10/site-packages/lxml/doctestcompare.py +488 -0
- omnilmm/lib/python3.10/site-packages/lxml/dtd.pxi +478 -0
- omnilmm/lib/python3.10/site-packages/lxml/etree.cpython-310-x86_64-linux-gnu.so +3 -0
- omnilmm/lib/python3.10/site-packages/lxml/etree.h +248 -0
- omnilmm/lib/python3.10/site-packages/lxml/etree.pyx +0 -0
- omnilmm/lib/python3.10/site-packages/lxml/etree_api.h +195 -0
- omnilmm/lib/python3.10/site-packages/lxml/extensions.pxi +833 -0
- omnilmm/lib/python3.10/site-packages/lxml/includes/__init__.pxd +0 -0
- omnilmm/lib/python3.10/site-packages/lxml/includes/__init__.py +0 -0
- omnilmm/lib/python3.10/site-packages/lxml/includes/c14n.pxd +25 -0
- omnilmm/lib/python3.10/site-packages/lxml/includes/config.pxd +3 -0
- omnilmm/lib/python3.10/site-packages/lxml/includes/dtdvalid.pxd +18 -0
- omnilmm/lib/python3.10/site-packages/lxml/includes/etree_defs.h +379 -0
- omnilmm/lib/python3.10/site-packages/lxml/includes/etreepublic.pxd +237 -0
- omnilmm/lib/python3.10/site-packages/lxml/includes/htmlparser.pxd +56 -0
- omnilmm/lib/python3.10/site-packages/lxml/includes/libxml/SAX2.h +171 -0
- omnilmm/lib/python3.10/site-packages/lxml/includes/libxml/entities.h +155 -0
- omnilmm/lib/python3.10/site-packages/lxml/includes/libxml/parserInternals.h +663 -0
- omnilmm/lib/python3.10/site-packages/lxml/includes/libxml/schemasInternals.h +959 -0
- omnilmm/lib/python3.10/site-packages/lxml/includes/libxml/xlink.h +189 -0
- omnilmm/lib/python3.10/site-packages/lxml/includes/libxml/xmlversion.h +511 -0
- omnilmm/lib/python3.10/site-packages/lxml/includes/libxml/xmlwriter.h +488 -0
- omnilmm/lib/python3.10/site-packages/lxml/includes/libxml/xpath.h +575 -0
- omnilmm/lib/python3.10/site-packages/lxml/includes/lxml-version.h +3 -0
- omnilmm/lib/python3.10/site-packages/lxml/includes/relaxng.pxd +64 -0
- omnilmm/lib/python3.10/site-packages/lxml/includes/schematron.pxd +34 -0
- omnilmm/lib/python3.10/site-packages/lxml/includes/tree.pxd +494 -0
- omnilmm/lib/python3.10/site-packages/lxml/includes/uri.pxd +5 -0
- omnilmm/lib/python3.10/site-packages/lxml/includes/xinclude.pxd +22 -0
- omnilmm/lib/python3.10/site-packages/lxml/includes/xmlerror.pxd +852 -0
.gitattributes
CHANGED
|
@@ -1014,3 +1014,8 @@ omnilmm/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSerif-B
|
|
| 1014 |
omnilmm/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSansMono-Oblique.ttf filter=lfs diff=lfs merge=lfs -text
|
| 1015 |
omnilmm/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSerif.ttf filter=lfs diff=lfs merge=lfs -text
|
| 1016 |
omnilmm/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXGeneral.ttf filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1014 |
omnilmm/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSansMono-Oblique.ttf filter=lfs diff=lfs merge=lfs -text
|
| 1015 |
omnilmm/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/DejaVuSerif.ttf filter=lfs diff=lfs merge=lfs -text
|
| 1016 |
omnilmm/lib/python3.10/site-packages/matplotlib/mpl-data/fonts/ttf/STIXGeneral.ttf filter=lfs diff=lfs merge=lfs -text
|
| 1017 |
+
omnilmm/lib/python3.10/site-packages/lxml/_elementpath.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 1018 |
+
omnilmm/lib/python3.10/site-packages/lxml/objectify.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 1019 |
+
omnilmm/lib/python3.10/site-packages/lxml/sax.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 1020 |
+
omnilmm/lib/python3.10/site-packages/lxml/builder.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 1021 |
+
omnilmm/lib/python3.10/site-packages/lxml/etree.cpython-310-x86_64-linux-gnu.so filter=lf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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Metadata-Version: 2.3
|
| 2 |
+
Name: gradio
|
| 3 |
+
Version: 4.41.0
|
| 4 |
+
Summary: Python library for easily interacting with trained machine learning models
|
| 5 |
+
Project-URL: Homepage, https://github.com/gradio-app/gradio
|
| 6 |
+
Author-email: Abubakar Abid <gradio-team@huggingface.co>, Ali Abid <gradio-team@huggingface.co>, Ali Abdalla <gradio-team@huggingface.co>, Dawood Khan <gradio-team@huggingface.co>, Ahsen Khaliq <gradio-team@huggingface.co>, Pete Allen <gradio-team@huggingface.co>, Ömer Faruk Özdemir <gradio-team@huggingface.co>, Freddy A Boulton <gradio-team@huggingface.co>, Hannah Blair <gradio-team@huggingface.co>
|
| 7 |
+
License-Expression: Apache-2.0
|
| 8 |
+
License-File: LICENSE
|
| 9 |
+
Keywords: machine learning,reproducibility,visualization
|
| 10 |
+
Classifier: Development Status :: 5 - Production/Stable
|
| 11 |
+
Classifier: License :: OSI Approved :: Apache Software License
|
| 12 |
+
Classifier: Operating System :: OS Independent
|
| 13 |
+
Classifier: Programming Language :: Python :: 3
|
| 14 |
+
Classifier: Programming Language :: Python :: 3 :: Only
|
| 15 |
+
Classifier: Programming Language :: Python :: 3.8
|
| 16 |
+
Classifier: Programming Language :: Python :: 3.9
|
| 17 |
+
Classifier: Programming Language :: Python :: 3.10
|
| 18 |
+
Classifier: Programming Language :: Python :: 3.11
|
| 19 |
+
Classifier: Topic :: Scientific/Engineering
|
| 20 |
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
| 21 |
+
Classifier: Topic :: Scientific/Engineering :: Visualization
|
| 22 |
+
Requires-Python: >=3.8
|
| 23 |
+
Requires-Dist: aiofiles<24.0,>=22.0
|
| 24 |
+
Requires-Dist: anyio<5.0,>=3.0
|
| 25 |
+
Requires-Dist: fastapi
|
| 26 |
+
Requires-Dist: ffmpy
|
| 27 |
+
Requires-Dist: gradio-client==1.3.0
|
| 28 |
+
Requires-Dist: httpx>=0.24.1
|
| 29 |
+
Requires-Dist: huggingface-hub>=0.19.3
|
| 30 |
+
Requires-Dist: importlib-resources<7.0,>=1.3
|
| 31 |
+
Requires-Dist: jinja2<4.0
|
| 32 |
+
Requires-Dist: markupsafe~=2.0
|
| 33 |
+
Requires-Dist: matplotlib~=3.0
|
| 34 |
+
Requires-Dist: numpy<3.0,>=1.0
|
| 35 |
+
Requires-Dist: orjson~=3.0
|
| 36 |
+
Requires-Dist: packaging
|
| 37 |
+
Requires-Dist: pandas<3.0,>=1.0
|
| 38 |
+
Requires-Dist: pillow<11.0,>=8.0
|
| 39 |
+
Requires-Dist: pydantic>=2.0
|
| 40 |
+
Requires-Dist: pydub
|
| 41 |
+
Requires-Dist: python-multipart>=0.0.9
|
| 42 |
+
Requires-Dist: pyyaml<7.0,>=5.0
|
| 43 |
+
Requires-Dist: ruff>=0.2.2; sys_platform != 'emscripten'
|
| 44 |
+
Requires-Dist: semantic-version~=2.0
|
| 45 |
+
Requires-Dist: tomlkit==0.12.0
|
| 46 |
+
Requires-Dist: typer<1.0,>=0.12; sys_platform != 'emscripten'
|
| 47 |
+
Requires-Dist: typing-extensions~=4.0
|
| 48 |
+
Requires-Dist: urllib3~=2.0
|
| 49 |
+
Requires-Dist: uvicorn>=0.14.0; sys_platform != 'emscripten'
|
| 50 |
+
Provides-Extra: oauth
|
| 51 |
+
Requires-Dist: authlib; extra == 'oauth'
|
| 52 |
+
Requires-Dist: itsdangerous; extra == 'oauth'
|
| 53 |
+
Description-Content-Type: text/markdown
|
| 54 |
+
|
| 55 |
+
<!-- DO NOT EDIT THIS FILE DIRECTLY. INSTEAD EDIT THE `readme_template.md` OR `guides/1)getting_started/1)quickstart.md` TEMPLATES AND THEN RUN `render_readme.py` SCRIPT. -->
|
| 56 |
+
|
| 57 |
+
<div align="center">
|
| 58 |
+
|
| 59 |
+
[<img src="https://raw.githubusercontent.com/gradio-app/gradio/main/readme_files/gradio.svg" alt="gradio" width=400>](https://gradio.app)<br>
|
| 60 |
+
|
| 61 |
+
[](https://github.com/gradio-app/gradio/actions/workflows/test-python.yml)
|
| 62 |
+
[](https://github.com/gradio-app/gradio/actions/workflows/tests-js.yml)
|
| 63 |
+
[](https://pypi.org/project/gradio/)
|
| 64 |
+
[](https://pypi.org/project/gradio/)
|
| 65 |
+

|
| 66 |
+
[](https://twitter.com/gradio)
|
| 67 |
+
|
| 68 |
+
[Website](https://gradio.app)
|
| 69 |
+
| [Documentation](https://gradio.app/docs/)
|
| 70 |
+
| [Guides](https://gradio.app/guides/)
|
| 71 |
+
| [Getting Started](https://gradio.app/getting_started/)
|
| 72 |
+
| [Examples](demo/)
|
| 73 |
+
| [中文](https://raw.githubusercontent.com/gradio-app/gradio/main/readme_files/zh-cn#readme)
|
| 74 |
+
|
| 75 |
+
</div>
|
| 76 |
+
|
| 77 |
+
# Gradio: Build Machine Learning Web Apps — in Python
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
Gradio is an open-source Python package that allows you to quickly **build** a demo or web application for your machine learning model, API, or any arbitrary Python function. You can then **share** a link to your demo or web application in just a few seconds using Gradio's built-in sharing features. *No JavaScript, CSS, or web hosting experience needed!*
|
| 82 |
+
|
| 83 |
+
<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/gradio-guides/lcm-screenshot-3.gif" style="padding-bottom: 10px">
|
| 84 |
+
|
| 85 |
+
It just takes a few lines of Python to create a beautiful demo like the one above, so let's get started 💫
|
| 86 |
+
|
| 87 |
+
### Installation
|
| 88 |
+
|
| 89 |
+
**Prerequisite**: Gradio requires [Python 3.8 or higher](https://www.python.org/downloads/)
|
| 90 |
+
|
| 91 |
+
|
| 92 |
+
We recommend installing Gradio using `pip`, which is included by default in Python. Run this in your terminal or command prompt:
|
| 93 |
+
|
| 94 |
+
```
|
| 95 |
+
pip install gradio
|
| 96 |
+
```
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
> [!TIP]
|
| 100 |
+
> It is best to install Gradio in a virtual environment. Detailed installation instructions for all common operating systems <a href="https://www.gradio.app/main/guides/installing-gradio-in-a-virtual-environment">are provided here</a>.
|
| 101 |
+
|
| 102 |
+
### Building Your First Demo
|
| 103 |
+
|
| 104 |
+
You can run Gradio in your favorite code editor, Jupyter notebook, Google Colab, or anywhere else you write Python. Let's write your first Gradio app:
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
```python
|
| 108 |
+
import gradio as gr
|
| 109 |
+
|
| 110 |
+
def greet(name, intensity):
|
| 111 |
+
return "Hello " * intensity + name + "!"
|
| 112 |
+
|
| 113 |
+
demo = gr.Interface(
|
| 114 |
+
fn=greet,
|
| 115 |
+
inputs=["text", "slider"],
|
| 116 |
+
outputs=["text"],
|
| 117 |
+
)
|
| 118 |
+
|
| 119 |
+
demo.launch()
|
| 120 |
+
```
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
|
| 124 |
+
> [!TIP]
|
| 125 |
+
> We shorten the imported name from <code>gradio</code> to <code>gr</code> for better readability of code. This is a widely adopted convention that you should follow so that anyone working with your code can easily understand it.
|
| 126 |
+
|
| 127 |
+
Now, run your code. If you've written the Python code in a file named, for example, `app.py`, then you would run `python app.py` from the terminal.
|
| 128 |
+
|
| 129 |
+
The demo below will open in a browser on [http://localhost:7860](http://localhost:7860) if running from a file. If you are running within a notebook, the demo will appear embedded within the notebook.
|
| 130 |
+
|
| 131 |
+

|
| 132 |
+
|
| 133 |
+
Type your name in the textbox on the left, drag the slider, and then press the Submit button. You should see a friendly greeting on the right.
|
| 134 |
+
|
| 135 |
+
> [!TIP]
|
| 136 |
+
> When developing locally, you can run your Gradio app in <strong>hot reload mode</strong>, which automatically reloads the Gradio app whenever you make changes to the file. To do this, simply type in <code>gradio</code> before the name of the file instead of <code>python</code>. In the example above, you would type: `gradio app.py` in your terminal. Learn more about hot reloading in the <a href="https://www.gradio.app/guides/developing-faster-with-reload-mode">Hot Reloading Guide</a>.
|
| 137 |
+
|
| 138 |
+
|
| 139 |
+
**Understanding the `Interface` Class**
|
| 140 |
+
|
| 141 |
+
You'll notice that in order to make your first demo, you created an instance of the `gr.Interface` class. The `Interface` class is designed to create demos for machine learning models which accept one or more inputs, and return one or more outputs.
|
| 142 |
+
|
| 143 |
+
The `Interface` class has three core arguments:
|
| 144 |
+
|
| 145 |
+
- `fn`: the function to wrap a user interface (UI) around
|
| 146 |
+
- `inputs`: the Gradio component(s) to use for the input. The number of components should match the number of arguments in your function.
|
| 147 |
+
- `outputs`: the Gradio component(s) to use for the output. The number of components should match the number of return values from your function.
|
| 148 |
+
|
| 149 |
+
The `fn` argument is very flexible -- you can pass *any* Python function that you want to wrap with a UI. In the example above, we saw a relatively simple function, but the function could be anything from a music generator to a tax calculator to the prediction function of a pretrained machine learning model.
|
| 150 |
+
|
| 151 |
+
The `input` and `output` arguments take one or more Gradio components. As we'll see, Gradio includes more than [30 built-in components](https://www.gradio.app/docs/gradio/introduction) (such as the `gr.Textbox()`, `gr.Image()`, and `gr.HTML()` components) that are designed for machine learning applications.
|
| 152 |
+
|
| 153 |
+
> [!TIP]
|
| 154 |
+
> For the `inputs` and `outputs` arguments, you can pass in the name of these components as a string (`"textbox"`) or an instance of the class (`gr.Textbox()`).
|
| 155 |
+
|
| 156 |
+
If your function accepts more than one argument, as is the case above, pass a list of input components to `inputs`, with each input component corresponding to one of the arguments of the function, in order. The same holds true if your function returns more than one value: simply pass in a list of components to `outputs`. This flexibility makes the `Interface` class a very powerful way to create demos.
|
| 157 |
+
|
| 158 |
+
We'll dive deeper into the `gr.Interface` on our series on [building Interfaces](https://www.gradio.app/main/guides/the-interface-class).
|
| 159 |
+
|
| 160 |
+
### Sharing Your Demo
|
| 161 |
+
|
| 162 |
+
What good is a beautiful demo if you can't share it? Gradio lets you easily share a machine learning demo without having to worry about the hassle of hosting on a web server. Simply set `share=True` in `launch()`, and a publicly accessible URL will be created for your demo. Let's revisit our example demo, but change the last line as follows:
|
| 163 |
+
|
| 164 |
+
```python
|
| 165 |
+
import gradio as gr
|
| 166 |
+
|
| 167 |
+
def greet(name):
|
| 168 |
+
return "Hello " + name + "!"
|
| 169 |
+
|
| 170 |
+
demo = gr.Interface(fn=greet, inputs="textbox", outputs="textbox")
|
| 171 |
+
|
| 172 |
+
demo.launch(share=True) # Share your demo with just 1 extra parameter 🚀
|
| 173 |
+
```
|
| 174 |
+
|
| 175 |
+
When you run this code, a public URL will be generated for your demo in a matter of seconds, something like:
|
| 176 |
+
|
| 177 |
+
👉 `https://a23dsf231adb.gradio.live`
|
| 178 |
+
|
| 179 |
+
Now, anyone around the world can try your Gradio demo from their browser, while the machine learning model and all computation continues to run locally on your computer.
|
| 180 |
+
|
| 181 |
+
To learn more about sharing your demo, read our dedicated guide on [sharing your Gradio application](https://www.gradio.app/guides/sharing-your-app).
|
| 182 |
+
|
| 183 |
+
|
| 184 |
+
### An Overview of Gradio
|
| 185 |
+
|
| 186 |
+
So far, we've been discussing the `Interface` class, which is a high-level class that lets to build demos quickly with Gradio. But what else does Gradio do?
|
| 187 |
+
|
| 188 |
+
#### Chatbots with `gr.ChatInterface`
|
| 189 |
+
|
| 190 |
+
Gradio includes another high-level class, `gr.ChatInterface`, which is specifically designed to create Chatbot UIs. Similar to `Interface`, you supply a function and Gradio creates a fully working Chatbot UI. If you're interested in creating a chatbot, you can jump straight [our dedicated guide on `gr.ChatInterface`](https://www.gradio.app/guides/creating-a-chatbot-fast).
|
| 191 |
+
|
| 192 |
+
#### Custom Demos with `gr.Blocks`
|
| 193 |
+
|
| 194 |
+
Gradio also offers a low-level approach for designing web apps with more flexible layouts and data flows with the `gr.Blocks` class. Blocks allows you to do things like control where components appear on the page, handle complex data flows (e.g. outputs can serve as inputs to other functions), and update properties/visibility of components based on user interaction — still all in Python.
|
| 195 |
+
|
| 196 |
+
You can build very custom and complex applications using `gr.Blocks()`. For example, the popular image generation [Automatic1111 Web UI](https://github.com/AUTOMATIC1111/stable-diffusion-webui) is built using Gradio Blocks. We dive deeper into the `gr.Blocks` on our series on [building with Blocks](https://www.gradio.app/guides/blocks-and-event-listeners).
|
| 197 |
+
|
| 198 |
+
|
| 199 |
+
#### The Gradio Python & JavaScript Ecosystem
|
| 200 |
+
|
| 201 |
+
That's the gist of the core `gradio` Python library, but Gradio is actually so much more! It's an entire ecosystem of Python and JavaScript libraries that let you build machine learning applications, or query them programmatically, in Python or JavaScript. Here are other related parts of the Gradio ecosystem:
|
| 202 |
+
|
| 203 |
+
* [Gradio Python Client](https://www.gradio.app/guides/getting-started-with-the-python-client) (`gradio_client`): query any Gradio app programmatically in Python.
|
| 204 |
+
* [Gradio JavaScript Client](https://www.gradio.app/guides/getting-started-with-the-js-client) (`@gradio/client`): query any Gradio app programmatically in JavaScript.
|
| 205 |
+
* [Gradio-Lite](https://www.gradio.app/guides/gradio-lite) (`@gradio/lite`): write Gradio apps in Python that run entirely in the browser (no server needed!), thanks to Pyodide.
|
| 206 |
+
* [Hugging Face Spaces](https://huggingface.co/spaces): the most popular place to host Gradio applications — for free!
|
| 207 |
+
|
| 208 |
+
### What's Next?
|
| 209 |
+
|
| 210 |
+
Keep learning about Gradio sequentially using the Gradio Guides, which include explanations as well as example code and embedded interactive demos. Next up: [key features about Gradio demos](https://www.gradio.app/guides/key-features).
|
| 211 |
+
|
| 212 |
+
Or, if you already know the basics and are looking for something specific, you can search the more [technical API documentation](https://www.gradio.app/docs/).
|
| 213 |
+
|
| 214 |
+
|
| 215 |
+
|
| 216 |
+
|
| 217 |
+
## Questions?
|
| 218 |
+
|
| 219 |
+
If you'd like to report a bug or have a feature request, please create an [issue on GitHub](https://github.com/gradio-app/gradio/issues/new/choose). For general questions about usage, we are available on [our Discord server](https://discord.com/invite/feTf9x3ZSB) and happy to help.
|
| 220 |
+
|
| 221 |
+
If you like Gradio, please leave us a ⭐ on GitHub!
|
| 222 |
+
|
| 223 |
+
## Open Source Stack
|
| 224 |
+
|
| 225 |
+
Gradio is built on top of many wonderful open-source libraries!
|
| 226 |
+
|
| 227 |
+
[<img src="https://raw.githubusercontent.com/gradio-app/gradio/main/readme_files/huggingface_mini.svg" alt="huggingface" height=40>](https://huggingface.co)
|
| 228 |
+
[<img src="https://raw.githubusercontent.com/gradio-app/gradio/main/readme_files/python.svg" alt="python" height=40>](https://www.python.org)
|
| 229 |
+
[<img src="https://raw.githubusercontent.com/gradio-app/gradio/main/readme_files/fastapi.svg" alt="fastapi" height=40>](https://fastapi.tiangolo.com)
|
| 230 |
+
[<img src="https://raw.githubusercontent.com/gradio-app/gradio/main/readme_files/encode.svg" alt="encode" height=40>](https://www.encode.io)
|
| 231 |
+
[<img src="https://raw.githubusercontent.com/gradio-app/gradio/main/readme_files/svelte.svg" alt="svelte" height=40>](https://svelte.dev)
|
| 232 |
+
[<img src="https://raw.githubusercontent.com/gradio-app/gradio/main/readme_files/vite.svg" alt="vite" height=40>](https://vitejs.dev)
|
| 233 |
+
[<img src="https://raw.githubusercontent.com/gradio-app/gradio/main/readme_files/pnpm.svg" alt="pnpm" height=40>](https://pnpm.io)
|
| 234 |
+
[<img src="https://raw.githubusercontent.com/gradio-app/gradio/main/readme_files/tailwind.svg" alt="tailwind" height=40>](https://tailwindcss.com)
|
| 235 |
+
[<img src="https://raw.githubusercontent.com/gradio-app/gradio/main/readme_files/storybook.svg" alt="storybook" height=40>](https://storybook.js.org/)
|
| 236 |
+
[<img src="https://raw.githubusercontent.com/gradio-app/gradio/main/readme_files/chromatic.svg" alt="chromatic" height=40>](https://www.chromatic.com/)
|
| 237 |
+
|
| 238 |
+
## License
|
| 239 |
+
|
| 240 |
+
Gradio is licensed under the Apache License 2.0 found in the [LICENSE](LICENSE) file in the root directory of this repository.
|
| 241 |
+
|
| 242 |
+
## Citation
|
| 243 |
+
|
| 244 |
+
Also check out the paper _[Gradio: Hassle-Free Sharing and Testing of ML Models in the Wild](https://arxiv.org/abs/1906.02569), ICML HILL 2019_, and please cite it if you use Gradio in your work.
|
| 245 |
+
|
| 246 |
+
```
|
| 247 |
+
@article{abid2019gradio,
|
| 248 |
+
title = {Gradio: Hassle-Free Sharing and Testing of ML Models in the Wild},
|
| 249 |
+
author = {Abid, Abubakar and Abdalla, Ali and Abid, Ali and Khan, Dawood and Alfozan, Abdulrahman and Zou, James},
|
| 250 |
+
journal = {arXiv preprint arXiv:1906.02569},
|
| 251 |
+
year = {2019},
|
| 252 |
+
}
|
| 253 |
+
```
|
omnilmm/lib/python3.10/site-packages/gradio-4.41.0.dist-info/RECORD
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
omnilmm/lib/python3.10/site-packages/gradio-4.41.0.dist-info/REQUESTED
ADDED
|
File without changes
|
omnilmm/lib/python3.10/site-packages/gradio-4.41.0.dist-info/WHEEL
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Wheel-Version: 1.0
|
| 2 |
+
Generator: hatchling 1.25.0
|
| 3 |
+
Root-Is-Purelib: true
|
| 4 |
+
Tag: py3-none-any
|
omnilmm/lib/python3.10/site-packages/gradio-4.41.0.dist-info/entry_points.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[console_scripts]
|
| 2 |
+
gradio = gradio.cli:cli
|
| 3 |
+
upload_theme = gradio.themes.upload_theme:main
|
omnilmm/lib/python3.10/site-packages/gradio-4.41.0.dist-info/licenses/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Apache License
|
| 2 |
+
Version 2.0, January 2004
|
| 3 |
+
http://www.apache.org/licenses/
|
| 4 |
+
|
| 5 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
| 6 |
+
|
| 7 |
+
1. Definitions.
|
| 8 |
+
|
| 9 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
| 10 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
| 11 |
+
|
| 12 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
| 13 |
+
the copyright owner that is granting the License.
|
| 14 |
+
|
| 15 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
| 16 |
+
other entities that control, are controlled by, or are under common
|
| 17 |
+
control with that entity. For the purposes of this definition,
|
| 18 |
+
"control" means (i) the power, direct or indirect, to cause the
|
| 19 |
+
direction or management of such entity, whether by contract or
|
| 20 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
| 21 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
| 22 |
+
|
| 23 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
| 24 |
+
exercising permissions granted by this License.
|
| 25 |
+
|
| 26 |
+
"Source" form shall mean the preferred form for making modifications,
|
| 27 |
+
including but not limited to software source code, documentation
|
| 28 |
+
source, and configuration files.
|
| 29 |
+
|
| 30 |
+
"Object" form shall mean any form resulting from mechanical
|
| 31 |
+
transformation or translation of a Source form, including but
|
| 32 |
+
not limited to compiled object code, generated documentation,
|
| 33 |
+
and conversions to other media types.
|
| 34 |
+
|
| 35 |
+
"Work" shall mean the work of authorship, whether in Source or
|
| 36 |
+
Object form, made available under the License, as indicated by a
|
| 37 |
+
copyright notice that is included in or attached to the work
|
| 38 |
+
(an example is provided in the Appendix below).
|
| 39 |
+
|
| 40 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
| 41 |
+
form, that is based on (or derived from) the Work and for which the
|
| 42 |
+
editorial revisions, annotations, elaborations, or other modifications
|
| 43 |
+
represent, as a whole, an original work of authorship. For the purposes
|
| 44 |
+
of this License, Derivative Works shall not include works that remain
|
| 45 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
| 46 |
+
the Work and Derivative Works thereof.
|
| 47 |
+
|
| 48 |
+
"Contribution" shall mean any work of authorship, including
|
| 49 |
+
the original version of the Work and any modifications or additions
|
| 50 |
+
to that Work or Derivative Works thereof, that is intentionally
|
| 51 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
| 52 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
| 53 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
| 54 |
+
means any form of electronic, verbal, or written communication sent
|
| 55 |
+
to the Licensor or its representatives, including but not limited to
|
| 56 |
+
communication on electronic mailing lists, source code control systems,
|
| 57 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
| 58 |
+
Licensor for the purpose of discussing and improving the Work, but
|
| 59 |
+
excluding communication that is conspicuously marked or otherwise
|
| 60 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
| 61 |
+
|
| 62 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
| 63 |
+
on behalf of whom a Contribution has been received by Licensor and
|
| 64 |
+
subsequently incorporated within the Work.
|
| 65 |
+
|
| 66 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
| 67 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 68 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 69 |
+
copyright license to reproduce, prepare Derivative Works of,
|
| 70 |
+
publicly display, publicly perform, sublicense, and distribute the
|
| 71 |
+
Work and such Derivative Works in Source or Object form.
|
| 72 |
+
|
| 73 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
| 74 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 75 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 76 |
+
(except as stated in this section) patent license to make, have made,
|
| 77 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
| 78 |
+
where such license applies only to those patent claims licensable
|
| 79 |
+
by such Contributor that are necessarily infringed by their
|
| 80 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
| 81 |
+
with the Work to which such Contribution(s) was submitted. If You
|
| 82 |
+
institute patent litigation against any entity (including a
|
| 83 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
| 84 |
+
or a Contribution incorporated within the Work constitutes direct
|
| 85 |
+
or contributory patent infringement, then any patent licenses
|
| 86 |
+
granted to You under this License for that Work shall terminate
|
| 87 |
+
as of the date such litigation is filed.
|
| 88 |
+
|
| 89 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
| 90 |
+
Work or Derivative Works thereof in any medium, with or without
|
| 91 |
+
modifications, and in Source or Object form, provided that You
|
| 92 |
+
meet the following conditions:
|
| 93 |
+
|
| 94 |
+
(a) You must give any other recipients of the Work or
|
| 95 |
+
Derivative Works a copy of this License; and
|
| 96 |
+
|
| 97 |
+
(b) You must cause any modified files to carry prominent notices
|
| 98 |
+
stating that You changed the files; and
|
| 99 |
+
|
| 100 |
+
(c) You must retain, in the Source form of any Derivative Works
|
| 101 |
+
that You distribute, all copyright, patent, trademark, and
|
| 102 |
+
attribution notices from the Source form of the Work,
|
| 103 |
+
excluding those notices that do not pertain to any part of
|
| 104 |
+
the Derivative Works; and
|
| 105 |
+
|
| 106 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
| 107 |
+
distribution, then any Derivative Works that You distribute must
|
| 108 |
+
include a readable copy of the attribution notices contained
|
| 109 |
+
within such NOTICE file, excluding those notices that do not
|
| 110 |
+
pertain to any part of the Derivative Works, in at least one
|
| 111 |
+
of the following places: within a NOTICE text file distributed
|
| 112 |
+
as part of the Derivative Works; within the Source form or
|
| 113 |
+
documentation, if provided along with the Derivative Works; or,
|
| 114 |
+
within a display generated by the Derivative Works, if and
|
| 115 |
+
wherever such third-party notices normally appear. The contents
|
| 116 |
+
of the NOTICE file are for informational purposes only and
|
| 117 |
+
do not modify the License. You may add Your own attribution
|
| 118 |
+
notices within Derivative Works that You distribute, alongside
|
| 119 |
+
or as an addendum to the NOTICE text from the Work, provided
|
| 120 |
+
that such additional attribution notices cannot be construed
|
| 121 |
+
as modifying the License.
|
| 122 |
+
|
| 123 |
+
You may add Your own copyright statement to Your modifications and
|
| 124 |
+
may provide additional or different license terms and conditions
|
| 125 |
+
for use, reproduction, or distribution of Your modifications, or
|
| 126 |
+
for any such Derivative Works as a whole, provided Your use,
|
| 127 |
+
reproduction, and distribution of the Work otherwise complies with
|
| 128 |
+
the conditions stated in this License.
|
| 129 |
+
|
| 130 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
| 131 |
+
any Contribution intentionally submitted for inclusion in the Work
|
| 132 |
+
by You to the Licensor shall be under the terms and conditions of
|
| 133 |
+
this License, without any additional terms or conditions.
|
| 134 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
| 135 |
+
the terms of any separate license agreement you may have executed
|
| 136 |
+
with Licensor regarding such Contributions.
|
| 137 |
+
|
| 138 |
+
6. Trademarks. This License does not grant permission to use the trade
|
| 139 |
+
names, trademarks, service marks, or product names of the Licensor,
|
| 140 |
+
except as required for reasonable and customary use in describing the
|
| 141 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
| 142 |
+
|
| 143 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
| 144 |
+
agreed to in writing, Licensor provides the Work (and each
|
| 145 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
| 146 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
| 147 |
+
implied, including, without limitation, any warranties or conditions
|
| 148 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
| 149 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
| 150 |
+
appropriateness of using or redistributing the Work and assume any
|
| 151 |
+
risks associated with Your exercise of permissions under this License.
|
| 152 |
+
|
| 153 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
| 154 |
+
whether in tort (including negligence), contract, or otherwise,
|
| 155 |
+
unless required by applicable law (such as deliberate and grossly
|
| 156 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
| 157 |
+
liable to You for damages, including any direct, indirect, special,
|
| 158 |
+
incidental, or consequential damages of any character arising as a
|
| 159 |
+
result of this License or out of the use or inability to use the
|
| 160 |
+
Work (including but not limited to damages for loss of goodwill,
|
| 161 |
+
work stoppage, computer failure or malfunction, or any and all
|
| 162 |
+
other commercial damages or losses), even if such Contributor
|
| 163 |
+
has been advised of the possibility of such damages.
|
| 164 |
+
|
| 165 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
| 166 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
| 167 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
| 168 |
+
or other liability obligations and/or rights consistent with this
|
| 169 |
+
License. However, in accepting such obligations, You may act only
|
| 170 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
| 171 |
+
of any other Contributor, and only if You agree to indemnify,
|
| 172 |
+
defend, and hold each Contributor harmless for any liability
|
| 173 |
+
incurred by, or claims asserted against, such Contributor by reason
|
| 174 |
+
of your accepting any such warranty or additional liability.
|
| 175 |
+
|
| 176 |
+
END OF TERMS AND CONDITIONS
|
| 177 |
+
|
| 178 |
+
APPENDIX: How to apply the Apache License to your work.
|
| 179 |
+
|
| 180 |
+
To apply the Apache License to your work, attach the following
|
| 181 |
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
| 182 |
+
replaced with your own identifying information. (Don't include
|
| 183 |
+
the brackets!) The text should be enclosed in the appropriate
|
| 184 |
+
comment syntax for the file format. We also recommend that a
|
| 185 |
+
file or class name and description of purpose be included on the
|
| 186 |
+
same "printed page" as the copyright notice for easier
|
| 187 |
+
identification within third-party archives.
|
| 188 |
+
|
| 189 |
+
Copyright [yyyy] [name of copyright owner]
|
| 190 |
+
|
| 191 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
| 192 |
+
you may not use this file except in compliance with the License.
|
| 193 |
+
You may obtain a copy of the License at
|
| 194 |
+
|
| 195 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
| 196 |
+
|
| 197 |
+
Unless required by applicable law or agreed to in writing, software
|
| 198 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
| 199 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 200 |
+
See the License for the specific language governing permissions and
|
| 201 |
+
limitations under the License.
|
omnilmm/lib/python3.10/site-packages/lxml/ElementInclude.py
ADDED
|
@@ -0,0 +1,244 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#
|
| 2 |
+
# ElementTree
|
| 3 |
+
# $Id: ElementInclude.py 1862 2004-06-18 07:31:02Z Fredrik $
|
| 4 |
+
#
|
| 5 |
+
# limited xinclude support for element trees
|
| 6 |
+
#
|
| 7 |
+
# history:
|
| 8 |
+
# 2003-08-15 fl created
|
| 9 |
+
# 2003-11-14 fl fixed default loader
|
| 10 |
+
#
|
| 11 |
+
# Copyright (c) 2003-2004 by Fredrik Lundh. All rights reserved.
|
| 12 |
+
#
|
| 13 |
+
# fredrik@pythonware.com
|
| 14 |
+
# http://www.pythonware.com
|
| 15 |
+
#
|
| 16 |
+
# --------------------------------------------------------------------
|
| 17 |
+
# The ElementTree toolkit is
|
| 18 |
+
#
|
| 19 |
+
# Copyright (c) 1999-2004 by Fredrik Lundh
|
| 20 |
+
#
|
| 21 |
+
# By obtaining, using, and/or copying this software and/or its
|
| 22 |
+
# associated documentation, you agree that you have read, understood,
|
| 23 |
+
# and will comply with the following terms and conditions:
|
| 24 |
+
#
|
| 25 |
+
# Permission to use, copy, modify, and distribute this software and
|
| 26 |
+
# its associated documentation for any purpose and without fee is
|
| 27 |
+
# hereby granted, provided that the above copyright notice appears in
|
| 28 |
+
# all copies, and that both that copyright notice and this permission
|
| 29 |
+
# notice appear in supporting documentation, and that the name of
|
| 30 |
+
# Secret Labs AB or the author not be used in advertising or publicity
|
| 31 |
+
# pertaining to distribution of the software without specific, written
|
| 32 |
+
# prior permission.
|
| 33 |
+
#
|
| 34 |
+
# SECRET LABS AB AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
|
| 35 |
+
# TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT-
|
| 36 |
+
# ABILITY AND FITNESS. IN NO EVENT SHALL SECRET LABS AB OR THE AUTHOR
|
| 37 |
+
# BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
|
| 38 |
+
# DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 39 |
+
# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
| 40 |
+
# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 41 |
+
# OF THIS SOFTWARE.
|
| 42 |
+
# --------------------------------------------------------------------
|
| 43 |
+
|
| 44 |
+
"""
|
| 45 |
+
Limited XInclude support for the ElementTree package.
|
| 46 |
+
|
| 47 |
+
While lxml.etree has full support for XInclude (see
|
| 48 |
+
`etree.ElementTree.xinclude()`), this module provides a simpler, pure
|
| 49 |
+
Python, ElementTree compatible implementation that supports a simple
|
| 50 |
+
form of custom URL resolvers.
|
| 51 |
+
"""
|
| 52 |
+
|
| 53 |
+
from lxml import etree
|
| 54 |
+
try:
|
| 55 |
+
from urlparse import urljoin
|
| 56 |
+
from urllib2 import urlopen
|
| 57 |
+
except ImportError:
|
| 58 |
+
# Python 3
|
| 59 |
+
from urllib.parse import urljoin
|
| 60 |
+
from urllib.request import urlopen
|
| 61 |
+
|
| 62 |
+
XINCLUDE = "{http://www.w3.org/2001/XInclude}"
|
| 63 |
+
|
| 64 |
+
XINCLUDE_INCLUDE = XINCLUDE + "include"
|
| 65 |
+
XINCLUDE_FALLBACK = XINCLUDE + "fallback"
|
| 66 |
+
XINCLUDE_ITER_TAG = XINCLUDE + "*"
|
| 67 |
+
|
| 68 |
+
# For security reasons, the inclusion depth is limited to this read-only value by default.
|
| 69 |
+
DEFAULT_MAX_INCLUSION_DEPTH = 6
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
##
|
| 73 |
+
# Fatal include error.
|
| 74 |
+
|
| 75 |
+
class FatalIncludeError(etree.LxmlSyntaxError):
|
| 76 |
+
pass
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
class LimitedRecursiveIncludeError(FatalIncludeError):
|
| 80 |
+
pass
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
##
|
| 84 |
+
# ET compatible default loader.
|
| 85 |
+
# This loader reads an included resource from disk.
|
| 86 |
+
#
|
| 87 |
+
# @param href Resource reference.
|
| 88 |
+
# @param parse Parse mode. Either "xml" or "text".
|
| 89 |
+
# @param encoding Optional text encoding.
|
| 90 |
+
# @return The expanded resource. If the parse mode is "xml", this
|
| 91 |
+
# is an ElementTree instance. If the parse mode is "text", this
|
| 92 |
+
# is a Unicode string. If the loader fails, it can return None
|
| 93 |
+
# or raise an IOError exception.
|
| 94 |
+
# @throws IOError If the loader fails to load the resource.
|
| 95 |
+
|
| 96 |
+
def default_loader(href, parse, encoding=None):
|
| 97 |
+
file = open(href, 'rb')
|
| 98 |
+
if parse == "xml":
|
| 99 |
+
data = etree.parse(file).getroot()
|
| 100 |
+
else:
|
| 101 |
+
data = file.read()
|
| 102 |
+
if not encoding:
|
| 103 |
+
encoding = 'utf-8'
|
| 104 |
+
data = data.decode(encoding)
|
| 105 |
+
file.close()
|
| 106 |
+
return data
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
##
|
| 110 |
+
# Default loader used by lxml.etree - handles custom resolvers properly
|
| 111 |
+
#
|
| 112 |
+
|
| 113 |
+
def _lxml_default_loader(href, parse, encoding=None, parser=None):
|
| 114 |
+
if parse == "xml":
|
| 115 |
+
data = etree.parse(href, parser).getroot()
|
| 116 |
+
else:
|
| 117 |
+
if "://" in href:
|
| 118 |
+
f = urlopen(href)
|
| 119 |
+
else:
|
| 120 |
+
f = open(href, 'rb')
|
| 121 |
+
data = f.read()
|
| 122 |
+
f.close()
|
| 123 |
+
if not encoding:
|
| 124 |
+
encoding = 'utf-8'
|
| 125 |
+
data = data.decode(encoding)
|
| 126 |
+
return data
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
##
|
| 130 |
+
# Wrapper for ET compatibility - drops the parser
|
| 131 |
+
|
| 132 |
+
def _wrap_et_loader(loader):
|
| 133 |
+
def load(href, parse, encoding=None, parser=None):
|
| 134 |
+
return loader(href, parse, encoding)
|
| 135 |
+
return load
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
##
|
| 139 |
+
# Expand XInclude directives.
|
| 140 |
+
#
|
| 141 |
+
# @param elem Root element.
|
| 142 |
+
# @param loader Optional resource loader. If omitted, it defaults
|
| 143 |
+
# to {@link default_loader}. If given, it should be a callable
|
| 144 |
+
# that implements the same interface as <b>default_loader</b>.
|
| 145 |
+
# @param base_url The base URL of the original file, to resolve
|
| 146 |
+
# relative include file references.
|
| 147 |
+
# @param max_depth The maximum number of recursive inclusions.
|
| 148 |
+
# Limited to reduce the risk of malicious content explosion.
|
| 149 |
+
# Pass None to disable the limitation.
|
| 150 |
+
# @throws LimitedRecursiveIncludeError If the {@link max_depth} was exceeded.
|
| 151 |
+
# @throws FatalIncludeError If the function fails to include a given
|
| 152 |
+
# resource, or if the tree contains malformed XInclude elements.
|
| 153 |
+
# @throws IOError If the function fails to load a given resource.
|
| 154 |
+
# @returns the node or its replacement if it was an XInclude node
|
| 155 |
+
|
| 156 |
+
def include(elem, loader=None, base_url=None,
|
| 157 |
+
max_depth=DEFAULT_MAX_INCLUSION_DEPTH):
|
| 158 |
+
if max_depth is None:
|
| 159 |
+
max_depth = -1
|
| 160 |
+
elif max_depth < 0:
|
| 161 |
+
raise ValueError("expected non-negative depth or None for 'max_depth', got %r" % max_depth)
|
| 162 |
+
|
| 163 |
+
if base_url is None:
|
| 164 |
+
if hasattr(elem, 'getroot'):
|
| 165 |
+
tree = elem
|
| 166 |
+
elem = elem.getroot()
|
| 167 |
+
else:
|
| 168 |
+
tree = elem.getroottree()
|
| 169 |
+
if hasattr(tree, 'docinfo'):
|
| 170 |
+
base_url = tree.docinfo.URL
|
| 171 |
+
elif hasattr(elem, 'getroot'):
|
| 172 |
+
elem = elem.getroot()
|
| 173 |
+
_include(elem, loader, base_url, max_depth)
|
| 174 |
+
|
| 175 |
+
|
| 176 |
+
def _include(elem, loader=None, base_url=None,
|
| 177 |
+
max_depth=DEFAULT_MAX_INCLUSION_DEPTH, _parent_hrefs=None):
|
| 178 |
+
if loader is not None:
|
| 179 |
+
load_include = _wrap_et_loader(loader)
|
| 180 |
+
else:
|
| 181 |
+
load_include = _lxml_default_loader
|
| 182 |
+
|
| 183 |
+
if _parent_hrefs is None:
|
| 184 |
+
_parent_hrefs = set()
|
| 185 |
+
|
| 186 |
+
parser = elem.getroottree().parser
|
| 187 |
+
|
| 188 |
+
include_elements = list(
|
| 189 |
+
elem.iter(XINCLUDE_ITER_TAG))
|
| 190 |
+
|
| 191 |
+
for e in include_elements:
|
| 192 |
+
if e.tag == XINCLUDE_INCLUDE:
|
| 193 |
+
# process xinclude directive
|
| 194 |
+
href = urljoin(base_url, e.get("href"))
|
| 195 |
+
parse = e.get("parse", "xml")
|
| 196 |
+
parent = e.getparent()
|
| 197 |
+
if parse == "xml":
|
| 198 |
+
if href in _parent_hrefs:
|
| 199 |
+
raise FatalIncludeError(
|
| 200 |
+
"recursive include of %r detected" % href
|
| 201 |
+
)
|
| 202 |
+
if max_depth == 0:
|
| 203 |
+
raise LimitedRecursiveIncludeError(
|
| 204 |
+
"maximum xinclude depth reached when including file %s" % href)
|
| 205 |
+
node = load_include(href, parse, parser=parser)
|
| 206 |
+
if node is None:
|
| 207 |
+
raise FatalIncludeError(
|
| 208 |
+
"cannot load %r as %r" % (href, parse)
|
| 209 |
+
)
|
| 210 |
+
node = _include(node, loader, href, max_depth - 1, {href} | _parent_hrefs)
|
| 211 |
+
if e.tail:
|
| 212 |
+
node.tail = (node.tail or "") + e.tail
|
| 213 |
+
if parent is None:
|
| 214 |
+
return node # replaced the root node!
|
| 215 |
+
parent.replace(e, node)
|
| 216 |
+
elif parse == "text":
|
| 217 |
+
text = load_include(href, parse, encoding=e.get("encoding"))
|
| 218 |
+
if text is None:
|
| 219 |
+
raise FatalIncludeError(
|
| 220 |
+
"cannot load %r as %r" % (href, parse)
|
| 221 |
+
)
|
| 222 |
+
predecessor = e.getprevious()
|
| 223 |
+
if predecessor is not None:
|
| 224 |
+
predecessor.tail = (predecessor.tail or "") + text
|
| 225 |
+
elif parent is None:
|
| 226 |
+
return text # replaced the root node!
|
| 227 |
+
else:
|
| 228 |
+
parent.text = (parent.text or "") + text + (e.tail or "")
|
| 229 |
+
parent.remove(e)
|
| 230 |
+
else:
|
| 231 |
+
raise FatalIncludeError(
|
| 232 |
+
"unknown parse type in xi:include tag (%r)" % parse
|
| 233 |
+
)
|
| 234 |
+
elif e.tag == XINCLUDE_FALLBACK:
|
| 235 |
+
parent = e.getparent()
|
| 236 |
+
if parent is not None and parent.tag != XINCLUDE_INCLUDE:
|
| 237 |
+
raise FatalIncludeError(
|
| 238 |
+
"xi:fallback tag must be child of xi:include (%r)" % e.tag
|
| 239 |
+
)
|
| 240 |
+
else:
|
| 241 |
+
raise FatalIncludeError(
|
| 242 |
+
"Invalid element found in XInclude namespace (%r)" % e.tag
|
| 243 |
+
)
|
| 244 |
+
return elem
|
omnilmm/lib/python3.10/site-packages/lxml/__init__.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# this is a package
|
| 2 |
+
|
| 3 |
+
__version__ = "5.3.0"
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def get_include():
|
| 7 |
+
"""
|
| 8 |
+
Returns a list of header include paths (for lxml itself, libxml2
|
| 9 |
+
and libxslt) needed to compile C code against lxml if it was built
|
| 10 |
+
with statically linked libraries.
|
| 11 |
+
"""
|
| 12 |
+
import os
|
| 13 |
+
lxml_path = __path__[0]
|
| 14 |
+
include_path = os.path.join(lxml_path, 'includes')
|
| 15 |
+
includes = [include_path, lxml_path]
|
| 16 |
+
|
| 17 |
+
for name in os.listdir(include_path):
|
| 18 |
+
path = os.path.join(include_path, name)
|
| 19 |
+
if os.path.isdir(path):
|
| 20 |
+
includes.append(path)
|
| 21 |
+
|
| 22 |
+
return includes
|
omnilmm/lib/python3.10/site-packages/lxml/_elementpath.cpython-310-x86_64-linux-gnu.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9da6d33453bcf5ebc894842fbf7d7eeb497a7aea9abe51a0e49bf53f878647b1
|
| 3 |
+
size 209088
|
omnilmm/lib/python3.10/site-packages/lxml/_elementpath.py
ADDED
|
@@ -0,0 +1,341 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# cython: language_level=2
|
| 2 |
+
|
| 3 |
+
#
|
| 4 |
+
# ElementTree
|
| 5 |
+
# $Id: ElementPath.py 3375 2008-02-13 08:05:08Z fredrik $
|
| 6 |
+
#
|
| 7 |
+
# limited xpath support for element trees
|
| 8 |
+
#
|
| 9 |
+
# history:
|
| 10 |
+
# 2003-05-23 fl created
|
| 11 |
+
# 2003-05-28 fl added support for // etc
|
| 12 |
+
# 2003-08-27 fl fixed parsing of periods in element names
|
| 13 |
+
# 2007-09-10 fl new selection engine
|
| 14 |
+
# 2007-09-12 fl fixed parent selector
|
| 15 |
+
# 2007-09-13 fl added iterfind; changed findall to return a list
|
| 16 |
+
# 2007-11-30 fl added namespaces support
|
| 17 |
+
# 2009-10-30 fl added child element value filter
|
| 18 |
+
#
|
| 19 |
+
# Copyright (c) 2003-2009 by Fredrik Lundh. All rights reserved.
|
| 20 |
+
#
|
| 21 |
+
# fredrik@pythonware.com
|
| 22 |
+
# http://www.pythonware.com
|
| 23 |
+
#
|
| 24 |
+
# --------------------------------------------------------------------
|
| 25 |
+
# The ElementTree toolkit is
|
| 26 |
+
#
|
| 27 |
+
# Copyright (c) 1999-2009 by Fredrik Lundh
|
| 28 |
+
#
|
| 29 |
+
# By obtaining, using, and/or copying this software and/or its
|
| 30 |
+
# associated documentation, you agree that you have read, understood,
|
| 31 |
+
# and will comply with the following terms and conditions:
|
| 32 |
+
#
|
| 33 |
+
# Permission to use, copy, modify, and distribute this software and
|
| 34 |
+
# its associated documentation for any purpose and without fee is
|
| 35 |
+
# hereby granted, provided that the above copyright notice appears in
|
| 36 |
+
# all copies, and that both that copyright notice and this permission
|
| 37 |
+
# notice appear in supporting documentation, and that the name of
|
| 38 |
+
# Secret Labs AB or the author not be used in advertising or publicity
|
| 39 |
+
# pertaining to distribution of the software without specific, written
|
| 40 |
+
# prior permission.
|
| 41 |
+
#
|
| 42 |
+
# SECRET LABS AB AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
|
| 43 |
+
# TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT-
|
| 44 |
+
# ABILITY AND FITNESS. IN NO EVENT SHALL SECRET LABS AB OR THE AUTHOR
|
| 45 |
+
# BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
|
| 46 |
+
# DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 47 |
+
# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
| 48 |
+
# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 49 |
+
# OF THIS SOFTWARE.
|
| 50 |
+
# --------------------------------------------------------------------
|
| 51 |
+
|
| 52 |
+
##
|
| 53 |
+
# Implementation module for XPath support. There's usually no reason
|
| 54 |
+
# to import this module directly; the <b>ElementTree</b> does this for
|
| 55 |
+
# you, if needed.
|
| 56 |
+
##
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
import re
|
| 60 |
+
|
| 61 |
+
xpath_tokenizer_re = re.compile(
|
| 62 |
+
"("
|
| 63 |
+
"'[^']*'|\"[^\"]*\"|"
|
| 64 |
+
"::|"
|
| 65 |
+
"//?|"
|
| 66 |
+
r"\.\.|"
|
| 67 |
+
r"\(\)|"
|
| 68 |
+
r"[/.*:\[\]\(\)@=])|"
|
| 69 |
+
r"((?:\{[^}]+\})?[^/\[\]\(\)@=\s]+)|"
|
| 70 |
+
r"\s+"
|
| 71 |
+
)
|
| 72 |
+
|
| 73 |
+
def xpath_tokenizer(pattern, namespaces=None, with_prefixes=True):
|
| 74 |
+
# ElementTree uses '', lxml used None originally.
|
| 75 |
+
default_namespace = (namespaces.get(None) or namespaces.get('')) if namespaces else None
|
| 76 |
+
parsing_attribute = False
|
| 77 |
+
for token in xpath_tokenizer_re.findall(pattern):
|
| 78 |
+
ttype, tag = token
|
| 79 |
+
if tag and tag[0] != "{":
|
| 80 |
+
if ":" in tag and with_prefixes:
|
| 81 |
+
prefix, uri = tag.split(":", 1)
|
| 82 |
+
try:
|
| 83 |
+
if not namespaces:
|
| 84 |
+
raise KeyError
|
| 85 |
+
yield ttype, "{%s}%s" % (namespaces[prefix], uri)
|
| 86 |
+
except KeyError:
|
| 87 |
+
raise SyntaxError("prefix %r not found in prefix map" % prefix)
|
| 88 |
+
elif default_namespace and not parsing_attribute:
|
| 89 |
+
yield ttype, "{%s}%s" % (default_namespace, tag)
|
| 90 |
+
else:
|
| 91 |
+
yield token
|
| 92 |
+
parsing_attribute = False
|
| 93 |
+
else:
|
| 94 |
+
yield token
|
| 95 |
+
parsing_attribute = ttype == '@'
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
def prepare_child(next, token):
|
| 99 |
+
tag = token[1]
|
| 100 |
+
def select(result):
|
| 101 |
+
for elem in result:
|
| 102 |
+
yield from elem.iterchildren(tag)
|
| 103 |
+
return select
|
| 104 |
+
|
| 105 |
+
def prepare_star(next, token):
|
| 106 |
+
def select(result):
|
| 107 |
+
for elem in result:
|
| 108 |
+
yield from elem.iterchildren('*')
|
| 109 |
+
return select
|
| 110 |
+
|
| 111 |
+
def prepare_self(next, token):
|
| 112 |
+
def select(result):
|
| 113 |
+
return result
|
| 114 |
+
return select
|
| 115 |
+
|
| 116 |
+
def prepare_descendant(next, token):
|
| 117 |
+
token = next()
|
| 118 |
+
if token[0] == "*":
|
| 119 |
+
tag = "*"
|
| 120 |
+
elif not token[0]:
|
| 121 |
+
tag = token[1]
|
| 122 |
+
else:
|
| 123 |
+
raise SyntaxError("invalid descendant")
|
| 124 |
+
def select(result):
|
| 125 |
+
for elem in result:
|
| 126 |
+
yield from elem.iterdescendants(tag)
|
| 127 |
+
return select
|
| 128 |
+
|
| 129 |
+
def prepare_parent(next, token):
|
| 130 |
+
def select(result):
|
| 131 |
+
for elem in result:
|
| 132 |
+
parent = elem.getparent()
|
| 133 |
+
if parent is not None:
|
| 134 |
+
yield parent
|
| 135 |
+
return select
|
| 136 |
+
|
| 137 |
+
def prepare_predicate(next, token):
|
| 138 |
+
# FIXME: replace with real parser!!! refs:
|
| 139 |
+
# http://effbot.org/zone/simple-iterator-parser.htm
|
| 140 |
+
# http://javascript.crockford.com/tdop/tdop.html
|
| 141 |
+
signature = ''
|
| 142 |
+
predicate = []
|
| 143 |
+
while 1:
|
| 144 |
+
token = next()
|
| 145 |
+
if token[0] == "]":
|
| 146 |
+
break
|
| 147 |
+
if token == ('', ''):
|
| 148 |
+
# ignore whitespace
|
| 149 |
+
continue
|
| 150 |
+
if token[0] and token[0][:1] in "'\"":
|
| 151 |
+
token = "'", token[0][1:-1]
|
| 152 |
+
signature += token[0] or "-"
|
| 153 |
+
predicate.append(token[1])
|
| 154 |
+
|
| 155 |
+
# use signature to determine predicate type
|
| 156 |
+
if signature == "@-":
|
| 157 |
+
# [@attribute] predicate
|
| 158 |
+
key = predicate[1]
|
| 159 |
+
def select(result):
|
| 160 |
+
for elem in result:
|
| 161 |
+
if elem.get(key) is not None:
|
| 162 |
+
yield elem
|
| 163 |
+
return select
|
| 164 |
+
if signature == "@-='":
|
| 165 |
+
# [@attribute='value']
|
| 166 |
+
key = predicate[1]
|
| 167 |
+
value = predicate[-1]
|
| 168 |
+
def select(result):
|
| 169 |
+
for elem in result:
|
| 170 |
+
if elem.get(key) == value:
|
| 171 |
+
yield elem
|
| 172 |
+
return select
|
| 173 |
+
if signature == "-" and not re.match(r"-?\d+$", predicate[0]):
|
| 174 |
+
# [tag]
|
| 175 |
+
tag = predicate[0]
|
| 176 |
+
def select(result):
|
| 177 |
+
for elem in result:
|
| 178 |
+
for _ in elem.iterchildren(tag):
|
| 179 |
+
yield elem
|
| 180 |
+
break
|
| 181 |
+
return select
|
| 182 |
+
if signature == ".='" or (signature == "-='" and not re.match(r"-?\d+$", predicate[0])):
|
| 183 |
+
# [.='value'] or [tag='value']
|
| 184 |
+
tag = predicate[0]
|
| 185 |
+
value = predicate[-1]
|
| 186 |
+
if tag:
|
| 187 |
+
def select(result):
|
| 188 |
+
for elem in result:
|
| 189 |
+
for e in elem.iterchildren(tag):
|
| 190 |
+
if "".join(e.itertext()) == value:
|
| 191 |
+
yield elem
|
| 192 |
+
break
|
| 193 |
+
else:
|
| 194 |
+
def select(result):
|
| 195 |
+
for elem in result:
|
| 196 |
+
if "".join(elem.itertext()) == value:
|
| 197 |
+
yield elem
|
| 198 |
+
return select
|
| 199 |
+
if signature == "-" or signature == "-()" or signature == "-()-":
|
| 200 |
+
# [index] or [last()] or [last()-index]
|
| 201 |
+
if signature == "-":
|
| 202 |
+
# [index]
|
| 203 |
+
index = int(predicate[0]) - 1
|
| 204 |
+
if index < 0:
|
| 205 |
+
if index == -1:
|
| 206 |
+
raise SyntaxError(
|
| 207 |
+
"indices in path predicates are 1-based, not 0-based")
|
| 208 |
+
else:
|
| 209 |
+
raise SyntaxError("path index >= 1 expected")
|
| 210 |
+
else:
|
| 211 |
+
if predicate[0] != "last":
|
| 212 |
+
raise SyntaxError("unsupported function")
|
| 213 |
+
if signature == "-()-":
|
| 214 |
+
try:
|
| 215 |
+
index = int(predicate[2]) - 1
|
| 216 |
+
except ValueError:
|
| 217 |
+
raise SyntaxError("unsupported expression")
|
| 218 |
+
else:
|
| 219 |
+
index = -1
|
| 220 |
+
def select(result):
|
| 221 |
+
for elem in result:
|
| 222 |
+
parent = elem.getparent()
|
| 223 |
+
if parent is None:
|
| 224 |
+
continue
|
| 225 |
+
try:
|
| 226 |
+
# FIXME: what if the selector is "*" ?
|
| 227 |
+
elems = list(parent.iterchildren(elem.tag))
|
| 228 |
+
if elems[index] is elem:
|
| 229 |
+
yield elem
|
| 230 |
+
except IndexError:
|
| 231 |
+
pass
|
| 232 |
+
return select
|
| 233 |
+
raise SyntaxError("invalid predicate")
|
| 234 |
+
|
| 235 |
+
ops = {
|
| 236 |
+
"": prepare_child,
|
| 237 |
+
"*": prepare_star,
|
| 238 |
+
".": prepare_self,
|
| 239 |
+
"..": prepare_parent,
|
| 240 |
+
"//": prepare_descendant,
|
| 241 |
+
"[": prepare_predicate,
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
|
| 245 |
+
# --------------------------------------------------------------------
|
| 246 |
+
|
| 247 |
+
_cache = {}
|
| 248 |
+
|
| 249 |
+
|
| 250 |
+
def _build_path_iterator(path, namespaces, with_prefixes=True):
|
| 251 |
+
"""compile selector pattern"""
|
| 252 |
+
if path[-1:] == "/":
|
| 253 |
+
path += "*" # implicit all (FIXME: keep this?)
|
| 254 |
+
|
| 255 |
+
cache_key = (path,)
|
| 256 |
+
if namespaces:
|
| 257 |
+
# lxml originally used None for the default namespace but ElementTree uses the
|
| 258 |
+
# more convenient (all-strings-dict) empty string, so we support both here,
|
| 259 |
+
# preferring the more convenient '', as long as they aren't ambiguous.
|
| 260 |
+
if None in namespaces:
|
| 261 |
+
if '' in namespaces and namespaces[None] != namespaces['']:
|
| 262 |
+
raise ValueError("Ambiguous default namespace provided: %r versus %r" % (
|
| 263 |
+
namespaces[None], namespaces['']))
|
| 264 |
+
cache_key += (namespaces[None],) + tuple(sorted(
|
| 265 |
+
item for item in namespaces.items() if item[0] is not None))
|
| 266 |
+
else:
|
| 267 |
+
cache_key += tuple(sorted(namespaces.items()))
|
| 268 |
+
|
| 269 |
+
try:
|
| 270 |
+
return _cache[cache_key]
|
| 271 |
+
except KeyError:
|
| 272 |
+
pass
|
| 273 |
+
if len(_cache) > 100:
|
| 274 |
+
_cache.clear()
|
| 275 |
+
|
| 276 |
+
if path[:1] == "/":
|
| 277 |
+
raise SyntaxError("cannot use absolute path on element")
|
| 278 |
+
stream = iter(xpath_tokenizer(path, namespaces, with_prefixes=with_prefixes))
|
| 279 |
+
try:
|
| 280 |
+
_next = stream.next
|
| 281 |
+
except AttributeError:
|
| 282 |
+
# Python 3
|
| 283 |
+
_next = stream.__next__
|
| 284 |
+
try:
|
| 285 |
+
token = _next()
|
| 286 |
+
except StopIteration:
|
| 287 |
+
raise SyntaxError("empty path expression")
|
| 288 |
+
selector = []
|
| 289 |
+
while 1:
|
| 290 |
+
try:
|
| 291 |
+
selector.append(ops[token[0]](_next, token))
|
| 292 |
+
except StopIteration:
|
| 293 |
+
raise SyntaxError("invalid path")
|
| 294 |
+
try:
|
| 295 |
+
token = _next()
|
| 296 |
+
if token[0] == "/":
|
| 297 |
+
token = _next()
|
| 298 |
+
except StopIteration:
|
| 299 |
+
break
|
| 300 |
+
_cache[cache_key] = selector
|
| 301 |
+
return selector
|
| 302 |
+
|
| 303 |
+
|
| 304 |
+
##
|
| 305 |
+
# Iterate over the matching nodes
|
| 306 |
+
|
| 307 |
+
def iterfind(elem, path, namespaces=None, with_prefixes=True):
|
| 308 |
+
selector = _build_path_iterator(path, namespaces, with_prefixes=with_prefixes)
|
| 309 |
+
result = iter((elem,))
|
| 310 |
+
for select in selector:
|
| 311 |
+
result = select(result)
|
| 312 |
+
return result
|
| 313 |
+
|
| 314 |
+
|
| 315 |
+
##
|
| 316 |
+
# Find first matching object.
|
| 317 |
+
|
| 318 |
+
def find(elem, path, namespaces=None, with_prefixes=True):
|
| 319 |
+
it = iterfind(elem, path, namespaces, with_prefixes=with_prefixes)
|
| 320 |
+
try:
|
| 321 |
+
return next(it)
|
| 322 |
+
except StopIteration:
|
| 323 |
+
return None
|
| 324 |
+
|
| 325 |
+
|
| 326 |
+
##
|
| 327 |
+
# Find all matching objects.
|
| 328 |
+
|
| 329 |
+
def findall(elem, path, namespaces=None, with_prefixes=True):
|
| 330 |
+
return list(iterfind(elem, path, namespaces))
|
| 331 |
+
|
| 332 |
+
|
| 333 |
+
##
|
| 334 |
+
# Find text for first matching object.
|
| 335 |
+
|
| 336 |
+
def findtext(elem, path, default=None, namespaces=None, with_prefixes=True):
|
| 337 |
+
el = find(elem, path, namespaces, with_prefixes=with_prefixes)
|
| 338 |
+
if el is None:
|
| 339 |
+
return default
|
| 340 |
+
else:
|
| 341 |
+
return el.text or ''
|
omnilmm/lib/python3.10/site-packages/lxml/apihelpers.pxi
ADDED
|
@@ -0,0 +1,1793 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
| 1 |
+
# Private/public helper functions for API functions
|
| 2 |
+
|
| 3 |
+
from lxml.includes cimport uri
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
cdef void displayNode(xmlNode* c_node, indent) noexcept:
|
| 7 |
+
# to help with debugging
|
| 8 |
+
cdef xmlNode* c_child
|
| 9 |
+
try:
|
| 10 |
+
print(indent * ' ', <long>c_node)
|
| 11 |
+
c_child = c_node.children
|
| 12 |
+
while c_child is not NULL:
|
| 13 |
+
displayNode(c_child, indent + 1)
|
| 14 |
+
c_child = c_child.next
|
| 15 |
+
finally:
|
| 16 |
+
return # swallow any exceptions
|
| 17 |
+
|
| 18 |
+
cdef inline bint _isHtmlDocument(_Element element) except -1:
|
| 19 |
+
cdef xmlNode* c_node = element._c_node
|
| 20 |
+
return (
|
| 21 |
+
c_node is not NULL and c_node.doc is not NULL and
|
| 22 |
+
c_node.doc.properties & tree.XML_DOC_HTML != 0
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
+
cdef inline int _assertValidNode(_Element element) except -1:
|
| 26 |
+
assert element._c_node is not NULL, "invalid Element proxy at %s" % id(element)
|
| 27 |
+
|
| 28 |
+
cdef inline int _assertValidDoc(_Document doc) except -1:
|
| 29 |
+
assert doc._c_doc is not NULL, "invalid Document proxy at %s" % id(doc)
|
| 30 |
+
|
| 31 |
+
cdef _Document _documentOrRaise(object input):
|
| 32 |
+
"""Call this to get the document of a _Document, _ElementTree or _Element
|
| 33 |
+
object, or to raise an exception if it can't be determined.
|
| 34 |
+
|
| 35 |
+
Should be used in all API functions for consistency.
|
| 36 |
+
"""
|
| 37 |
+
cdef _Document doc
|
| 38 |
+
if isinstance(input, _ElementTree):
|
| 39 |
+
if (<_ElementTree>input)._context_node is not None:
|
| 40 |
+
doc = (<_ElementTree>input)._context_node._doc
|
| 41 |
+
else:
|
| 42 |
+
doc = None
|
| 43 |
+
elif isinstance(input, _Element):
|
| 44 |
+
doc = (<_Element>input)._doc
|
| 45 |
+
elif isinstance(input, _Document):
|
| 46 |
+
doc = <_Document>input
|
| 47 |
+
else:
|
| 48 |
+
raise TypeError, f"Invalid input object: {python._fqtypename(input).decode('utf8')}"
|
| 49 |
+
if doc is None:
|
| 50 |
+
raise ValueError, f"Input object has no document: {python._fqtypename(input).decode('utf8')}"
|
| 51 |
+
_assertValidDoc(doc)
|
| 52 |
+
return doc
|
| 53 |
+
|
| 54 |
+
cdef _Element _rootNodeOrRaise(object input):
|
| 55 |
+
"""Call this to get the root node of a _Document, _ElementTree or
|
| 56 |
+
_Element object, or to raise an exception if it can't be determined.
|
| 57 |
+
|
| 58 |
+
Should be used in all API functions for consistency.
|
| 59 |
+
"""
|
| 60 |
+
cdef _Element node
|
| 61 |
+
if isinstance(input, _ElementTree):
|
| 62 |
+
node = (<_ElementTree>input)._context_node
|
| 63 |
+
elif isinstance(input, _Element):
|
| 64 |
+
node = <_Element>input
|
| 65 |
+
elif isinstance(input, _Document):
|
| 66 |
+
node = (<_Document>input).getroot()
|
| 67 |
+
else:
|
| 68 |
+
raise TypeError, f"Invalid input object: {python._fqtypename(input).decode('utf8')}"
|
| 69 |
+
if (node is None or not node._c_node or
|
| 70 |
+
node._c_node.type != tree.XML_ELEMENT_NODE):
|
| 71 |
+
raise ValueError, f"Input object is not an XML element: {python._fqtypename(input).decode('utf8')}"
|
| 72 |
+
_assertValidNode(node)
|
| 73 |
+
return node
|
| 74 |
+
|
| 75 |
+
cdef bint _isAncestorOrSame(xmlNode* c_ancestor, xmlNode* c_node) noexcept:
|
| 76 |
+
while c_node:
|
| 77 |
+
if c_node is c_ancestor:
|
| 78 |
+
return True
|
| 79 |
+
c_node = c_node.parent
|
| 80 |
+
return False
|
| 81 |
+
|
| 82 |
+
cdef _Element _makeElement(tag, xmlDoc* c_doc, _Document doc,
|
| 83 |
+
_BaseParser parser, text, tail, attrib, nsmap,
|
| 84 |
+
dict extra_attrs):
|
| 85 |
+
"""Create a new element and initialize text content, namespaces and
|
| 86 |
+
attributes.
|
| 87 |
+
|
| 88 |
+
This helper function will reuse as much of the existing document as
|
| 89 |
+
possible:
|
| 90 |
+
|
| 91 |
+
If 'parser' is None, the parser will be inherited from 'doc' or the
|
| 92 |
+
default parser will be used.
|
| 93 |
+
|
| 94 |
+
If 'doc' is None, 'c_doc' is used to create a new _Document and the new
|
| 95 |
+
element is made its root node.
|
| 96 |
+
|
| 97 |
+
If 'c_doc' is also NULL, a new xmlDoc will be created.
|
| 98 |
+
"""
|
| 99 |
+
cdef xmlNode* c_node
|
| 100 |
+
if doc is not None:
|
| 101 |
+
c_doc = doc._c_doc
|
| 102 |
+
ns_utf, name_utf = _getNsTag(tag)
|
| 103 |
+
if parser is not None and parser._for_html:
|
| 104 |
+
_htmlTagValidOrRaise(name_utf)
|
| 105 |
+
if c_doc is NULL:
|
| 106 |
+
c_doc = _newHTMLDoc()
|
| 107 |
+
else:
|
| 108 |
+
_tagValidOrRaise(name_utf)
|
| 109 |
+
if c_doc is NULL:
|
| 110 |
+
c_doc = _newXMLDoc()
|
| 111 |
+
c_node = _createElement(c_doc, name_utf)
|
| 112 |
+
if c_node is NULL:
|
| 113 |
+
if doc is None and c_doc is not NULL:
|
| 114 |
+
tree.xmlFreeDoc(c_doc)
|
| 115 |
+
raise MemoryError()
|
| 116 |
+
try:
|
| 117 |
+
if doc is None:
|
| 118 |
+
tree.xmlDocSetRootElement(c_doc, c_node)
|
| 119 |
+
doc = _documentFactory(c_doc, parser)
|
| 120 |
+
if text is not None:
|
| 121 |
+
_setNodeText(c_node, text)
|
| 122 |
+
if tail is not None:
|
| 123 |
+
_setTailText(c_node, tail)
|
| 124 |
+
# add namespaces to node if necessary
|
| 125 |
+
_setNodeNamespaces(c_node, doc, ns_utf, nsmap)
|
| 126 |
+
_initNodeAttributes(c_node, doc, attrib, extra_attrs)
|
| 127 |
+
return _elementFactory(doc, c_node)
|
| 128 |
+
except:
|
| 129 |
+
# free allocated c_node/c_doc unless Python does it for us
|
| 130 |
+
if c_node.doc is not c_doc:
|
| 131 |
+
# node not yet in document => will not be freed by document
|
| 132 |
+
if tail is not None:
|
| 133 |
+
_removeText(c_node.next) # tail
|
| 134 |
+
tree.xmlFreeNode(c_node)
|
| 135 |
+
if doc is None:
|
| 136 |
+
# c_doc will not be freed by doc
|
| 137 |
+
tree.xmlFreeDoc(c_doc)
|
| 138 |
+
raise
|
| 139 |
+
|
| 140 |
+
cdef int _initNewElement(_Element element, bint is_html, name_utf, ns_utf,
|
| 141 |
+
_BaseParser parser, attrib, nsmap, dict extra_attrs) except -1:
|
| 142 |
+
"""Initialise a new Element object.
|
| 143 |
+
|
| 144 |
+
This is used when users instantiate a Python Element subclass
|
| 145 |
+
directly, without it being mapped to an existing XML node.
|
| 146 |
+
"""
|
| 147 |
+
cdef xmlDoc* c_doc
|
| 148 |
+
cdef xmlNode* c_node
|
| 149 |
+
cdef _Document doc
|
| 150 |
+
if is_html:
|
| 151 |
+
_htmlTagValidOrRaise(name_utf)
|
| 152 |
+
c_doc = _newHTMLDoc()
|
| 153 |
+
else:
|
| 154 |
+
_tagValidOrRaise(name_utf)
|
| 155 |
+
c_doc = _newXMLDoc()
|
| 156 |
+
c_node = _createElement(c_doc, name_utf)
|
| 157 |
+
if c_node is NULL:
|
| 158 |
+
if c_doc is not NULL:
|
| 159 |
+
tree.xmlFreeDoc(c_doc)
|
| 160 |
+
raise MemoryError()
|
| 161 |
+
tree.xmlDocSetRootElement(c_doc, c_node)
|
| 162 |
+
doc = _documentFactory(c_doc, parser)
|
| 163 |
+
# add namespaces to node if necessary
|
| 164 |
+
_setNodeNamespaces(c_node, doc, ns_utf, nsmap)
|
| 165 |
+
_initNodeAttributes(c_node, doc, attrib, extra_attrs)
|
| 166 |
+
_registerProxy(element, doc, c_node)
|
| 167 |
+
element._init()
|
| 168 |
+
return 0
|
| 169 |
+
|
| 170 |
+
cdef _Element _makeSubElement(_Element parent, tag, text, tail,
|
| 171 |
+
attrib, nsmap, dict extra_attrs):
|
| 172 |
+
"""Create a new child element and initialize text content, namespaces and
|
| 173 |
+
attributes.
|
| 174 |
+
"""
|
| 175 |
+
cdef xmlNode* c_node
|
| 176 |
+
cdef xmlDoc* c_doc
|
| 177 |
+
if parent is None or parent._doc is None:
|
| 178 |
+
return None
|
| 179 |
+
_assertValidNode(parent)
|
| 180 |
+
ns_utf, name_utf = _getNsTag(tag)
|
| 181 |
+
c_doc = parent._doc._c_doc
|
| 182 |
+
|
| 183 |
+
if parent._doc._parser is not None and parent._doc._parser._for_html:
|
| 184 |
+
_htmlTagValidOrRaise(name_utf)
|
| 185 |
+
else:
|
| 186 |
+
_tagValidOrRaise(name_utf)
|
| 187 |
+
|
| 188 |
+
c_node = _createElement(c_doc, name_utf)
|
| 189 |
+
if c_node is NULL:
|
| 190 |
+
raise MemoryError()
|
| 191 |
+
tree.xmlAddChild(parent._c_node, c_node)
|
| 192 |
+
|
| 193 |
+
try:
|
| 194 |
+
if text is not None:
|
| 195 |
+
_setNodeText(c_node, text)
|
| 196 |
+
if tail is not None:
|
| 197 |
+
_setTailText(c_node, tail)
|
| 198 |
+
|
| 199 |
+
# add namespaces to node if necessary
|
| 200 |
+
_setNodeNamespaces(c_node, parent._doc, ns_utf, nsmap)
|
| 201 |
+
_initNodeAttributes(c_node, parent._doc, attrib, extra_attrs)
|
| 202 |
+
return _elementFactory(parent._doc, c_node)
|
| 203 |
+
except:
|
| 204 |
+
# make sure we clean up in case of an error
|
| 205 |
+
_removeNode(parent._doc, c_node)
|
| 206 |
+
raise
|
| 207 |
+
|
| 208 |
+
|
| 209 |
+
cdef int _setNodeNamespaces(xmlNode* c_node, _Document doc,
|
| 210 |
+
object node_ns_utf, object nsmap) except -1:
|
| 211 |
+
"""Lookup current namespace prefixes, then set namespace structure for
|
| 212 |
+
node (if 'node_ns_utf' was provided) and register new ns-prefix mappings.
|
| 213 |
+
|
| 214 |
+
'node_ns_utf' should only be passed for a newly created node.
|
| 215 |
+
"""
|
| 216 |
+
cdef xmlNs* c_ns
|
| 217 |
+
cdef list nsdefs
|
| 218 |
+
|
| 219 |
+
if nsmap:
|
| 220 |
+
for prefix, href in _iter_nsmap(nsmap):
|
| 221 |
+
href_utf = _utf8(href)
|
| 222 |
+
_uriValidOrRaise(href_utf)
|
| 223 |
+
c_href = _xcstr(href_utf)
|
| 224 |
+
if prefix is not None:
|
| 225 |
+
prefix_utf = _utf8(prefix)
|
| 226 |
+
_prefixValidOrRaise(prefix_utf)
|
| 227 |
+
c_prefix = _xcstr(prefix_utf)
|
| 228 |
+
else:
|
| 229 |
+
c_prefix = <const_xmlChar*>NULL
|
| 230 |
+
# add namespace with prefix if it is not already known
|
| 231 |
+
c_ns = tree.xmlSearchNs(doc._c_doc, c_node, c_prefix)
|
| 232 |
+
if c_ns is NULL or \
|
| 233 |
+
c_ns.href is NULL or \
|
| 234 |
+
tree.xmlStrcmp(c_ns.href, c_href) != 0:
|
| 235 |
+
c_ns = tree.xmlNewNs(c_node, c_href, c_prefix)
|
| 236 |
+
if href_utf == node_ns_utf:
|
| 237 |
+
tree.xmlSetNs(c_node, c_ns)
|
| 238 |
+
node_ns_utf = None
|
| 239 |
+
|
| 240 |
+
if node_ns_utf is not None:
|
| 241 |
+
_uriValidOrRaise(node_ns_utf)
|
| 242 |
+
doc._setNodeNs(c_node, _xcstr(node_ns_utf))
|
| 243 |
+
return 0
|
| 244 |
+
|
| 245 |
+
|
| 246 |
+
cdef dict _build_nsmap(xmlNode* c_node):
|
| 247 |
+
"""
|
| 248 |
+
Namespace prefix->URI mapping known in the context of this Element.
|
| 249 |
+
This includes all namespace declarations of the parents.
|
| 250 |
+
"""
|
| 251 |
+
cdef xmlNs* c_ns
|
| 252 |
+
nsmap = {}
|
| 253 |
+
while c_node is not NULL and c_node.type == tree.XML_ELEMENT_NODE:
|
| 254 |
+
c_ns = c_node.nsDef
|
| 255 |
+
while c_ns is not NULL:
|
| 256 |
+
if c_ns.prefix or c_ns.href:
|
| 257 |
+
prefix = funicodeOrNone(c_ns.prefix)
|
| 258 |
+
if prefix not in nsmap:
|
| 259 |
+
nsmap[prefix] = funicodeOrNone(c_ns.href)
|
| 260 |
+
c_ns = c_ns.next
|
| 261 |
+
c_node = c_node.parent
|
| 262 |
+
return nsmap
|
| 263 |
+
|
| 264 |
+
|
| 265 |
+
cdef _iter_nsmap(nsmap):
|
| 266 |
+
"""
|
| 267 |
+
Create a reproducibly ordered iterable from an nsmap mapping.
|
| 268 |
+
Tries to preserve an existing order and sorts if it assumes no order.
|
| 269 |
+
|
| 270 |
+
The difference to _iter_attrib() is that None doesn't sort with strings
|
| 271 |
+
in Py3.x.
|
| 272 |
+
"""
|
| 273 |
+
if isinstance(nsmap, dict):
|
| 274 |
+
# dicts are insertion-ordered in Py3.6+ => keep the user provided order.
|
| 275 |
+
return nsmap.items()
|
| 276 |
+
if len(nsmap) <= 1:
|
| 277 |
+
return nsmap.items()
|
| 278 |
+
# nsmap will usually be a plain unordered dict => avoid type checking overhead
|
| 279 |
+
if type(nsmap) is not dict and isinstance(nsmap, OrderedDict):
|
| 280 |
+
return nsmap.items() # keep existing order
|
| 281 |
+
if None not in nsmap:
|
| 282 |
+
return sorted(nsmap.items())
|
| 283 |
+
|
| 284 |
+
# Move the default namespace to the end. This makes sure libxml2
|
| 285 |
+
# prefers a prefix if the ns is defined redundantly on the same
|
| 286 |
+
# element. That way, users can work around a problem themselves
|
| 287 |
+
# where default namespace attributes on non-default namespaced
|
| 288 |
+
# elements serialise without prefix (i.e. into the non-default
|
| 289 |
+
# namespace).
|
| 290 |
+
default_ns = nsmap[None]
|
| 291 |
+
nsdefs = [(k, v) for k, v in nsmap.items() if k is not None]
|
| 292 |
+
nsdefs.sort()
|
| 293 |
+
nsdefs.append((None, default_ns))
|
| 294 |
+
return nsdefs
|
| 295 |
+
|
| 296 |
+
|
| 297 |
+
cdef _iter_attrib(attrib):
|
| 298 |
+
"""
|
| 299 |
+
Create a reproducibly ordered iterable from an attrib mapping.
|
| 300 |
+
Tries to preserve an existing order and sorts if it assumes no order.
|
| 301 |
+
"""
|
| 302 |
+
# dicts are insertion-ordered in Py3.6+ => keep the user provided order.
|
| 303 |
+
if isinstance(attrib, (dict, _Attrib, OrderedDict)):
|
| 304 |
+
return attrib.items()
|
| 305 |
+
# assume it's an unordered mapping of some kind
|
| 306 |
+
return sorted(attrib.items())
|
| 307 |
+
|
| 308 |
+
|
| 309 |
+
cdef _initNodeAttributes(xmlNode* c_node, _Document doc, attrib, dict extra):
|
| 310 |
+
"""Initialise the attributes of an element node.
|
| 311 |
+
"""
|
| 312 |
+
cdef bint is_html
|
| 313 |
+
cdef xmlNs* c_ns
|
| 314 |
+
if attrib is not None and not hasattr(attrib, 'items'):
|
| 315 |
+
raise TypeError, f"Invalid attribute dictionary: {python._fqtypename(attrib).decode('utf8')}"
|
| 316 |
+
if not attrib and not extra:
|
| 317 |
+
return # nothing to do
|
| 318 |
+
is_html = doc._parser._for_html
|
| 319 |
+
seen = set()
|
| 320 |
+
if extra:
|
| 321 |
+
for name, value in extra.items():
|
| 322 |
+
_addAttributeToNode(c_node, doc, is_html, name, value, seen)
|
| 323 |
+
if attrib:
|
| 324 |
+
for name, value in _iter_attrib(attrib):
|
| 325 |
+
_addAttributeToNode(c_node, doc, is_html, name, value, seen)
|
| 326 |
+
|
| 327 |
+
|
| 328 |
+
cdef int _addAttributeToNode(xmlNode* c_node, _Document doc, bint is_html,
|
| 329 |
+
name, value, set seen_tags) except -1:
|
| 330 |
+
ns_utf, name_utf = tag = _getNsTag(name)
|
| 331 |
+
if tag in seen_tags:
|
| 332 |
+
return 0
|
| 333 |
+
seen_tags.add(tag)
|
| 334 |
+
if not is_html:
|
| 335 |
+
_attributeValidOrRaise(name_utf)
|
| 336 |
+
value_utf = _utf8(value)
|
| 337 |
+
if ns_utf is None:
|
| 338 |
+
tree.xmlNewProp(c_node, _xcstr(name_utf), _xcstr(value_utf))
|
| 339 |
+
else:
|
| 340 |
+
_uriValidOrRaise(ns_utf)
|
| 341 |
+
c_ns = doc._findOrBuildNodeNs(c_node, _xcstr(ns_utf), NULL, 1)
|
| 342 |
+
tree.xmlNewNsProp(c_node, c_ns,
|
| 343 |
+
_xcstr(name_utf), _xcstr(value_utf))
|
| 344 |
+
return 0
|
| 345 |
+
|
| 346 |
+
|
| 347 |
+
ctypedef struct _ns_node_ref:
|
| 348 |
+
xmlNs* ns
|
| 349 |
+
xmlNode* node
|
| 350 |
+
|
| 351 |
+
|
| 352 |
+
cdef int _collectNsDefs(xmlNode* c_element, _ns_node_ref **_c_ns_list,
|
| 353 |
+
size_t *_c_ns_list_len, size_t *_c_ns_list_size) except -1:
|
| 354 |
+
c_ns_list = _c_ns_list[0]
|
| 355 |
+
cdef size_t c_ns_list_len = _c_ns_list_len[0]
|
| 356 |
+
cdef size_t c_ns_list_size = _c_ns_list_size[0]
|
| 357 |
+
|
| 358 |
+
c_nsdef = c_element.nsDef
|
| 359 |
+
while c_nsdef is not NULL:
|
| 360 |
+
if c_ns_list_len >= c_ns_list_size:
|
| 361 |
+
if c_ns_list is NULL:
|
| 362 |
+
c_ns_list_size = 20
|
| 363 |
+
else:
|
| 364 |
+
c_ns_list_size *= 2
|
| 365 |
+
c_nsref_ptr = <_ns_node_ref*> python.lxml_realloc(
|
| 366 |
+
c_ns_list, c_ns_list_size, sizeof(_ns_node_ref))
|
| 367 |
+
if c_nsref_ptr is NULL:
|
| 368 |
+
if c_ns_list is not NULL:
|
| 369 |
+
python.lxml_free(c_ns_list)
|
| 370 |
+
_c_ns_list[0] = NULL
|
| 371 |
+
raise MemoryError()
|
| 372 |
+
c_ns_list = c_nsref_ptr
|
| 373 |
+
|
| 374 |
+
c_ns_list[c_ns_list_len] = _ns_node_ref(c_nsdef, c_element)
|
| 375 |
+
c_ns_list_len += 1
|
| 376 |
+
c_nsdef = c_nsdef.next
|
| 377 |
+
|
| 378 |
+
_c_ns_list_size[0] = c_ns_list_size
|
| 379 |
+
_c_ns_list_len[0] = c_ns_list_len
|
| 380 |
+
_c_ns_list[0] = c_ns_list
|
| 381 |
+
|
| 382 |
+
|
| 383 |
+
cdef int _removeUnusedNamespaceDeclarations(xmlNode* c_element, set prefixes_to_keep) except -1:
|
| 384 |
+
"""Remove any namespace declarations from a subtree that are not used by
|
| 385 |
+
any of its elements (or attributes).
|
| 386 |
+
|
| 387 |
+
If a 'prefixes_to_keep' is provided, it must be a set of prefixes.
|
| 388 |
+
Any corresponding namespace mappings will not be removed as part of the cleanup.
|
| 389 |
+
"""
|
| 390 |
+
cdef xmlNode* c_node
|
| 391 |
+
cdef _ns_node_ref* c_ns_list = NULL
|
| 392 |
+
cdef size_t c_ns_list_size = 0
|
| 393 |
+
cdef size_t c_ns_list_len = 0
|
| 394 |
+
cdef size_t i
|
| 395 |
+
|
| 396 |
+
if c_element.parent and c_element.parent.type == tree.XML_DOCUMENT_NODE:
|
| 397 |
+
# include declarations on the document node
|
| 398 |
+
_collectNsDefs(c_element.parent, &c_ns_list, &c_ns_list_len, &c_ns_list_size)
|
| 399 |
+
|
| 400 |
+
tree.BEGIN_FOR_EACH_ELEMENT_FROM(c_element, c_element, 1)
|
| 401 |
+
# collect all new namespace declarations into the ns list
|
| 402 |
+
if c_element.nsDef:
|
| 403 |
+
_collectNsDefs(c_element, &c_ns_list, &c_ns_list_len, &c_ns_list_size)
|
| 404 |
+
|
| 405 |
+
# remove all namespace declarations from the list that are referenced
|
| 406 |
+
if c_ns_list_len and c_element.type == tree.XML_ELEMENT_NODE:
|
| 407 |
+
c_node = c_element
|
| 408 |
+
while c_node and c_ns_list_len:
|
| 409 |
+
if c_node.ns:
|
| 410 |
+
for i in range(c_ns_list_len):
|
| 411 |
+
if c_node.ns is c_ns_list[i].ns:
|
| 412 |
+
c_ns_list_len -= 1
|
| 413 |
+
c_ns_list[i] = c_ns_list[c_ns_list_len]
|
| 414 |
+
#c_ns_list[c_ns_list_len] = _ns_node_ref(NULL, NULL)
|
| 415 |
+
break
|
| 416 |
+
if c_node is c_element:
|
| 417 |
+
# continue with attributes
|
| 418 |
+
c_node = <xmlNode*>c_element.properties
|
| 419 |
+
else:
|
| 420 |
+
c_node = c_node.next
|
| 421 |
+
tree.END_FOR_EACH_ELEMENT_FROM(c_element)
|
| 422 |
+
|
| 423 |
+
if c_ns_list is NULL:
|
| 424 |
+
return 0
|
| 425 |
+
|
| 426 |
+
# free all namespace declarations that remained in the list,
|
| 427 |
+
# except for those we should keep explicitly
|
| 428 |
+
cdef xmlNs* c_nsdef
|
| 429 |
+
for i in range(c_ns_list_len):
|
| 430 |
+
if prefixes_to_keep is not None:
|
| 431 |
+
if c_ns_list[i].ns.prefix and c_ns_list[i].ns.prefix in prefixes_to_keep:
|
| 432 |
+
continue
|
| 433 |
+
c_node = c_ns_list[i].node
|
| 434 |
+
c_nsdef = c_node.nsDef
|
| 435 |
+
if c_nsdef is c_ns_list[i].ns:
|
| 436 |
+
c_node.nsDef = c_node.nsDef.next
|
| 437 |
+
else:
|
| 438 |
+
while c_nsdef.next is not c_ns_list[i].ns:
|
| 439 |
+
c_nsdef = c_nsdef.next
|
| 440 |
+
c_nsdef.next = c_nsdef.next.next
|
| 441 |
+
tree.xmlFreeNs(c_ns_list[i].ns)
|
| 442 |
+
|
| 443 |
+
if c_ns_list is not NULL:
|
| 444 |
+
python.lxml_free(c_ns_list)
|
| 445 |
+
return 0
|
| 446 |
+
|
| 447 |
+
cdef xmlNs* _searchNsByHref(xmlNode* c_node, const_xmlChar* c_href, bint is_attribute) noexcept:
|
| 448 |
+
"""Search a namespace declaration that covers a node (element or
|
| 449 |
+
attribute).
|
| 450 |
+
|
| 451 |
+
For attributes, try to find a prefixed namespace declaration
|
| 452 |
+
instead of the default namespaces. This helps in supporting
|
| 453 |
+
round-trips for attributes on elements with a different namespace.
|
| 454 |
+
"""
|
| 455 |
+
cdef xmlNs* c_ns
|
| 456 |
+
cdef xmlNs* c_default_ns = NULL
|
| 457 |
+
cdef xmlNode* c_element
|
| 458 |
+
if c_href is NULL or c_node is NULL or c_node.type == tree.XML_ENTITY_REF_NODE:
|
| 459 |
+
return NULL
|
| 460 |
+
if tree.xmlStrcmp(c_href, tree.XML_XML_NAMESPACE) == 0:
|
| 461 |
+
# no special cases here, let libxml2 handle this
|
| 462 |
+
return tree.xmlSearchNsByHref(c_node.doc, c_node, c_href)
|
| 463 |
+
if c_node.type == tree.XML_ATTRIBUTE_NODE:
|
| 464 |
+
is_attribute = 1
|
| 465 |
+
while c_node is not NULL and c_node.type != tree.XML_ELEMENT_NODE:
|
| 466 |
+
c_node = c_node.parent
|
| 467 |
+
c_element = c_node
|
| 468 |
+
while c_node is not NULL:
|
| 469 |
+
if c_node.type == tree.XML_ELEMENT_NODE:
|
| 470 |
+
c_ns = c_node.nsDef
|
| 471 |
+
while c_ns is not NULL:
|
| 472 |
+
if c_ns.href is not NULL and tree.xmlStrcmp(c_href, c_ns.href) == 0:
|
| 473 |
+
if c_ns.prefix is NULL and is_attribute:
|
| 474 |
+
# for attributes, continue searching a named
|
| 475 |
+
# prefix, but keep the first default namespace
|
| 476 |
+
# declaration that we found
|
| 477 |
+
if c_default_ns is NULL:
|
| 478 |
+
c_default_ns = c_ns
|
| 479 |
+
elif tree.xmlSearchNs(
|
| 480 |
+
c_element.doc, c_element, c_ns.prefix) is c_ns:
|
| 481 |
+
# start node is in namespace scope => found!
|
| 482 |
+
return c_ns
|
| 483 |
+
c_ns = c_ns.next
|
| 484 |
+
if c_node is not c_element and c_node.ns is not NULL:
|
| 485 |
+
# optimise: the node may have the namespace itself
|
| 486 |
+
c_ns = c_node.ns
|
| 487 |
+
if c_ns.href is not NULL and tree.xmlStrcmp(c_href, c_ns.href) == 0:
|
| 488 |
+
if c_ns.prefix is NULL and is_attribute:
|
| 489 |
+
# for attributes, continue searching a named
|
| 490 |
+
# prefix, but keep the first default namespace
|
| 491 |
+
# declaration that we found
|
| 492 |
+
if c_default_ns is NULL:
|
| 493 |
+
c_default_ns = c_ns
|
| 494 |
+
elif tree.xmlSearchNs(
|
| 495 |
+
c_element.doc, c_element, c_ns.prefix) is c_ns:
|
| 496 |
+
# start node is in namespace scope => found!
|
| 497 |
+
return c_ns
|
| 498 |
+
c_node = c_node.parent
|
| 499 |
+
# nothing found => use a matching default namespace or fail
|
| 500 |
+
if c_default_ns is not NULL:
|
| 501 |
+
if tree.xmlSearchNs(c_element.doc, c_element, NULL) is c_default_ns:
|
| 502 |
+
return c_default_ns
|
| 503 |
+
return NULL
|
| 504 |
+
|
| 505 |
+
cdef int _replaceNodeByChildren(_Document doc, xmlNode* c_node) except -1:
|
| 506 |
+
# NOTE: this does not deallocate the node, just unlink it!
|
| 507 |
+
cdef xmlNode* c_parent
|
| 508 |
+
cdef xmlNode* c_child
|
| 509 |
+
if c_node.children is NULL:
|
| 510 |
+
tree.xmlUnlinkNode(c_node)
|
| 511 |
+
return 0
|
| 512 |
+
|
| 513 |
+
c_parent = c_node.parent
|
| 514 |
+
# fix parent links of children
|
| 515 |
+
c_child = c_node.children
|
| 516 |
+
while c_child is not NULL:
|
| 517 |
+
c_child.parent = c_parent
|
| 518 |
+
c_child = c_child.next
|
| 519 |
+
|
| 520 |
+
# fix namespace references of children if their parent's namespace
|
| 521 |
+
# declarations get lost
|
| 522 |
+
if c_node.nsDef is not NULL:
|
| 523 |
+
c_child = c_node.children
|
| 524 |
+
while c_child is not NULL:
|
| 525 |
+
moveNodeToDocument(doc, doc._c_doc, c_child)
|
| 526 |
+
c_child = c_child.next
|
| 527 |
+
|
| 528 |
+
# fix sibling links to/from child slice
|
| 529 |
+
if c_node.prev is NULL:
|
| 530 |
+
c_parent.children = c_node.children
|
| 531 |
+
else:
|
| 532 |
+
c_node.prev.next = c_node.children
|
| 533 |
+
c_node.children.prev = c_node.prev
|
| 534 |
+
if c_node.next is NULL:
|
| 535 |
+
c_parent.last = c_node.last
|
| 536 |
+
else:
|
| 537 |
+
c_node.next.prev = c_node.last
|
| 538 |
+
c_node.last.next = c_node.next
|
| 539 |
+
|
| 540 |
+
# unlink c_node
|
| 541 |
+
c_node.children = c_node.last = NULL
|
| 542 |
+
c_node.parent = c_node.next = c_node.prev = NULL
|
| 543 |
+
return 0
|
| 544 |
+
|
| 545 |
+
cdef unicode _attributeValue(xmlNode* c_element, xmlAttr* c_attrib_node):
|
| 546 |
+
c_href = _getNs(<xmlNode*>c_attrib_node)
|
| 547 |
+
value = tree.xmlGetNsProp(c_element, c_attrib_node.name, c_href)
|
| 548 |
+
try:
|
| 549 |
+
result = funicode(value)
|
| 550 |
+
finally:
|
| 551 |
+
tree.xmlFree(value)
|
| 552 |
+
return result
|
| 553 |
+
|
| 554 |
+
cdef unicode _attributeValueFromNsName(xmlNode* c_element,
|
| 555 |
+
const_xmlChar* c_href, const_xmlChar* c_name):
|
| 556 |
+
c_result = tree.xmlGetNsProp(c_element, c_name, c_href)
|
| 557 |
+
if c_result is NULL:
|
| 558 |
+
return None
|
| 559 |
+
try:
|
| 560 |
+
result = funicode(c_result)
|
| 561 |
+
finally:
|
| 562 |
+
tree.xmlFree(c_result)
|
| 563 |
+
return result
|
| 564 |
+
|
| 565 |
+
cdef object _getNodeAttributeValue(xmlNode* c_node, key, default):
|
| 566 |
+
ns, tag = _getNsTag(key)
|
| 567 |
+
c_href = <const_xmlChar*>NULL if ns is None else _xcstr(ns)
|
| 568 |
+
c_result = tree.xmlGetNsProp(c_node, _xcstr(tag), c_href)
|
| 569 |
+
if c_result is NULL:
|
| 570 |
+
# XXX free namespace that is not in use..?
|
| 571 |
+
return default
|
| 572 |
+
try:
|
| 573 |
+
result = funicode(c_result)
|
| 574 |
+
finally:
|
| 575 |
+
tree.xmlFree(c_result)
|
| 576 |
+
return result
|
| 577 |
+
|
| 578 |
+
cdef inline object _getAttributeValue(_Element element, key, default):
|
| 579 |
+
return _getNodeAttributeValue(element._c_node, key, default)
|
| 580 |
+
|
| 581 |
+
cdef int _setAttributeValue(_Element element, key, value) except -1:
|
| 582 |
+
cdef const_xmlChar* c_value
|
| 583 |
+
cdef xmlNs* c_ns
|
| 584 |
+
ns, tag = _getNsTag(key)
|
| 585 |
+
is_html = element._doc._parser._for_html
|
| 586 |
+
if not is_html:
|
| 587 |
+
_attributeValidOrRaise(tag)
|
| 588 |
+
c_tag = _xcstr(tag)
|
| 589 |
+
if value is None and is_html:
|
| 590 |
+
c_value = NULL
|
| 591 |
+
else:
|
| 592 |
+
if isinstance(value, QName):
|
| 593 |
+
value = _resolveQNameText(element, value)
|
| 594 |
+
else:
|
| 595 |
+
value = _utf8(value)
|
| 596 |
+
c_value = _xcstr(value)
|
| 597 |
+
if ns is None:
|
| 598 |
+
c_ns = NULL
|
| 599 |
+
else:
|
| 600 |
+
c_ns = element._doc._findOrBuildNodeNs(element._c_node, _xcstr(ns), NULL, 1)
|
| 601 |
+
tree.xmlSetNsProp(element._c_node, c_ns, c_tag, c_value)
|
| 602 |
+
return 0
|
| 603 |
+
|
| 604 |
+
cdef int _delAttribute(_Element element, key) except -1:
|
| 605 |
+
ns, tag = _getNsTag(key)
|
| 606 |
+
c_href = <const_xmlChar*>NULL if ns is None else _xcstr(ns)
|
| 607 |
+
if _delAttributeFromNsName(element._c_node, c_href, _xcstr(tag)):
|
| 608 |
+
raise KeyError, key
|
| 609 |
+
return 0
|
| 610 |
+
|
| 611 |
+
cdef int _delAttributeFromNsName(xmlNode* c_node, const_xmlChar* c_href, const_xmlChar* c_name) noexcept:
|
| 612 |
+
c_attr = tree.xmlHasNsProp(c_node, c_name, c_href)
|
| 613 |
+
if c_attr is NULL:
|
| 614 |
+
# XXX free namespace that is not in use..?
|
| 615 |
+
return -1
|
| 616 |
+
tree.xmlRemoveProp(c_attr)
|
| 617 |
+
return 0
|
| 618 |
+
|
| 619 |
+
cdef list _collectAttributes(xmlNode* c_node, int collecttype):
|
| 620 |
+
"""Collect all attributes of a node in a list. Depending on collecttype,
|
| 621 |
+
it collects either the name (1), the value (2) or the name-value tuples.
|
| 622 |
+
"""
|
| 623 |
+
cdef Py_ssize_t count
|
| 624 |
+
c_attr = c_node.properties
|
| 625 |
+
count = 0
|
| 626 |
+
while c_attr is not NULL:
|
| 627 |
+
if c_attr.type == tree.XML_ATTRIBUTE_NODE:
|
| 628 |
+
count += 1
|
| 629 |
+
c_attr = c_attr.next
|
| 630 |
+
|
| 631 |
+
if not count:
|
| 632 |
+
return []
|
| 633 |
+
|
| 634 |
+
attributes = [None] * count
|
| 635 |
+
c_attr = c_node.properties
|
| 636 |
+
count = 0
|
| 637 |
+
while c_attr is not NULL:
|
| 638 |
+
if c_attr.type == tree.XML_ATTRIBUTE_NODE:
|
| 639 |
+
if collecttype == 1:
|
| 640 |
+
item = _namespacedName(<xmlNode*>c_attr)
|
| 641 |
+
elif collecttype == 2:
|
| 642 |
+
item = _attributeValue(c_node, c_attr)
|
| 643 |
+
else:
|
| 644 |
+
item = (_namespacedName(<xmlNode*>c_attr),
|
| 645 |
+
_attributeValue(c_node, c_attr))
|
| 646 |
+
attributes[count] = item
|
| 647 |
+
count += 1
|
| 648 |
+
c_attr = c_attr.next
|
| 649 |
+
return attributes
|
| 650 |
+
|
| 651 |
+
cdef object __RE_XML_ENCODING = re.compile(
|
| 652 |
+
r'^(<\?xml[^>]+)\s+encoding\s*=\s*["\'][^"\']*["\'](\s*\?>|)', re.U)
|
| 653 |
+
|
| 654 |
+
cdef object __REPLACE_XML_ENCODING = __RE_XML_ENCODING.sub
|
| 655 |
+
cdef object __HAS_XML_ENCODING = __RE_XML_ENCODING.match
|
| 656 |
+
|
| 657 |
+
cdef object _stripEncodingDeclaration(object xml_string):
|
| 658 |
+
# this is a hack to remove the XML encoding declaration from unicode
|
| 659 |
+
return __REPLACE_XML_ENCODING(r'\g<1>\g<2>', xml_string)
|
| 660 |
+
|
| 661 |
+
cdef bint _hasEncodingDeclaration(object xml_string) except -1:
|
| 662 |
+
# check if a (unicode) string has an XML encoding declaration
|
| 663 |
+
return __HAS_XML_ENCODING(xml_string) is not None
|
| 664 |
+
|
| 665 |
+
cdef inline bint _hasText(xmlNode* c_node) noexcept:
|
| 666 |
+
return c_node is not NULL and _textNodeOrSkip(c_node.children) is not NULL
|
| 667 |
+
|
| 668 |
+
cdef inline bint _hasTail(xmlNode* c_node) noexcept:
|
| 669 |
+
return c_node is not NULL and _textNodeOrSkip(c_node.next) is not NULL
|
| 670 |
+
|
| 671 |
+
cdef inline bint _hasNonWhitespaceTail(xmlNode* c_node) except -1:
|
| 672 |
+
return _hasNonWhitespaceText(c_node, tail=True)
|
| 673 |
+
|
| 674 |
+
cdef bint _hasNonWhitespaceText(xmlNode* c_node, bint tail=False) except -1:
|
| 675 |
+
c_text_node = c_node and _textNodeOrSkip(c_node.next if tail else c_node.children)
|
| 676 |
+
if c_text_node is NULL:
|
| 677 |
+
return False
|
| 678 |
+
while c_text_node is not NULL:
|
| 679 |
+
if c_text_node.content[0] != c'\0' and not _collectText(c_text_node).isspace():
|
| 680 |
+
return True
|
| 681 |
+
c_text_node = _textNodeOrSkip(c_text_node.next)
|
| 682 |
+
return False
|
| 683 |
+
|
| 684 |
+
cdef unicode _collectText(xmlNode* c_node):
|
| 685 |
+
"""Collect all text nodes and return them as a unicode string.
|
| 686 |
+
|
| 687 |
+
Start collecting at c_node.
|
| 688 |
+
|
| 689 |
+
If there was no text to collect, return None
|
| 690 |
+
"""
|
| 691 |
+
cdef Py_ssize_t scount
|
| 692 |
+
cdef xmlChar* c_text
|
| 693 |
+
cdef xmlNode* c_node_cur
|
| 694 |
+
# check for multiple text nodes
|
| 695 |
+
scount = 0
|
| 696 |
+
c_text = NULL
|
| 697 |
+
c_node_cur = c_node = _textNodeOrSkip(c_node)
|
| 698 |
+
while c_node_cur is not NULL:
|
| 699 |
+
if c_node_cur.content[0] != c'\0':
|
| 700 |
+
c_text = c_node_cur.content
|
| 701 |
+
scount += 1
|
| 702 |
+
c_node_cur = _textNodeOrSkip(c_node_cur.next)
|
| 703 |
+
|
| 704 |
+
# handle two most common cases first
|
| 705 |
+
if c_text is NULL:
|
| 706 |
+
return '' if scount > 0 else None
|
| 707 |
+
if scount == 1:
|
| 708 |
+
return funicode(c_text)
|
| 709 |
+
|
| 710 |
+
# the rest is not performance critical anymore
|
| 711 |
+
result = b''
|
| 712 |
+
while c_node is not NULL:
|
| 713 |
+
result += <unsigned char*>c_node.content
|
| 714 |
+
c_node = _textNodeOrSkip(c_node.next)
|
| 715 |
+
return funicode(<const_xmlChar*><unsigned char*>result)
|
| 716 |
+
|
| 717 |
+
cdef void _removeText(xmlNode* c_node) noexcept:
|
| 718 |
+
"""Remove all text nodes.
|
| 719 |
+
|
| 720 |
+
Start removing at c_node.
|
| 721 |
+
"""
|
| 722 |
+
cdef xmlNode* c_next
|
| 723 |
+
c_node = _textNodeOrSkip(c_node)
|
| 724 |
+
while c_node is not NULL:
|
| 725 |
+
c_next = _textNodeOrSkip(c_node.next)
|
| 726 |
+
tree.xmlUnlinkNode(c_node)
|
| 727 |
+
tree.xmlFreeNode(c_node)
|
| 728 |
+
c_node = c_next
|
| 729 |
+
|
| 730 |
+
cdef xmlNode* _createTextNode(xmlDoc* doc, value) except NULL:
|
| 731 |
+
cdef xmlNode* c_text_node
|
| 732 |
+
if isinstance(value, CDATA):
|
| 733 |
+
c_text_node = tree.xmlNewCDataBlock(
|
| 734 |
+
doc, _xcstr((<CDATA>value)._utf8_data),
|
| 735 |
+
python.PyBytes_GET_SIZE((<CDATA>value)._utf8_data))
|
| 736 |
+
else:
|
| 737 |
+
text = _utf8(value)
|
| 738 |
+
c_text_node = tree.xmlNewDocText(doc, _xcstr(text))
|
| 739 |
+
if not c_text_node:
|
| 740 |
+
raise MemoryError()
|
| 741 |
+
return c_text_node
|
| 742 |
+
|
| 743 |
+
cdef int _setNodeText(xmlNode* c_node, value) except -1:
|
| 744 |
+
# remove all text nodes at the start first
|
| 745 |
+
_removeText(c_node.children)
|
| 746 |
+
if value is None:
|
| 747 |
+
return 0
|
| 748 |
+
# now add new text node with value at start
|
| 749 |
+
c_text_node = _createTextNode(c_node.doc, value)
|
| 750 |
+
if c_node.children is NULL:
|
| 751 |
+
tree.xmlAddChild(c_node, c_text_node)
|
| 752 |
+
else:
|
| 753 |
+
tree.xmlAddPrevSibling(c_node.children, c_text_node)
|
| 754 |
+
return 0
|
| 755 |
+
|
| 756 |
+
cdef int _setTailText(xmlNode* c_node, value) except -1:
|
| 757 |
+
# remove all text nodes at the start first
|
| 758 |
+
_removeText(c_node.next)
|
| 759 |
+
if value is None:
|
| 760 |
+
return 0
|
| 761 |
+
# now append new text node with value
|
| 762 |
+
c_text_node = _createTextNode(c_node.doc, value)
|
| 763 |
+
tree.xmlAddNextSibling(c_node, c_text_node)
|
| 764 |
+
return 0
|
| 765 |
+
|
| 766 |
+
cdef bytes _resolveQNameText(_Element element, value):
|
| 767 |
+
cdef xmlNs* c_ns
|
| 768 |
+
ns, tag = _getNsTag(value)
|
| 769 |
+
if ns is None:
|
| 770 |
+
return tag
|
| 771 |
+
else:
|
| 772 |
+
c_ns = element._doc._findOrBuildNodeNs(
|
| 773 |
+
element._c_node, _xcstr(ns), NULL, 0)
|
| 774 |
+
return python.PyBytes_FromFormat('%s:%s', c_ns.prefix, _cstr(tag))
|
| 775 |
+
|
| 776 |
+
cdef inline bint _hasChild(xmlNode* c_node) noexcept:
|
| 777 |
+
return c_node is not NULL and _findChildForwards(c_node, 0) is not NULL
|
| 778 |
+
|
| 779 |
+
cdef inline Py_ssize_t _countElements(xmlNode* c_node) noexcept:
|
| 780 |
+
"Counts the elements within the following siblings and the node itself."
|
| 781 |
+
cdef Py_ssize_t count
|
| 782 |
+
count = 0
|
| 783 |
+
while c_node is not NULL:
|
| 784 |
+
if _isElement(c_node):
|
| 785 |
+
count += 1
|
| 786 |
+
c_node = c_node.next
|
| 787 |
+
return count
|
| 788 |
+
|
| 789 |
+
cdef int _findChildSlice(
|
| 790 |
+
slice sliceobject, xmlNode* c_parent,
|
| 791 |
+
xmlNode** c_start_node, Py_ssize_t* c_step, Py_ssize_t* c_length) except -1:
|
| 792 |
+
"""Resolve a children slice.
|
| 793 |
+
|
| 794 |
+
Returns the start node, step size and the slice length in the
|
| 795 |
+
pointer arguments.
|
| 796 |
+
"""
|
| 797 |
+
cdef Py_ssize_t start = 0, stop = 0, childcount
|
| 798 |
+
childcount = _countElements(c_parent.children)
|
| 799 |
+
if childcount == 0:
|
| 800 |
+
c_start_node[0] = NULL
|
| 801 |
+
c_length[0] = 0
|
| 802 |
+
if sliceobject.step is None:
|
| 803 |
+
c_step[0] = 1
|
| 804 |
+
else:
|
| 805 |
+
python._PyEval_SliceIndex(sliceobject.step, c_step)
|
| 806 |
+
return 0
|
| 807 |
+
python.PySlice_GetIndicesEx(
|
| 808 |
+
sliceobject, childcount, &start, &stop, c_step, c_length)
|
| 809 |
+
if start > childcount // 2:
|
| 810 |
+
c_start_node[0] = _findChildBackwards(c_parent, childcount - start - 1)
|
| 811 |
+
else:
|
| 812 |
+
c_start_node[0] = _findChild(c_parent, start)
|
| 813 |
+
return 0
|
| 814 |
+
|
| 815 |
+
cdef bint _isFullSlice(slice sliceobject) except -1:
|
| 816 |
+
"""Conservative guess if this slice is a full slice as in ``s[:]``.
|
| 817 |
+
"""
|
| 818 |
+
cdef Py_ssize_t step = 0
|
| 819 |
+
if sliceobject is None:
|
| 820 |
+
return 0
|
| 821 |
+
if sliceobject.start is None and \
|
| 822 |
+
sliceobject.stop is None:
|
| 823 |
+
if sliceobject.step is None:
|
| 824 |
+
return 1
|
| 825 |
+
python._PyEval_SliceIndex(sliceobject.step, &step)
|
| 826 |
+
if step == 1:
|
| 827 |
+
return 1
|
| 828 |
+
return 0
|
| 829 |
+
return 0
|
| 830 |
+
|
| 831 |
+
cdef _collectChildren(_Element element):
|
| 832 |
+
cdef xmlNode* c_node
|
| 833 |
+
cdef list result = []
|
| 834 |
+
c_node = element._c_node.children
|
| 835 |
+
if c_node is not NULL:
|
| 836 |
+
if not _isElement(c_node):
|
| 837 |
+
c_node = _nextElement(c_node)
|
| 838 |
+
while c_node is not NULL:
|
| 839 |
+
result.append(_elementFactory(element._doc, c_node))
|
| 840 |
+
c_node = _nextElement(c_node)
|
| 841 |
+
return result
|
| 842 |
+
|
| 843 |
+
cdef inline xmlNode* _findChild(xmlNode* c_node, Py_ssize_t index) noexcept:
|
| 844 |
+
if index < 0:
|
| 845 |
+
return _findChildBackwards(c_node, -index - 1)
|
| 846 |
+
else:
|
| 847 |
+
return _findChildForwards(c_node, index)
|
| 848 |
+
|
| 849 |
+
cdef inline xmlNode* _findChildForwards(xmlNode* c_node, Py_ssize_t index) noexcept:
|
| 850 |
+
"""Return child element of c_node with index, or return NULL if not found.
|
| 851 |
+
"""
|
| 852 |
+
cdef xmlNode* c_child
|
| 853 |
+
cdef Py_ssize_t c
|
| 854 |
+
c_child = c_node.children
|
| 855 |
+
c = 0
|
| 856 |
+
while c_child is not NULL:
|
| 857 |
+
if _isElement(c_child):
|
| 858 |
+
if c == index:
|
| 859 |
+
return c_child
|
| 860 |
+
c += 1
|
| 861 |
+
c_child = c_child.next
|
| 862 |
+
return NULL
|
| 863 |
+
|
| 864 |
+
cdef inline xmlNode* _findChildBackwards(xmlNode* c_node, Py_ssize_t index) noexcept:
|
| 865 |
+
"""Return child element of c_node with index, or return NULL if not found.
|
| 866 |
+
Search from the end.
|
| 867 |
+
"""
|
| 868 |
+
cdef xmlNode* c_child
|
| 869 |
+
cdef Py_ssize_t c
|
| 870 |
+
c_child = c_node.last
|
| 871 |
+
c = 0
|
| 872 |
+
while c_child is not NULL:
|
| 873 |
+
if _isElement(c_child):
|
| 874 |
+
if c == index:
|
| 875 |
+
return c_child
|
| 876 |
+
c += 1
|
| 877 |
+
c_child = c_child.prev
|
| 878 |
+
return NULL
|
| 879 |
+
|
| 880 |
+
cdef inline xmlNode* _textNodeOrSkip(xmlNode* c_node) noexcept nogil:
|
| 881 |
+
"""Return the node if it's a text node. Skip over ignorable nodes in a
|
| 882 |
+
series of text nodes. Return NULL if a non-ignorable node is found.
|
| 883 |
+
|
| 884 |
+
This is used to skip over XInclude nodes when collecting adjacent text
|
| 885 |
+
nodes.
|
| 886 |
+
"""
|
| 887 |
+
while c_node is not NULL:
|
| 888 |
+
if c_node.type == tree.XML_TEXT_NODE or \
|
| 889 |
+
c_node.type == tree.XML_CDATA_SECTION_NODE:
|
| 890 |
+
return c_node
|
| 891 |
+
elif c_node.type == tree.XML_XINCLUDE_START or \
|
| 892 |
+
c_node.type == tree.XML_XINCLUDE_END:
|
| 893 |
+
c_node = c_node.next
|
| 894 |
+
else:
|
| 895 |
+
return NULL
|
| 896 |
+
return NULL
|
| 897 |
+
|
| 898 |
+
cdef inline xmlNode* _nextElement(xmlNode* c_node) noexcept:
|
| 899 |
+
"""Given a node, find the next sibling that is an element.
|
| 900 |
+
"""
|
| 901 |
+
if c_node is NULL:
|
| 902 |
+
return NULL
|
| 903 |
+
c_node = c_node.next
|
| 904 |
+
while c_node is not NULL:
|
| 905 |
+
if _isElement(c_node):
|
| 906 |
+
return c_node
|
| 907 |
+
c_node = c_node.next
|
| 908 |
+
return NULL
|
| 909 |
+
|
| 910 |
+
cdef inline xmlNode* _previousElement(xmlNode* c_node) noexcept:
|
| 911 |
+
"""Given a node, find the next sibling that is an element.
|
| 912 |
+
"""
|
| 913 |
+
if c_node is NULL:
|
| 914 |
+
return NULL
|
| 915 |
+
c_node = c_node.prev
|
| 916 |
+
while c_node is not NULL:
|
| 917 |
+
if _isElement(c_node):
|
| 918 |
+
return c_node
|
| 919 |
+
c_node = c_node.prev
|
| 920 |
+
return NULL
|
| 921 |
+
|
| 922 |
+
cdef inline xmlNode* _parentElement(xmlNode* c_node) noexcept:
|
| 923 |
+
"Given a node, find the parent element."
|
| 924 |
+
if c_node is NULL or not _isElement(c_node):
|
| 925 |
+
return NULL
|
| 926 |
+
c_node = c_node.parent
|
| 927 |
+
if c_node is NULL or not _isElement(c_node):
|
| 928 |
+
return NULL
|
| 929 |
+
return c_node
|
| 930 |
+
|
| 931 |
+
cdef inline bint _tagMatches(xmlNode* c_node, const_xmlChar* c_href, const_xmlChar* c_name) noexcept:
|
| 932 |
+
"""Tests if the node matches namespace URI and tag name.
|
| 933 |
+
|
| 934 |
+
A node matches if it matches both c_href and c_name.
|
| 935 |
+
|
| 936 |
+
A node matches c_href if any of the following is true:
|
| 937 |
+
* c_href is NULL
|
| 938 |
+
* its namespace is NULL and c_href is the empty string
|
| 939 |
+
* its namespace string equals the c_href string
|
| 940 |
+
|
| 941 |
+
A node matches c_name if any of the following is true:
|
| 942 |
+
* c_name is NULL
|
| 943 |
+
* its name string equals the c_name string
|
| 944 |
+
"""
|
| 945 |
+
if c_node is NULL:
|
| 946 |
+
return 0
|
| 947 |
+
if c_node.type != tree.XML_ELEMENT_NODE:
|
| 948 |
+
# not an element, only succeed if we match everything
|
| 949 |
+
return c_name is NULL and c_href is NULL
|
| 950 |
+
if c_name is NULL:
|
| 951 |
+
if c_href is NULL:
|
| 952 |
+
# always match
|
| 953 |
+
return 1
|
| 954 |
+
else:
|
| 955 |
+
c_node_href = _getNs(c_node)
|
| 956 |
+
if c_node_href is NULL:
|
| 957 |
+
return c_href[0] == c'\0'
|
| 958 |
+
else:
|
| 959 |
+
return tree.xmlStrcmp(c_node_href, c_href) == 0
|
| 960 |
+
elif c_href is NULL:
|
| 961 |
+
if _getNs(c_node) is not NULL:
|
| 962 |
+
return 0
|
| 963 |
+
return c_node.name == c_name or tree.xmlStrcmp(c_node.name, c_name) == 0
|
| 964 |
+
elif c_node.name == c_name or tree.xmlStrcmp(c_node.name, c_name) == 0:
|
| 965 |
+
c_node_href = _getNs(c_node)
|
| 966 |
+
if c_node_href is NULL:
|
| 967 |
+
return c_href[0] == c'\0'
|
| 968 |
+
else:
|
| 969 |
+
return tree.xmlStrcmp(c_node_href, c_href) == 0
|
| 970 |
+
else:
|
| 971 |
+
return 0
|
| 972 |
+
|
| 973 |
+
cdef inline bint _tagMatchesExactly(xmlNode* c_node, qname* c_qname) noexcept:
|
| 974 |
+
"""Tests if the node matches namespace URI and tag name.
|
| 975 |
+
|
| 976 |
+
This differs from _tagMatches() in that it does not consider a
|
| 977 |
+
NULL value in qname.href a wildcard, and that it expects the c_name
|
| 978 |
+
to be taken from the doc dict, i.e. it only compares the names by
|
| 979 |
+
address.
|
| 980 |
+
|
| 981 |
+
A node matches if it matches both href and c_name of the qname.
|
| 982 |
+
|
| 983 |
+
A node matches c_href if any of the following is true:
|
| 984 |
+
* its namespace is NULL and c_href is the empty string
|
| 985 |
+
* its namespace string equals the c_href string
|
| 986 |
+
|
| 987 |
+
A node matches c_name if any of the following is true:
|
| 988 |
+
* c_name is NULL
|
| 989 |
+
* its name string points to the same address (!) as c_name
|
| 990 |
+
"""
|
| 991 |
+
return _nsTagMatchesExactly(_getNs(c_node), c_node.name, c_qname)
|
| 992 |
+
|
| 993 |
+
cdef inline bint _nsTagMatchesExactly(const_xmlChar* c_node_href,
|
| 994 |
+
const_xmlChar* c_node_name,
|
| 995 |
+
qname* c_qname) noexcept:
|
| 996 |
+
"""Tests if name and namespace URI match those of c_qname.
|
| 997 |
+
|
| 998 |
+
This differs from _tagMatches() in that it does not consider a
|
| 999 |
+
NULL value in qname.href a wildcard, and that it expects the c_name
|
| 1000 |
+
to be taken from the doc dict, i.e. it only compares the names by
|
| 1001 |
+
address.
|
| 1002 |
+
|
| 1003 |
+
A node matches if it matches both href and c_name of the qname.
|
| 1004 |
+
|
| 1005 |
+
A node matches c_href if any of the following is true:
|
| 1006 |
+
* its namespace is NULL and c_href is the empty string
|
| 1007 |
+
* its namespace string equals the c_href string
|
| 1008 |
+
|
| 1009 |
+
A node matches c_name if any of the following is true:
|
| 1010 |
+
* c_name is NULL
|
| 1011 |
+
* its name string points to the same address (!) as c_name
|
| 1012 |
+
"""
|
| 1013 |
+
cdef char* c_href
|
| 1014 |
+
if c_qname.c_name is not NULL and c_qname.c_name is not c_node_name:
|
| 1015 |
+
return 0
|
| 1016 |
+
if c_qname.href is NULL:
|
| 1017 |
+
return 1
|
| 1018 |
+
c_href = python.__cstr(c_qname.href)
|
| 1019 |
+
if c_href[0] == b'\0':
|
| 1020 |
+
return c_node_href is NULL or c_node_href[0] == b'\0'
|
| 1021 |
+
elif c_node_href is NULL:
|
| 1022 |
+
return 0
|
| 1023 |
+
else:
|
| 1024 |
+
return tree.xmlStrcmp(<const_xmlChar*>c_href, c_node_href) == 0
|
| 1025 |
+
|
| 1026 |
+
cdef Py_ssize_t _mapTagsToQnameMatchArray(xmlDoc* c_doc, list ns_tags,
|
| 1027 |
+
qname* c_ns_tags, bint force_into_dict) except -1:
|
| 1028 |
+
"""Map a sequence of (name, namespace) pairs to a qname array for efficient
|
| 1029 |
+
matching with _tagMatchesExactly() above.
|
| 1030 |
+
|
| 1031 |
+
Note that each qname struct in the array owns its href byte string object
|
| 1032 |
+
if it is not NULL.
|
| 1033 |
+
"""
|
| 1034 |
+
cdef Py_ssize_t count = 0, i
|
| 1035 |
+
cdef bytes ns, tag
|
| 1036 |
+
for ns, tag in ns_tags:
|
| 1037 |
+
if tag is None:
|
| 1038 |
+
c_tag = <const_xmlChar*>NULL
|
| 1039 |
+
elif force_into_dict:
|
| 1040 |
+
c_tag = tree.xmlDictLookup(c_doc.dict, _xcstr(tag), len(tag))
|
| 1041 |
+
if c_tag is NULL:
|
| 1042 |
+
# clean up before raising the error
|
| 1043 |
+
for i in xrange(count):
|
| 1044 |
+
cpython.ref.Py_XDECREF(c_ns_tags[i].href)
|
| 1045 |
+
raise MemoryError()
|
| 1046 |
+
else:
|
| 1047 |
+
c_tag = tree.xmlDictExists(c_doc.dict, _xcstr(tag), len(tag))
|
| 1048 |
+
if c_tag is NULL:
|
| 1049 |
+
# not in the dict => not in the document
|
| 1050 |
+
continue
|
| 1051 |
+
c_ns_tags[count].c_name = c_tag
|
| 1052 |
+
if ns is None:
|
| 1053 |
+
c_ns_tags[count].href = NULL
|
| 1054 |
+
else:
|
| 1055 |
+
cpython.ref.Py_INCREF(ns) # keep an owned reference!
|
| 1056 |
+
c_ns_tags[count].href = <python.PyObject*>ns
|
| 1057 |
+
count += 1
|
| 1058 |
+
return count
|
| 1059 |
+
|
| 1060 |
+
cdef int _removeNode(_Document doc, xmlNode* c_node) except -1:
|
| 1061 |
+
"""Unlink and free a node and subnodes if possible. Otherwise, make sure
|
| 1062 |
+
it's self-contained.
|
| 1063 |
+
"""
|
| 1064 |
+
cdef xmlNode* c_next
|
| 1065 |
+
c_next = c_node.next
|
| 1066 |
+
tree.xmlUnlinkNode(c_node)
|
| 1067 |
+
_moveTail(c_next, c_node)
|
| 1068 |
+
if not attemptDeallocation(c_node):
|
| 1069 |
+
# make namespaces absolute
|
| 1070 |
+
moveNodeToDocument(doc, c_node.doc, c_node)
|
| 1071 |
+
return 0
|
| 1072 |
+
|
| 1073 |
+
cdef int _removeSiblings(xmlNode* c_element, tree.xmlElementType node_type, bint with_tail) except -1:
|
| 1074 |
+
cdef xmlNode* c_node
|
| 1075 |
+
cdef xmlNode* c_next
|
| 1076 |
+
c_node = c_element.next
|
| 1077 |
+
while c_node is not NULL:
|
| 1078 |
+
c_next = _nextElement(c_node)
|
| 1079 |
+
if c_node.type == node_type:
|
| 1080 |
+
if with_tail:
|
| 1081 |
+
_removeText(c_node.next)
|
| 1082 |
+
tree.xmlUnlinkNode(c_node)
|
| 1083 |
+
attemptDeallocation(c_node)
|
| 1084 |
+
c_node = c_next
|
| 1085 |
+
c_node = c_element.prev
|
| 1086 |
+
while c_node is not NULL:
|
| 1087 |
+
c_next = _previousElement(c_node)
|
| 1088 |
+
if c_node.type == node_type:
|
| 1089 |
+
if with_tail:
|
| 1090 |
+
_removeText(c_node.next)
|
| 1091 |
+
tree.xmlUnlinkNode(c_node)
|
| 1092 |
+
attemptDeallocation(c_node)
|
| 1093 |
+
c_node = c_next
|
| 1094 |
+
return 0
|
| 1095 |
+
|
| 1096 |
+
cdef void _moveTail(xmlNode* c_tail, xmlNode* c_target) noexcept:
|
| 1097 |
+
cdef xmlNode* c_next
|
| 1098 |
+
# tail support: look for any text nodes trailing this node and
|
| 1099 |
+
# move them too
|
| 1100 |
+
c_tail = _textNodeOrSkip(c_tail)
|
| 1101 |
+
while c_tail is not NULL:
|
| 1102 |
+
c_next = _textNodeOrSkip(c_tail.next)
|
| 1103 |
+
c_target = tree.xmlAddNextSibling(c_target, c_tail)
|
| 1104 |
+
c_tail = c_next
|
| 1105 |
+
|
| 1106 |
+
cdef int _copyTail(xmlNode* c_tail, xmlNode* c_target) except -1:
|
| 1107 |
+
cdef xmlNode* c_new_tail
|
| 1108 |
+
# tail copying support: look for any text nodes trailing this node and
|
| 1109 |
+
# copy it to the target node
|
| 1110 |
+
c_tail = _textNodeOrSkip(c_tail)
|
| 1111 |
+
while c_tail is not NULL:
|
| 1112 |
+
if c_target.doc is not c_tail.doc:
|
| 1113 |
+
c_new_tail = tree.xmlDocCopyNode(c_tail, c_target.doc, 0)
|
| 1114 |
+
else:
|
| 1115 |
+
c_new_tail = tree.xmlCopyNode(c_tail, 0)
|
| 1116 |
+
if c_new_tail is NULL:
|
| 1117 |
+
raise MemoryError()
|
| 1118 |
+
c_target = tree.xmlAddNextSibling(c_target, c_new_tail)
|
| 1119 |
+
c_tail = _textNodeOrSkip(c_tail.next)
|
| 1120 |
+
return 0
|
| 1121 |
+
|
| 1122 |
+
cdef int _copyNonElementSiblings(xmlNode* c_node, xmlNode* c_target) except -1:
|
| 1123 |
+
cdef xmlNode* c_copy
|
| 1124 |
+
cdef xmlNode* c_sibling = c_node
|
| 1125 |
+
while c_sibling.prev != NULL and \
|
| 1126 |
+
(c_sibling.prev.type == tree.XML_PI_NODE or
|
| 1127 |
+
c_sibling.prev.type == tree.XML_COMMENT_NODE or
|
| 1128 |
+
c_sibling.prev.type == tree.XML_DTD_NODE):
|
| 1129 |
+
c_sibling = c_sibling.prev
|
| 1130 |
+
while c_sibling != c_node:
|
| 1131 |
+
if c_sibling.type == tree.XML_DTD_NODE:
|
| 1132 |
+
c_copy = <xmlNode*>_copyDtd(<tree.xmlDtd*>c_sibling)
|
| 1133 |
+
if c_sibling == <xmlNode*>c_node.doc.intSubset:
|
| 1134 |
+
c_target.doc.intSubset = <tree.xmlDtd*>c_copy
|
| 1135 |
+
else: # c_sibling == c_node.doc.extSubset
|
| 1136 |
+
c_target.doc.extSubset = <tree.xmlDtd*>c_copy
|
| 1137 |
+
else:
|
| 1138 |
+
c_copy = tree.xmlDocCopyNode(c_sibling, c_target.doc, 1)
|
| 1139 |
+
if c_copy is NULL:
|
| 1140 |
+
raise MemoryError()
|
| 1141 |
+
tree.xmlAddPrevSibling(c_target, c_copy)
|
| 1142 |
+
c_sibling = c_sibling.next
|
| 1143 |
+
while c_sibling.next != NULL and \
|
| 1144 |
+
(c_sibling.next.type == tree.XML_PI_NODE or
|
| 1145 |
+
c_sibling.next.type == tree.XML_COMMENT_NODE):
|
| 1146 |
+
c_sibling = c_sibling.next
|
| 1147 |
+
c_copy = tree.xmlDocCopyNode(c_sibling, c_target.doc, 1)
|
| 1148 |
+
if c_copy is NULL:
|
| 1149 |
+
raise MemoryError()
|
| 1150 |
+
tree.xmlAddNextSibling(c_target, c_copy)
|
| 1151 |
+
|
| 1152 |
+
cdef int _deleteSlice(_Document doc, xmlNode* c_node,
|
| 1153 |
+
Py_ssize_t count, Py_ssize_t step) except -1:
|
| 1154 |
+
"""Delete slice, ``count`` items starting with ``c_node`` with a step
|
| 1155 |
+
width of ``step``.
|
| 1156 |
+
"""
|
| 1157 |
+
cdef xmlNode* c_next
|
| 1158 |
+
cdef Py_ssize_t c, i
|
| 1159 |
+
cdef _node_to_node_function next_element
|
| 1160 |
+
if c_node is NULL:
|
| 1161 |
+
return 0
|
| 1162 |
+
if step > 0:
|
| 1163 |
+
next_element = _nextElement
|
| 1164 |
+
else:
|
| 1165 |
+
step = -step
|
| 1166 |
+
next_element = _previousElement
|
| 1167 |
+
# now start deleting nodes
|
| 1168 |
+
c = 0
|
| 1169 |
+
c_next = c_node
|
| 1170 |
+
while c_node is not NULL and c < count:
|
| 1171 |
+
for i in range(step):
|
| 1172 |
+
c_next = next_element(c_next)
|
| 1173 |
+
if c_next is NULL:
|
| 1174 |
+
break
|
| 1175 |
+
_removeNode(doc, c_node)
|
| 1176 |
+
c += 1
|
| 1177 |
+
c_node = c_next
|
| 1178 |
+
return 0
|
| 1179 |
+
|
| 1180 |
+
cdef int _replaceSlice(_Element parent, xmlNode* c_node,
|
| 1181 |
+
Py_ssize_t slicelength, Py_ssize_t step,
|
| 1182 |
+
bint left_to_right, elements) except -1:
|
| 1183 |
+
"""Replace the slice of ``count`` elements starting at ``c_node`` with
|
| 1184 |
+
positive step width ``step`` by the Elements in ``elements``. The
|
| 1185 |
+
direction is given by the boolean argument ``left_to_right``.
|
| 1186 |
+
|
| 1187 |
+
``c_node`` may be NULL to indicate the end of the children list.
|
| 1188 |
+
"""
|
| 1189 |
+
cdef xmlNode* c_orig_neighbour
|
| 1190 |
+
cdef xmlNode* c_next
|
| 1191 |
+
cdef xmlDoc* c_source_doc
|
| 1192 |
+
cdef _Element element
|
| 1193 |
+
cdef Py_ssize_t seqlength, i, c
|
| 1194 |
+
cdef _node_to_node_function next_element
|
| 1195 |
+
assert step > 0
|
| 1196 |
+
if left_to_right:
|
| 1197 |
+
next_element = _nextElement
|
| 1198 |
+
else:
|
| 1199 |
+
next_element = _previousElement
|
| 1200 |
+
|
| 1201 |
+
if not isinstance(elements, (list, tuple)):
|
| 1202 |
+
elements = list(elements)
|
| 1203 |
+
|
| 1204 |
+
if step != 1 or not left_to_right:
|
| 1205 |
+
# *replacing* children stepwise with list => check size!
|
| 1206 |
+
seqlength = len(elements)
|
| 1207 |
+
if seqlength != slicelength:
|
| 1208 |
+
raise ValueError, f"attempt to assign sequence of size {seqlength} " \
|
| 1209 |
+
f"to extended slice of size {slicelength}"
|
| 1210 |
+
|
| 1211 |
+
if c_node is NULL:
|
| 1212 |
+
# no children yet => add all elements straight away
|
| 1213 |
+
if left_to_right:
|
| 1214 |
+
for element in elements:
|
| 1215 |
+
assert element is not None, "Node must not be None"
|
| 1216 |
+
_appendChild(parent, element)
|
| 1217 |
+
else:
|
| 1218 |
+
for element in elements:
|
| 1219 |
+
assert element is not None, "Node must not be None"
|
| 1220 |
+
_prependChild(parent, element)
|
| 1221 |
+
return 0
|
| 1222 |
+
|
| 1223 |
+
# remove the elements first as some might be re-added
|
| 1224 |
+
if left_to_right:
|
| 1225 |
+
# L->R, remember left neighbour
|
| 1226 |
+
c_orig_neighbour = _previousElement(c_node)
|
| 1227 |
+
else:
|
| 1228 |
+
# R->L, remember right neighbour
|
| 1229 |
+
c_orig_neighbour = _nextElement(c_node)
|
| 1230 |
+
|
| 1231 |
+
# We remove the original slice elements one by one. Since we hold
|
| 1232 |
+
# a Python reference to all elements that we will insert, it is
|
| 1233 |
+
# safe to let _removeNode() try (and fail) to free them even if
|
| 1234 |
+
# the element itself or one of its descendents will be reinserted.
|
| 1235 |
+
c = 0
|
| 1236 |
+
c_next = c_node
|
| 1237 |
+
while c_node is not NULL and c < slicelength:
|
| 1238 |
+
for i in range(step):
|
| 1239 |
+
c_next = next_element(c_next)
|
| 1240 |
+
if c_next is NULL:
|
| 1241 |
+
break
|
| 1242 |
+
_removeNode(parent._doc, c_node)
|
| 1243 |
+
c += 1
|
| 1244 |
+
c_node = c_next
|
| 1245 |
+
|
| 1246 |
+
# make sure each element is inserted only once
|
| 1247 |
+
elements = iter(elements)
|
| 1248 |
+
|
| 1249 |
+
# find the first node right of the new insertion point
|
| 1250 |
+
if left_to_right:
|
| 1251 |
+
if c_orig_neighbour is not NULL:
|
| 1252 |
+
c_node = next_element(c_orig_neighbour)
|
| 1253 |
+
else:
|
| 1254 |
+
# before the first element
|
| 1255 |
+
c_node = _findChildForwards(parent._c_node, 0)
|
| 1256 |
+
elif c_orig_neighbour is NULL:
|
| 1257 |
+
# at the end, but reversed stepping
|
| 1258 |
+
# append one element and go to the next insertion point
|
| 1259 |
+
for element in elements:
|
| 1260 |
+
assert element is not None, "Node must not be None"
|
| 1261 |
+
_appendChild(parent, element)
|
| 1262 |
+
c_node = element._c_node
|
| 1263 |
+
if slicelength > 0:
|
| 1264 |
+
slicelength -= 1
|
| 1265 |
+
for i in range(1, step):
|
| 1266 |
+
c_node = next_element(c_node)
|
| 1267 |
+
if c_node is NULL:
|
| 1268 |
+
break
|
| 1269 |
+
break
|
| 1270 |
+
else:
|
| 1271 |
+
c_node = c_orig_neighbour
|
| 1272 |
+
|
| 1273 |
+
if left_to_right:
|
| 1274 |
+
# adjust step size after removing slice as we are not stepping
|
| 1275 |
+
# over the newly inserted elements
|
| 1276 |
+
step -= 1
|
| 1277 |
+
|
| 1278 |
+
# now insert elements where we removed them
|
| 1279 |
+
if c_node is not NULL:
|
| 1280 |
+
for element in elements:
|
| 1281 |
+
assert element is not None, "Node must not be None"
|
| 1282 |
+
_assertValidNode(element)
|
| 1283 |
+
# move element and tail over
|
| 1284 |
+
c_source_doc = element._c_node.doc
|
| 1285 |
+
c_next = element._c_node.next
|
| 1286 |
+
tree.xmlAddPrevSibling(c_node, element._c_node)
|
| 1287 |
+
_moveTail(c_next, element._c_node)
|
| 1288 |
+
|
| 1289 |
+
# integrate element into new document
|
| 1290 |
+
moveNodeToDocument(parent._doc, c_source_doc, element._c_node)
|
| 1291 |
+
|
| 1292 |
+
# stop at the end of the slice
|
| 1293 |
+
if slicelength > 0:
|
| 1294 |
+
slicelength -= 1
|
| 1295 |
+
for i in range(step):
|
| 1296 |
+
c_node = next_element(c_node)
|
| 1297 |
+
if c_node is NULL:
|
| 1298 |
+
break
|
| 1299 |
+
if c_node is NULL:
|
| 1300 |
+
break
|
| 1301 |
+
else:
|
| 1302 |
+
# everything inserted
|
| 1303 |
+
return 0
|
| 1304 |
+
|
| 1305 |
+
# append the remaining elements at the respective end
|
| 1306 |
+
if left_to_right:
|
| 1307 |
+
for element in elements:
|
| 1308 |
+
assert element is not None, "Node must not be None"
|
| 1309 |
+
_assertValidNode(element)
|
| 1310 |
+
_appendChild(parent, element)
|
| 1311 |
+
else:
|
| 1312 |
+
for element in elements:
|
| 1313 |
+
assert element is not None, "Node must not be None"
|
| 1314 |
+
_assertValidNode(element)
|
| 1315 |
+
_prependChild(parent, element)
|
| 1316 |
+
|
| 1317 |
+
return 0
|
| 1318 |
+
|
| 1319 |
+
|
| 1320 |
+
cdef int _linkChild(xmlNode* c_parent, xmlNode* c_node) except -1:
|
| 1321 |
+
"""Adaptation of 'xmlAddChild()' that deep-fix the document links iteratively.
|
| 1322 |
+
"""
|
| 1323 |
+
assert _isElement(c_node)
|
| 1324 |
+
c_node.parent = c_parent
|
| 1325 |
+
if c_parent.children is NULL:
|
| 1326 |
+
c_parent.children = c_parent.last = c_node
|
| 1327 |
+
else:
|
| 1328 |
+
c_node.prev = c_parent.last
|
| 1329 |
+
c_parent.last.next = c_node
|
| 1330 |
+
c_parent.last = c_node
|
| 1331 |
+
|
| 1332 |
+
_setTreeDoc(c_node, c_parent.doc)
|
| 1333 |
+
return 0
|
| 1334 |
+
|
| 1335 |
+
|
| 1336 |
+
cdef int _appendChild(_Element parent, _Element child) except -1:
|
| 1337 |
+
"""Append a new child to a parent element.
|
| 1338 |
+
"""
|
| 1339 |
+
c_node = child._c_node
|
| 1340 |
+
c_source_doc = c_node.doc
|
| 1341 |
+
# prevent cycles
|
| 1342 |
+
if _isAncestorOrSame(c_node, parent._c_node):
|
| 1343 |
+
raise ValueError("cannot append parent to itself")
|
| 1344 |
+
# store possible text node
|
| 1345 |
+
c_next = c_node.next
|
| 1346 |
+
# move node itself
|
| 1347 |
+
tree.xmlUnlinkNode(c_node)
|
| 1348 |
+
# do not call xmlAddChild() here since it would deep-traverse the tree
|
| 1349 |
+
_linkChild(parent._c_node, c_node)
|
| 1350 |
+
_moveTail(c_next, c_node)
|
| 1351 |
+
# uh oh, elements may be pointing to different doc when
|
| 1352 |
+
# parent element has moved; change them too..
|
| 1353 |
+
moveNodeToDocument(parent._doc, c_source_doc, c_node)
|
| 1354 |
+
return 0
|
| 1355 |
+
|
| 1356 |
+
cdef int _prependChild(_Element parent, _Element child) except -1:
|
| 1357 |
+
"""Prepend a new child to a parent element.
|
| 1358 |
+
"""
|
| 1359 |
+
c_node = child._c_node
|
| 1360 |
+
c_source_doc = c_node.doc
|
| 1361 |
+
# prevent cycles
|
| 1362 |
+
if _isAncestorOrSame(c_node, parent._c_node):
|
| 1363 |
+
raise ValueError("cannot append parent to itself")
|
| 1364 |
+
# store possible text node
|
| 1365 |
+
c_next = c_node.next
|
| 1366 |
+
# move node itself
|
| 1367 |
+
c_child = _findChildForwards(parent._c_node, 0)
|
| 1368 |
+
if c_child is NULL:
|
| 1369 |
+
tree.xmlUnlinkNode(c_node)
|
| 1370 |
+
# do not call xmlAddChild() here since it would deep-traverse the tree
|
| 1371 |
+
_linkChild(parent._c_node, c_node)
|
| 1372 |
+
else:
|
| 1373 |
+
tree.xmlAddPrevSibling(c_child, c_node)
|
| 1374 |
+
_moveTail(c_next, c_node)
|
| 1375 |
+
# uh oh, elements may be pointing to different doc when
|
| 1376 |
+
# parent element has moved; change them too..
|
| 1377 |
+
moveNodeToDocument(parent._doc, c_source_doc, c_node)
|
| 1378 |
+
return 0
|
| 1379 |
+
|
| 1380 |
+
cdef int _appendSibling(_Element element, _Element sibling) except -1:
|
| 1381 |
+
"""Add a new sibling behind an element.
|
| 1382 |
+
"""
|
| 1383 |
+
return _addSibling(element, sibling, as_next=True)
|
| 1384 |
+
|
| 1385 |
+
cdef int _prependSibling(_Element element, _Element sibling) except -1:
|
| 1386 |
+
"""Add a new sibling before an element.
|
| 1387 |
+
"""
|
| 1388 |
+
return _addSibling(element, sibling, as_next=False)
|
| 1389 |
+
|
| 1390 |
+
cdef int _addSibling(_Element element, _Element sibling, bint as_next) except -1:
|
| 1391 |
+
c_node = sibling._c_node
|
| 1392 |
+
c_source_doc = c_node.doc
|
| 1393 |
+
# prevent cycles
|
| 1394 |
+
if _isAncestorOrSame(c_node, element._c_node):
|
| 1395 |
+
if element._c_node is c_node:
|
| 1396 |
+
return 0 # nothing to do
|
| 1397 |
+
raise ValueError("cannot add ancestor as sibling, please break cycle first")
|
| 1398 |
+
# store possible text node
|
| 1399 |
+
c_next = c_node.next
|
| 1400 |
+
# move node itself
|
| 1401 |
+
if as_next:
|
| 1402 |
+
# must insert after any tail text
|
| 1403 |
+
c_next_node = _nextElement(element._c_node)
|
| 1404 |
+
if c_next_node is NULL:
|
| 1405 |
+
c_next_node = element._c_node
|
| 1406 |
+
while c_next_node.next:
|
| 1407 |
+
c_next_node = c_next_node.next
|
| 1408 |
+
tree.xmlAddNextSibling(c_next_node, c_node)
|
| 1409 |
+
else:
|
| 1410 |
+
tree.xmlAddPrevSibling(c_next_node, c_node)
|
| 1411 |
+
else:
|
| 1412 |
+
tree.xmlAddPrevSibling(element._c_node, c_node)
|
| 1413 |
+
_moveTail(c_next, c_node)
|
| 1414 |
+
# uh oh, elements may be pointing to different doc when
|
| 1415 |
+
# parent element has moved; change them too..
|
| 1416 |
+
moveNodeToDocument(element._doc, c_source_doc, c_node)
|
| 1417 |
+
return 0
|
| 1418 |
+
|
| 1419 |
+
cdef inline bint isutf8(const_xmlChar* s) noexcept:
|
| 1420 |
+
cdef xmlChar c = s[0]
|
| 1421 |
+
while c != c'\0':
|
| 1422 |
+
if c & 0x80:
|
| 1423 |
+
return True
|
| 1424 |
+
s += 1
|
| 1425 |
+
c = s[0]
|
| 1426 |
+
return False
|
| 1427 |
+
|
| 1428 |
+
cdef bint isutf8l(const_xmlChar* s, size_t length) noexcept:
|
| 1429 |
+
"""
|
| 1430 |
+
Search for non-ASCII characters in the string, knowing its length in advance.
|
| 1431 |
+
"""
|
| 1432 |
+
cdef unsigned int i
|
| 1433 |
+
cdef unsigned long non_ascii_mask
|
| 1434 |
+
cdef const unsigned long *lptr = <const unsigned long*> s
|
| 1435 |
+
|
| 1436 |
+
cdef const unsigned long *end = lptr + length // sizeof(unsigned long)
|
| 1437 |
+
if length >= sizeof(non_ascii_mask):
|
| 1438 |
+
# Build constant 0x80808080... mask (and let the C compiler fold it).
|
| 1439 |
+
non_ascii_mask = 0
|
| 1440 |
+
for i in range(sizeof(non_ascii_mask) // 2):
|
| 1441 |
+
non_ascii_mask = (non_ascii_mask << 16) | 0x8080
|
| 1442 |
+
|
| 1443 |
+
# Advance to long-aligned character before we start reading longs.
|
| 1444 |
+
while (<size_t>s) % sizeof(unsigned long) and s < <const_xmlChar *>end:
|
| 1445 |
+
if s[0] & 0x80:
|
| 1446 |
+
return True
|
| 1447 |
+
s += 1
|
| 1448 |
+
|
| 1449 |
+
# Read one long at a time
|
| 1450 |
+
lptr = <const unsigned long*> s
|
| 1451 |
+
while lptr < end:
|
| 1452 |
+
if lptr[0] & non_ascii_mask:
|
| 1453 |
+
return True
|
| 1454 |
+
lptr += 1
|
| 1455 |
+
s = <const_xmlChar *>lptr
|
| 1456 |
+
|
| 1457 |
+
while s < (<const_xmlChar *>end + length % sizeof(unsigned long)):
|
| 1458 |
+
if s[0] & 0x80:
|
| 1459 |
+
return True
|
| 1460 |
+
s += 1
|
| 1461 |
+
|
| 1462 |
+
return False
|
| 1463 |
+
|
| 1464 |
+
cdef int _is_valid_xml_ascii(bytes pystring) except -1:
|
| 1465 |
+
"""Check if a string is XML ascii content."""
|
| 1466 |
+
cdef signed char ch
|
| 1467 |
+
# When ch is a *signed* char, non-ascii characters are negative integers
|
| 1468 |
+
# and xmlIsChar_ch does not accept them.
|
| 1469 |
+
for ch in pystring:
|
| 1470 |
+
if not tree.xmlIsChar_ch(ch):
|
| 1471 |
+
return 0
|
| 1472 |
+
return 1
|
| 1473 |
+
|
| 1474 |
+
cdef bint _is_valid_xml_utf8(bytes pystring) except -1:
|
| 1475 |
+
"""Check if a string is like valid UTF-8 XML content."""
|
| 1476 |
+
cdef const_xmlChar* s = _xcstr(pystring)
|
| 1477 |
+
cdef const_xmlChar* c_end = s + len(pystring)
|
| 1478 |
+
cdef unsigned long next3 = 0
|
| 1479 |
+
if s < c_end - 2:
|
| 1480 |
+
next3 = (s[0] << 8) | (s[1])
|
| 1481 |
+
|
| 1482 |
+
while s < c_end - 2:
|
| 1483 |
+
next3 = 0x00ffffff & ((next3 << 8) | s[2])
|
| 1484 |
+
if s[0] & 0x80:
|
| 1485 |
+
# 0xefbfbe and 0xefbfbf are utf-8 encodings of
|
| 1486 |
+
# forbidden characters \ufffe and \uffff
|
| 1487 |
+
if next3 == 0x00efbfbe or next3 == 0x00efbfbf:
|
| 1488 |
+
return 0
|
| 1489 |
+
# 0xeda080 and 0xedbfbf are utf-8 encodings of
|
| 1490 |
+
# \ud800 and \udfff. Anything between them (inclusive)
|
| 1491 |
+
# is forbidden, because they are surrogate blocks in utf-16.
|
| 1492 |
+
if 0x00eda080 <= next3 <= 0x00edbfbf:
|
| 1493 |
+
return 0
|
| 1494 |
+
elif not tree.xmlIsChar_ch(s[0]):
|
| 1495 |
+
return 0 # invalid ascii char
|
| 1496 |
+
s += 1
|
| 1497 |
+
|
| 1498 |
+
while s < c_end:
|
| 1499 |
+
if not s[0] & 0x80 and not tree.xmlIsChar_ch(s[0]):
|
| 1500 |
+
return 0 # invalid ascii char
|
| 1501 |
+
s += 1
|
| 1502 |
+
|
| 1503 |
+
return 1
|
| 1504 |
+
|
| 1505 |
+
cdef inline unicode funicodeOrNone(const_xmlChar* s):
|
| 1506 |
+
return funicode(s) if s is not NULL else None
|
| 1507 |
+
|
| 1508 |
+
cdef inline unicode funicodeOrEmpty(const_xmlChar* s):
|
| 1509 |
+
return funicode(s) if s is not NULL else ''
|
| 1510 |
+
|
| 1511 |
+
cdef unicode funicode(const_xmlChar* s):
|
| 1512 |
+
return s.decode('UTF-8')
|
| 1513 |
+
|
| 1514 |
+
cdef bytes _utf8(object s):
|
| 1515 |
+
"""Test if a string is valid user input and encode it to UTF-8.
|
| 1516 |
+
Reject all bytes/unicode input that contains non-XML characters.
|
| 1517 |
+
Reject all bytes input that contains non-ASCII characters.
|
| 1518 |
+
"""
|
| 1519 |
+
cdef int valid
|
| 1520 |
+
cdef bytes utf8_string
|
| 1521 |
+
if isinstance(s, unicode):
|
| 1522 |
+
utf8_string = (<unicode>s).encode('utf8')
|
| 1523 |
+
valid = _is_valid_xml_utf8(utf8_string)
|
| 1524 |
+
elif isinstance(s, (bytes, bytearray)):
|
| 1525 |
+
utf8_string = s if type(s) is bytes else bytes(s)
|
| 1526 |
+
valid = _is_valid_xml_ascii(utf8_string)
|
| 1527 |
+
else:
|
| 1528 |
+
raise TypeError("Argument must be bytes or unicode, got '%.200s'" % type(s).__name__)
|
| 1529 |
+
if not valid:
|
| 1530 |
+
raise ValueError(
|
| 1531 |
+
"All strings must be XML compatible: Unicode or ASCII, no NULL bytes or control characters")
|
| 1532 |
+
return utf8_string
|
| 1533 |
+
|
| 1534 |
+
|
| 1535 |
+
cdef bytes _utf8orNone(object s):
|
| 1536 |
+
return _utf8(s) if s is not None else None
|
| 1537 |
+
|
| 1538 |
+
|
| 1539 |
+
cdef enum:
|
| 1540 |
+
NO_FILE_PATH = 0
|
| 1541 |
+
ABS_UNIX_FILE_PATH = 1
|
| 1542 |
+
ABS_WIN_FILE_PATH = 2
|
| 1543 |
+
REL_FILE_PATH = 3
|
| 1544 |
+
|
| 1545 |
+
|
| 1546 |
+
cdef bint _isFilePath(const_xmlChar* c_path) noexcept:
|
| 1547 |
+
"simple heuristic to see if a path is a filename"
|
| 1548 |
+
cdef xmlChar c
|
| 1549 |
+
# test if it looks like an absolute Unix path or a Windows network path
|
| 1550 |
+
if c_path[0] == c'/':
|
| 1551 |
+
return ABS_UNIX_FILE_PATH
|
| 1552 |
+
|
| 1553 |
+
# test if it looks like an absolute Windows path or URL
|
| 1554 |
+
if c'a' <= c_path[0] <= c'z' or c'A' <= c_path[0] <= c'Z':
|
| 1555 |
+
c_path += 1
|
| 1556 |
+
if c_path[0] == c':' and c_path[1] in b'\0\\':
|
| 1557 |
+
return ABS_WIN_FILE_PATH # C: or C:\...
|
| 1558 |
+
|
| 1559 |
+
# test if it looks like a URL with scheme://
|
| 1560 |
+
while c'a' <= c_path[0] <= c'z' or c'A' <= c_path[0] <= c'Z':
|
| 1561 |
+
c_path += 1
|
| 1562 |
+
if c_path[0] == c':' and c_path[1] == c'/' and c_path[2] == c'/':
|
| 1563 |
+
return NO_FILE_PATH
|
| 1564 |
+
|
| 1565 |
+
# assume it's a relative path
|
| 1566 |
+
return REL_FILE_PATH
|
| 1567 |
+
|
| 1568 |
+
|
| 1569 |
+
cdef object _getFSPathOrObject(object obj):
|
| 1570 |
+
"""
|
| 1571 |
+
Get the __fspath__ attribute of an object if it exists.
|
| 1572 |
+
Otherwise, the original object is returned.
|
| 1573 |
+
"""
|
| 1574 |
+
if _isString(obj):
|
| 1575 |
+
return obj
|
| 1576 |
+
try:
|
| 1577 |
+
return python.PyOS_FSPath(obj)
|
| 1578 |
+
except TypeError:
|
| 1579 |
+
return obj
|
| 1580 |
+
|
| 1581 |
+
|
| 1582 |
+
cdef object _encodeFilename(object filename):
|
| 1583 |
+
"""Make sure a filename is 8-bit encoded (or None).
|
| 1584 |
+
"""
|
| 1585 |
+
if filename is None:
|
| 1586 |
+
return None
|
| 1587 |
+
elif isinstance(filename, bytes):
|
| 1588 |
+
return filename
|
| 1589 |
+
elif isinstance(filename, unicode):
|
| 1590 |
+
filename8 = (<unicode>filename).encode('utf8')
|
| 1591 |
+
if _isFilePath(<unsigned char*>filename8):
|
| 1592 |
+
try:
|
| 1593 |
+
return python.PyUnicode_AsEncodedString(
|
| 1594 |
+
filename, _C_FILENAME_ENCODING, NULL)
|
| 1595 |
+
except UnicodeEncodeError:
|
| 1596 |
+
pass
|
| 1597 |
+
return filename8
|
| 1598 |
+
else:
|
| 1599 |
+
raise TypeError("Argument must be string or unicode.")
|
| 1600 |
+
|
| 1601 |
+
cdef object _decodeFilename(const_xmlChar* c_path):
|
| 1602 |
+
"""Make the filename a unicode string if we are in Py3.
|
| 1603 |
+
"""
|
| 1604 |
+
return _decodeFilenameWithLength(c_path, tree.xmlStrlen(c_path))
|
| 1605 |
+
|
| 1606 |
+
cdef object _decodeFilenameWithLength(const_xmlChar* c_path, size_t c_len):
|
| 1607 |
+
"""Make the filename a unicode string if we are in Py3.
|
| 1608 |
+
"""
|
| 1609 |
+
if _isFilePath(c_path):
|
| 1610 |
+
try:
|
| 1611 |
+
return python.PyUnicode_Decode(
|
| 1612 |
+
<const_char*>c_path, c_len, _C_FILENAME_ENCODING, NULL)
|
| 1613 |
+
except UnicodeDecodeError:
|
| 1614 |
+
pass
|
| 1615 |
+
try:
|
| 1616 |
+
return (<unsigned char*>c_path)[:c_len].decode('UTF-8')
|
| 1617 |
+
except UnicodeDecodeError:
|
| 1618 |
+
# this is a stupid fallback, but it might still work...
|
| 1619 |
+
return (<unsigned char*>c_path)[:c_len].decode('latin-1', 'replace')
|
| 1620 |
+
|
| 1621 |
+
cdef object _encodeFilenameUTF8(object filename):
|
| 1622 |
+
"""Recode filename as UTF-8. Tries ASCII, local filesystem encoding and
|
| 1623 |
+
UTF-8 as source encoding.
|
| 1624 |
+
"""
|
| 1625 |
+
cdef char* c_filename
|
| 1626 |
+
if filename is None:
|
| 1627 |
+
return None
|
| 1628 |
+
elif isinstance(filename, bytes):
|
| 1629 |
+
if not isutf8l(<bytes>filename, len(<bytes>filename)):
|
| 1630 |
+
# plain ASCII!
|
| 1631 |
+
return filename
|
| 1632 |
+
c_filename = _cstr(<bytes>filename)
|
| 1633 |
+
try:
|
| 1634 |
+
# try to decode with default encoding
|
| 1635 |
+
filename = python.PyUnicode_Decode(
|
| 1636 |
+
c_filename, len(<bytes>filename),
|
| 1637 |
+
_C_FILENAME_ENCODING, NULL)
|
| 1638 |
+
except UnicodeDecodeError as decode_exc:
|
| 1639 |
+
try:
|
| 1640 |
+
# try if it's proper UTF-8
|
| 1641 |
+
(<bytes>filename).decode('utf8')
|
| 1642 |
+
return filename
|
| 1643 |
+
except UnicodeDecodeError:
|
| 1644 |
+
raise decode_exc # otherwise re-raise original exception
|
| 1645 |
+
if isinstance(filename, unicode):
|
| 1646 |
+
return (<unicode>filename).encode('utf8')
|
| 1647 |
+
else:
|
| 1648 |
+
raise TypeError("Argument must be string or unicode.")
|
| 1649 |
+
|
| 1650 |
+
cdef tuple _getNsTag(tag):
|
| 1651 |
+
"""Given a tag, find namespace URI and tag name.
|
| 1652 |
+
Return None for NS uri if no namespace URI provided.
|
| 1653 |
+
"""
|
| 1654 |
+
return __getNsTag(tag, 0)
|
| 1655 |
+
|
| 1656 |
+
cdef tuple _getNsTagWithEmptyNs(tag):
|
| 1657 |
+
"""Given a tag, find namespace URI and tag name. Return None for NS uri
|
| 1658 |
+
if no namespace URI provided, or the empty string if namespace
|
| 1659 |
+
part is '{}'.
|
| 1660 |
+
"""
|
| 1661 |
+
return __getNsTag(tag, 1)
|
| 1662 |
+
|
| 1663 |
+
cdef tuple __getNsTag(tag, bint empty_ns):
|
| 1664 |
+
cdef char* c_tag
|
| 1665 |
+
cdef char* c_ns_end
|
| 1666 |
+
cdef Py_ssize_t taglen
|
| 1667 |
+
cdef Py_ssize_t nslen
|
| 1668 |
+
cdef bytes ns = None
|
| 1669 |
+
# _isString() is much faster than isinstance()
|
| 1670 |
+
if not _isString(tag) and isinstance(tag, QName):
|
| 1671 |
+
tag = (<QName>tag).text
|
| 1672 |
+
tag = _utf8(tag)
|
| 1673 |
+
c_tag = _cstr(tag)
|
| 1674 |
+
if c_tag[0] == c'{':
|
| 1675 |
+
c_tag += 1
|
| 1676 |
+
c_ns_end = cstring_h.strchr(c_tag, c'}')
|
| 1677 |
+
if c_ns_end is NULL:
|
| 1678 |
+
raise ValueError, "Invalid tag name"
|
| 1679 |
+
nslen = c_ns_end - c_tag
|
| 1680 |
+
taglen = python.PyBytes_GET_SIZE(tag) - nslen - 2
|
| 1681 |
+
if taglen == 0:
|
| 1682 |
+
raise ValueError, "Empty tag name"
|
| 1683 |
+
if nslen > 0:
|
| 1684 |
+
ns = <bytes>c_tag[:nslen]
|
| 1685 |
+
elif empty_ns:
|
| 1686 |
+
ns = b''
|
| 1687 |
+
tag = <bytes>c_ns_end[1:taglen+1]
|
| 1688 |
+
elif python.PyBytes_GET_SIZE(tag) == 0:
|
| 1689 |
+
raise ValueError, "Empty tag name"
|
| 1690 |
+
return ns, tag
|
| 1691 |
+
|
| 1692 |
+
cdef inline int _pyXmlNameIsValid(name_utf8):
|
| 1693 |
+
return _xmlNameIsValid(_xcstr(name_utf8)) and b':' not in name_utf8
|
| 1694 |
+
|
| 1695 |
+
cdef inline int _pyHtmlNameIsValid(name_utf8):
|
| 1696 |
+
return _htmlNameIsValid(_xcstr(name_utf8))
|
| 1697 |
+
|
| 1698 |
+
cdef inline int _xmlNameIsValid(const_xmlChar* c_name) noexcept:
|
| 1699 |
+
return tree.xmlValidateNameValue(c_name)
|
| 1700 |
+
|
| 1701 |
+
cdef int _htmlNameIsValid(const_xmlChar* c_name) noexcept:
|
| 1702 |
+
if c_name is NULL or c_name[0] == c'\0':
|
| 1703 |
+
return 0
|
| 1704 |
+
while c_name[0] != c'\0':
|
| 1705 |
+
if c_name[0] in b'&<>/"\'\t\n\x0B\x0C\r ':
|
| 1706 |
+
return 0
|
| 1707 |
+
c_name += 1
|
| 1708 |
+
return 1
|
| 1709 |
+
|
| 1710 |
+
cdef bint _characterReferenceIsValid(const_xmlChar* c_name) noexcept:
|
| 1711 |
+
cdef bint is_hex
|
| 1712 |
+
if c_name[0] == c'x':
|
| 1713 |
+
c_name += 1
|
| 1714 |
+
is_hex = 1
|
| 1715 |
+
else:
|
| 1716 |
+
is_hex = 0
|
| 1717 |
+
if c_name[0] == c'\0':
|
| 1718 |
+
return 0
|
| 1719 |
+
while c_name[0] != c'\0':
|
| 1720 |
+
if c_name[0] < c'0' or c_name[0] > c'9':
|
| 1721 |
+
if not is_hex:
|
| 1722 |
+
return 0
|
| 1723 |
+
if not (c'a' <= c_name[0] <= c'f'):
|
| 1724 |
+
if not (c'A' <= c_name[0] <= c'F'):
|
| 1725 |
+
return 0
|
| 1726 |
+
c_name += 1
|
| 1727 |
+
return 1
|
| 1728 |
+
|
| 1729 |
+
cdef int _tagValidOrRaise(tag_utf) except -1:
|
| 1730 |
+
if not _pyXmlNameIsValid(tag_utf):
|
| 1731 |
+
raise ValueError(f"Invalid tag name {(<bytes>tag_utf).decode('utf8')!r}")
|
| 1732 |
+
return 0
|
| 1733 |
+
|
| 1734 |
+
cdef int _htmlTagValidOrRaise(tag_utf) except -1:
|
| 1735 |
+
if not _pyHtmlNameIsValid(tag_utf):
|
| 1736 |
+
raise ValueError(f"Invalid HTML tag name {(<bytes>tag_utf).decode('utf8')!r}")
|
| 1737 |
+
return 0
|
| 1738 |
+
|
| 1739 |
+
cdef int _attributeValidOrRaise(name_utf) except -1:
|
| 1740 |
+
if not _pyXmlNameIsValid(name_utf):
|
| 1741 |
+
raise ValueError(f"Invalid attribute name {(<bytes>name_utf).decode('utf8')!r}")
|
| 1742 |
+
return 0
|
| 1743 |
+
|
| 1744 |
+
cdef int _prefixValidOrRaise(tag_utf) except -1:
|
| 1745 |
+
if not _pyXmlNameIsValid(tag_utf):
|
| 1746 |
+
raise ValueError(f"Invalid namespace prefix {(<bytes>tag_utf).decode('utf8')!r}")
|
| 1747 |
+
return 0
|
| 1748 |
+
|
| 1749 |
+
cdef int _uriValidOrRaise(uri_utf) except -1:
|
| 1750 |
+
cdef uri.xmlURI* c_uri = uri.xmlParseURI(_cstr(uri_utf))
|
| 1751 |
+
if c_uri is NULL:
|
| 1752 |
+
raise ValueError(f"Invalid namespace URI {(<bytes>uri_utf).decode('utf8')!r}")
|
| 1753 |
+
uri.xmlFreeURI(c_uri)
|
| 1754 |
+
return 0
|
| 1755 |
+
|
| 1756 |
+
cdef inline unicode _namespacedName(xmlNode* c_node):
|
| 1757 |
+
return _namespacedNameFromNsName(_getNs(c_node), c_node.name)
|
| 1758 |
+
|
| 1759 |
+
|
| 1760 |
+
cdef unicode _namespacedNameFromNsName(const_xmlChar* c_href, const_xmlChar* c_name):
|
| 1761 |
+
name = funicode(c_name)
|
| 1762 |
+
if c_href is NULL:
|
| 1763 |
+
return name
|
| 1764 |
+
href = funicode(c_href)
|
| 1765 |
+
return f"{{{href}}}{name}"
|
| 1766 |
+
|
| 1767 |
+
|
| 1768 |
+
cdef _getFilenameForFile(source):
|
| 1769 |
+
"""Given a Python File or Gzip object, give filename back.
|
| 1770 |
+
|
| 1771 |
+
Returns None if not a file object.
|
| 1772 |
+
"""
|
| 1773 |
+
# urllib2 provides a geturl() method
|
| 1774 |
+
try:
|
| 1775 |
+
return source.geturl()
|
| 1776 |
+
except:
|
| 1777 |
+
pass
|
| 1778 |
+
# file instances have a name attribute
|
| 1779 |
+
try:
|
| 1780 |
+
filename = source.name
|
| 1781 |
+
if _isString(filename):
|
| 1782 |
+
return os_path_abspath(filename)
|
| 1783 |
+
except:
|
| 1784 |
+
pass
|
| 1785 |
+
# gzip file instances have a filename attribute (before Py3k)
|
| 1786 |
+
try:
|
| 1787 |
+
filename = source.filename
|
| 1788 |
+
if _isString(filename):
|
| 1789 |
+
return os_path_abspath(filename)
|
| 1790 |
+
except:
|
| 1791 |
+
pass
|
| 1792 |
+
# can't determine filename
|
| 1793 |
+
return None
|
omnilmm/lib/python3.10/site-packages/lxml/builder.cpython-310-x86_64-linux-gnu.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1f2b95d4289fda3eba6bb74e4e85b674309f12a24a78cb9b02186bc2a6968496
|
| 3 |
+
size 112416
|
omnilmm/lib/python3.10/site-packages/lxml/builder.py
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# cython: language_level=2
|
| 2 |
+
|
| 3 |
+
#
|
| 4 |
+
# Element generator factory by Fredrik Lundh.
|
| 5 |
+
#
|
| 6 |
+
# Source:
|
| 7 |
+
# http://online.effbot.org/2006_11_01_archive.htm#et-builder
|
| 8 |
+
# http://effbot.python-hosting.com/file/stuff/sandbox/elementlib/builder.py
|
| 9 |
+
#
|
| 10 |
+
# --------------------------------------------------------------------
|
| 11 |
+
# The ElementTree toolkit is
|
| 12 |
+
#
|
| 13 |
+
# Copyright (c) 1999-2004 by Fredrik Lundh
|
| 14 |
+
#
|
| 15 |
+
# By obtaining, using, and/or copying this software and/or its
|
| 16 |
+
# associated documentation, you agree that you have read, understood,
|
| 17 |
+
# and will comply with the following terms and conditions:
|
| 18 |
+
#
|
| 19 |
+
# Permission to use, copy, modify, and distribute this software and
|
| 20 |
+
# its associated documentation for any purpose and without fee is
|
| 21 |
+
# hereby granted, provided that the above copyright notice appears in
|
| 22 |
+
# all copies, and that both that copyright notice and this permission
|
| 23 |
+
# notice appear in supporting documentation, and that the name of
|
| 24 |
+
# Secret Labs AB or the author not be used in advertising or publicity
|
| 25 |
+
# pertaining to distribution of the software without specific, written
|
| 26 |
+
# prior permission.
|
| 27 |
+
#
|
| 28 |
+
# SECRET LABS AB AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
|
| 29 |
+
# TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT-
|
| 30 |
+
# ABILITY AND FITNESS. IN NO EVENT SHALL SECRET LABS AB OR THE AUTHOR
|
| 31 |
+
# BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
|
| 32 |
+
# DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 33 |
+
# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
| 34 |
+
# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 35 |
+
# OF THIS SOFTWARE.
|
| 36 |
+
# --------------------------------------------------------------------
|
| 37 |
+
|
| 38 |
+
"""
|
| 39 |
+
The ``E`` Element factory for generating XML documents.
|
| 40 |
+
"""
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
import lxml.etree as ET
|
| 44 |
+
_QName = ET.QName
|
| 45 |
+
|
| 46 |
+
from functools import partial
|
| 47 |
+
|
| 48 |
+
try:
|
| 49 |
+
basestring
|
| 50 |
+
except NameError:
|
| 51 |
+
basestring = str
|
| 52 |
+
|
| 53 |
+
try:
|
| 54 |
+
unicode
|
| 55 |
+
except NameError:
|
| 56 |
+
unicode = str
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
class ElementMaker:
|
| 60 |
+
"""Element generator factory.
|
| 61 |
+
|
| 62 |
+
Unlike the ordinary Element factory, the E factory allows you to pass in
|
| 63 |
+
more than just a tag and some optional attributes; you can also pass in
|
| 64 |
+
text and other elements. The text is added as either text or tail
|
| 65 |
+
attributes, and elements are inserted at the right spot. Some small
|
| 66 |
+
examples::
|
| 67 |
+
|
| 68 |
+
>>> from lxml import etree as ET
|
| 69 |
+
>>> from lxml.builder import E
|
| 70 |
+
|
| 71 |
+
>>> ET.tostring(E("tag"))
|
| 72 |
+
'<tag/>'
|
| 73 |
+
>>> ET.tostring(E("tag", "text"))
|
| 74 |
+
'<tag>text</tag>'
|
| 75 |
+
>>> ET.tostring(E("tag", "text", key="value"))
|
| 76 |
+
'<tag key="value">text</tag>'
|
| 77 |
+
>>> ET.tostring(E("tag", E("subtag", "text"), "tail"))
|
| 78 |
+
'<tag><subtag>text</subtag>tail</tag>'
|
| 79 |
+
|
| 80 |
+
For simple tags, the factory also allows you to write ``E.tag(...)`` instead
|
| 81 |
+
of ``E('tag', ...)``::
|
| 82 |
+
|
| 83 |
+
>>> ET.tostring(E.tag())
|
| 84 |
+
'<tag/>'
|
| 85 |
+
>>> ET.tostring(E.tag("text"))
|
| 86 |
+
'<tag>text</tag>'
|
| 87 |
+
>>> ET.tostring(E.tag(E.subtag("text"), "tail"))
|
| 88 |
+
'<tag><subtag>text</subtag>tail</tag>'
|
| 89 |
+
|
| 90 |
+
Here's a somewhat larger example; this shows how to generate HTML
|
| 91 |
+
documents, using a mix of prepared factory functions for inline elements,
|
| 92 |
+
nested ``E.tag`` calls, and embedded XHTML fragments::
|
| 93 |
+
|
| 94 |
+
# some common inline elements
|
| 95 |
+
A = E.a
|
| 96 |
+
I = E.i
|
| 97 |
+
B = E.b
|
| 98 |
+
|
| 99 |
+
def CLASS(v):
|
| 100 |
+
# helper function, 'class' is a reserved word
|
| 101 |
+
return {'class': v}
|
| 102 |
+
|
| 103 |
+
page = (
|
| 104 |
+
E.html(
|
| 105 |
+
E.head(
|
| 106 |
+
E.title("This is a sample document")
|
| 107 |
+
),
|
| 108 |
+
E.body(
|
| 109 |
+
E.h1("Hello!", CLASS("title")),
|
| 110 |
+
E.p("This is a paragraph with ", B("bold"), " text in it!"),
|
| 111 |
+
E.p("This is another paragraph, with a ",
|
| 112 |
+
A("link", href="http://www.python.org"), "."),
|
| 113 |
+
E.p("Here are some reserved characters: <spam&egg>."),
|
| 114 |
+
ET.XML("<p>And finally, here is an embedded XHTML fragment.</p>"),
|
| 115 |
+
)
|
| 116 |
+
)
|
| 117 |
+
)
|
| 118 |
+
|
| 119 |
+
print ET.tostring(page)
|
| 120 |
+
|
| 121 |
+
Here's a prettyprinted version of the output from the above script::
|
| 122 |
+
|
| 123 |
+
<html>
|
| 124 |
+
<head>
|
| 125 |
+
<title>This is a sample document</title>
|
| 126 |
+
</head>
|
| 127 |
+
<body>
|
| 128 |
+
<h1 class="title">Hello!</h1>
|
| 129 |
+
<p>This is a paragraph with <b>bold</b> text in it!</p>
|
| 130 |
+
<p>This is another paragraph, with <a href="http://www.python.org">link</a>.</p>
|
| 131 |
+
<p>Here are some reserved characters: <spam&egg>.</p>
|
| 132 |
+
<p>And finally, here is an embedded XHTML fragment.</p>
|
| 133 |
+
</body>
|
| 134 |
+
</html>
|
| 135 |
+
|
| 136 |
+
For namespace support, you can pass a namespace map (``nsmap``)
|
| 137 |
+
and/or a specific target ``namespace`` to the ElementMaker class::
|
| 138 |
+
|
| 139 |
+
>>> E = ElementMaker(namespace="http://my.ns/")
|
| 140 |
+
>>> print(ET.tostring( E.test ))
|
| 141 |
+
<test xmlns="http://my.ns/"/>
|
| 142 |
+
|
| 143 |
+
>>> E = ElementMaker(namespace="http://my.ns/", nsmap={'p':'http://my.ns/'})
|
| 144 |
+
>>> print(ET.tostring( E.test ))
|
| 145 |
+
<p:test xmlns:p="http://my.ns/"/>
|
| 146 |
+
"""
|
| 147 |
+
|
| 148 |
+
def __init__(self, typemap=None,
|
| 149 |
+
namespace=None, nsmap=None, makeelement=None):
|
| 150 |
+
self._namespace = '{' + namespace + '}' if namespace is not None else None
|
| 151 |
+
self._nsmap = dict(nsmap) if nsmap else None
|
| 152 |
+
|
| 153 |
+
assert makeelement is None or callable(makeelement)
|
| 154 |
+
self._makeelement = makeelement if makeelement is not None else ET.Element
|
| 155 |
+
|
| 156 |
+
# initialize the default type map functions for this element factory
|
| 157 |
+
typemap = dict(typemap) if typemap else {}
|
| 158 |
+
|
| 159 |
+
def add_text(elem, item):
|
| 160 |
+
try:
|
| 161 |
+
last_child = elem[-1]
|
| 162 |
+
except IndexError:
|
| 163 |
+
elem.text = (elem.text or "") + item
|
| 164 |
+
else:
|
| 165 |
+
last_child.tail = (last_child.tail or "") + item
|
| 166 |
+
|
| 167 |
+
def add_cdata(elem, cdata):
|
| 168 |
+
if elem.text:
|
| 169 |
+
raise ValueError("Can't add a CDATA section. Element already has some text: %r" % elem.text)
|
| 170 |
+
elem.text = cdata
|
| 171 |
+
|
| 172 |
+
if str not in typemap:
|
| 173 |
+
typemap[str] = add_text
|
| 174 |
+
if unicode not in typemap:
|
| 175 |
+
typemap[unicode] = add_text
|
| 176 |
+
if ET.CDATA not in typemap:
|
| 177 |
+
typemap[ET.CDATA] = add_cdata
|
| 178 |
+
|
| 179 |
+
def add_dict(elem, item):
|
| 180 |
+
attrib = elem.attrib
|
| 181 |
+
for k, v in item.items():
|
| 182 |
+
if isinstance(v, basestring):
|
| 183 |
+
attrib[k] = v
|
| 184 |
+
else:
|
| 185 |
+
attrib[k] = typemap[type(v)](None, v)
|
| 186 |
+
|
| 187 |
+
if dict not in typemap:
|
| 188 |
+
typemap[dict] = add_dict
|
| 189 |
+
|
| 190 |
+
self._typemap = typemap
|
| 191 |
+
|
| 192 |
+
def __call__(self, tag, *children, **attrib):
|
| 193 |
+
typemap = self._typemap
|
| 194 |
+
|
| 195 |
+
# We'll usually get a 'str', and the compiled type check is very fast.
|
| 196 |
+
if not isinstance(tag, str) and isinstance(tag, _QName):
|
| 197 |
+
# A QName is explicitly qualified, do not look at self._namespace.
|
| 198 |
+
tag = tag.text
|
| 199 |
+
elif self._namespace is not None and tag[0] != '{':
|
| 200 |
+
tag = self._namespace + tag
|
| 201 |
+
elem = self._makeelement(tag, nsmap=self._nsmap)
|
| 202 |
+
if attrib:
|
| 203 |
+
typemap[dict](elem, attrib)
|
| 204 |
+
|
| 205 |
+
for item in children:
|
| 206 |
+
if callable(item):
|
| 207 |
+
item = item()
|
| 208 |
+
t = typemap.get(type(item))
|
| 209 |
+
if t is None:
|
| 210 |
+
if ET.iselement(item):
|
| 211 |
+
elem.append(item)
|
| 212 |
+
continue
|
| 213 |
+
for basetype in type(item).__mro__:
|
| 214 |
+
# See if the typemap knows of any of this type's bases.
|
| 215 |
+
t = typemap.get(basetype)
|
| 216 |
+
if t is not None:
|
| 217 |
+
break
|
| 218 |
+
else:
|
| 219 |
+
raise TypeError("bad argument type: %s(%r)" %
|
| 220 |
+
(type(item).__name__, item))
|
| 221 |
+
v = t(elem, item)
|
| 222 |
+
if v:
|
| 223 |
+
typemap.get(type(v))(elem, v)
|
| 224 |
+
|
| 225 |
+
return elem
|
| 226 |
+
|
| 227 |
+
def __getattr__(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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Configurable Element class lookup
|
| 2 |
+
|
| 3 |
+
################################################################################
|
| 4 |
+
# Custom Element classes
|
| 5 |
+
|
| 6 |
+
cdef public class ElementBase(_Element) [ type LxmlElementBaseType,
|
| 7 |
+
object LxmlElementBase ]:
|
| 8 |
+
"""ElementBase(*children, attrib=None, nsmap=None, **_extra)
|
| 9 |
+
|
| 10 |
+
The public Element class. All custom Element classes must inherit
|
| 11 |
+
from this one. To create an Element, use the `Element()` factory.
|
| 12 |
+
|
| 13 |
+
BIG FAT WARNING: Subclasses *must not* override __init__ or
|
| 14 |
+
__new__ as it is absolutely undefined when these objects will be
|
| 15 |
+
created or destroyed. All persistent state of Elements must be
|
| 16 |
+
stored in the underlying XML. If you really need to initialize
|
| 17 |
+
the object after creation, you can implement an ``_init(self)``
|
| 18 |
+
method that will be called directly after object creation.
|
| 19 |
+
|
| 20 |
+
Subclasses of this class can be instantiated to create a new
|
| 21 |
+
Element. By default, the tag name will be the class name and the
|
| 22 |
+
namespace will be empty. You can modify this with the following
|
| 23 |
+
class attributes:
|
| 24 |
+
|
| 25 |
+
* TAG - the tag name, possibly containing a namespace in Clark
|
| 26 |
+
notation
|
| 27 |
+
|
| 28 |
+
* NAMESPACE - the default namespace URI, unless provided as part
|
| 29 |
+
of the TAG attribute.
|
| 30 |
+
|
| 31 |
+
* HTML - flag if the class is an HTML tag, as opposed to an XML
|
| 32 |
+
tag. This only applies to un-namespaced tags and defaults to
|
| 33 |
+
false (i.e. XML).
|
| 34 |
+
|
| 35 |
+
* PARSER - the parser that provides the configuration for the
|
| 36 |
+
newly created document. Providing an HTML parser here will
|
| 37 |
+
default to creating an HTML element.
|
| 38 |
+
|
| 39 |
+
In user code, the latter three are commonly inherited in class
|
| 40 |
+
hierarchies that implement a common namespace.
|
| 41 |
+
"""
|
| 42 |
+
def __init__(self, *children, attrib=None, nsmap=None, **_extra):
|
| 43 |
+
"""ElementBase(*children, attrib=None, nsmap=None, **_extra)
|
| 44 |
+
"""
|
| 45 |
+
cdef bint is_html = 0
|
| 46 |
+
cdef _BaseParser parser
|
| 47 |
+
cdef _Element last_child
|
| 48 |
+
# don't use normal attribute access as it might be overridden
|
| 49 |
+
_getattr = object.__getattribute__
|
| 50 |
+
try:
|
| 51 |
+
namespace = _utf8(_getattr(self, 'NAMESPACE'))
|
| 52 |
+
except AttributeError:
|
| 53 |
+
namespace = None
|
| 54 |
+
try:
|
| 55 |
+
ns, tag = _getNsTag(_getattr(self, 'TAG'))
|
| 56 |
+
if ns is not None:
|
| 57 |
+
namespace = ns
|
| 58 |
+
except AttributeError:
|
| 59 |
+
tag = _utf8(_getattr(_getattr(self, '__class__'), '__name__'))
|
| 60 |
+
if b'.' in tag:
|
| 61 |
+
tag = tag.split(b'.')[-1]
|
| 62 |
+
try:
|
| 63 |
+
parser = _getattr(self, 'PARSER')
|
| 64 |
+
except AttributeError:
|
| 65 |
+
parser = None
|
| 66 |
+
for child in children:
|
| 67 |
+
if isinstance(child, _Element):
|
| 68 |
+
parser = (<_Element>child)._doc._parser
|
| 69 |
+
break
|
| 70 |
+
if isinstance(parser, HTMLParser):
|
| 71 |
+
is_html = 1
|
| 72 |
+
if namespace is None:
|
| 73 |
+
try:
|
| 74 |
+
is_html = _getattr(self, 'HTML')
|
| 75 |
+
except AttributeError:
|
| 76 |
+
pass
|
| 77 |
+
_initNewElement(self, is_html, tag, namespace, parser,
|
| 78 |
+
attrib, nsmap, _extra)
|
| 79 |
+
last_child = None
|
| 80 |
+
for child in children:
|
| 81 |
+
if _isString(child):
|
| 82 |
+
if last_child is None:
|
| 83 |
+
_setNodeText(self._c_node,
|
| 84 |
+
(_collectText(self._c_node.children) or '') + child)
|
| 85 |
+
else:
|
| 86 |
+
_setTailText(last_child._c_node,
|
| 87 |
+
(_collectText(last_child._c_node.next) or '') + child)
|
| 88 |
+
elif isinstance(child, _Element):
|
| 89 |
+
last_child = child
|
| 90 |
+
_appendChild(self, last_child)
|
| 91 |
+
elif isinstance(child, type) and issubclass(child, ElementBase):
|
| 92 |
+
last_child = child()
|
| 93 |
+
_appendChild(self, last_child)
|
| 94 |
+
else:
|
| 95 |
+
raise TypeError, f"Invalid child type: {type(child)!r}"
|
| 96 |
+
|
| 97 |
+
cdef class CommentBase(_Comment):
|
| 98 |
+
"""All custom Comment classes must inherit from this one.
|
| 99 |
+
|
| 100 |
+
To create an XML Comment instance, use the ``Comment()`` factory.
|
| 101 |
+
|
| 102 |
+
Subclasses *must not* override __init__ or __new__ as it is
|
| 103 |
+
absolutely undefined when these objects will be created or
|
| 104 |
+
destroyed. All persistent state of Comments must be stored in the
|
| 105 |
+
underlying XML. If you really need to initialize the object after
|
| 106 |
+
creation, you can implement an ``_init(self)`` method that will be
|
| 107 |
+
called after object creation.
|
| 108 |
+
"""
|
| 109 |
+
def __init__(self, text):
|
| 110 |
+
# copied from Comment() factory
|
| 111 |
+
cdef _Document doc
|
| 112 |
+
cdef xmlDoc* c_doc
|
| 113 |
+
if text is None:
|
| 114 |
+
text = b''
|
| 115 |
+
else:
|
| 116 |
+
text = _utf8(text)
|
| 117 |
+
c_doc = _newXMLDoc()
|
| 118 |
+
doc = _documentFactory(c_doc, None)
|
| 119 |
+
self._c_node = _createComment(c_doc, _xcstr(text))
|
| 120 |
+
if self._c_node is NULL:
|
| 121 |
+
raise MemoryError()
|
| 122 |
+
tree.xmlAddChild(<xmlNode*>c_doc, self._c_node)
|
| 123 |
+
_registerProxy(self, doc, self._c_node)
|
| 124 |
+
self._init()
|
| 125 |
+
|
| 126 |
+
cdef class PIBase(_ProcessingInstruction):
|
| 127 |
+
"""All custom Processing Instruction classes must inherit from this one.
|
| 128 |
+
|
| 129 |
+
To create an XML ProcessingInstruction instance, use the ``PI()``
|
| 130 |
+
factory.
|
| 131 |
+
|
| 132 |
+
Subclasses *must not* override __init__ or __new__ as it is
|
| 133 |
+
absolutely undefined when these objects will be created or
|
| 134 |
+
destroyed. All persistent state of PIs must be stored in the
|
| 135 |
+
underlying XML. If you really need to initialize the object after
|
| 136 |
+
creation, you can implement an ``_init(self)`` method that will be
|
| 137 |
+
called after object creation.
|
| 138 |
+
"""
|
| 139 |
+
def __init__(self, target, text=None):
|
| 140 |
+
# copied from PI() factory
|
| 141 |
+
cdef _Document doc
|
| 142 |
+
cdef xmlDoc* c_doc
|
| 143 |
+
target = _utf8(target)
|
| 144 |
+
if text is None:
|
| 145 |
+
text = b''
|
| 146 |
+
else:
|
| 147 |
+
text = _utf8(text)
|
| 148 |
+
c_doc = _newXMLDoc()
|
| 149 |
+
doc = _documentFactory(c_doc, None)
|
| 150 |
+
self._c_node = _createPI(c_doc, _xcstr(target), _xcstr(text))
|
| 151 |
+
if self._c_node is NULL:
|
| 152 |
+
raise MemoryError()
|
| 153 |
+
tree.xmlAddChild(<xmlNode*>c_doc, self._c_node)
|
| 154 |
+
_registerProxy(self, doc, self._c_node)
|
| 155 |
+
self._init()
|
| 156 |
+
|
| 157 |
+
cdef class EntityBase(_Entity):
|
| 158 |
+
"""All custom Entity classes must inherit from this one.
|
| 159 |
+
|
| 160 |
+
To create an XML Entity instance, use the ``Entity()`` factory.
|
| 161 |
+
|
| 162 |
+
Subclasses *must not* override __init__ or __new__ as it is
|
| 163 |
+
absolutely undefined when these objects will be created or
|
| 164 |
+
destroyed. All persistent state of Entities must be stored in the
|
| 165 |
+
underlying XML. If you really need to initialize the object after
|
| 166 |
+
creation, you can implement an ``_init(self)`` method that will be
|
| 167 |
+
called after object creation.
|
| 168 |
+
"""
|
| 169 |
+
def __init__(self, name):
|
| 170 |
+
cdef _Document doc
|
| 171 |
+
cdef xmlDoc* c_doc
|
| 172 |
+
name_utf = _utf8(name)
|
| 173 |
+
c_name = _xcstr(name_utf)
|
| 174 |
+
if c_name[0] == c'#':
|
| 175 |
+
if not _characterReferenceIsValid(c_name + 1):
|
| 176 |
+
raise ValueError, f"Invalid character reference: '{name}'"
|
| 177 |
+
elif not _xmlNameIsValid(c_name):
|
| 178 |
+
raise ValueError, f"Invalid entity reference: '{name}'"
|
| 179 |
+
c_doc = _newXMLDoc()
|
| 180 |
+
doc = _documentFactory(c_doc, None)
|
| 181 |
+
self._c_node = _createEntity(c_doc, c_name)
|
| 182 |
+
if self._c_node is NULL:
|
| 183 |
+
raise MemoryError()
|
| 184 |
+
tree.xmlAddChild(<xmlNode*>c_doc, self._c_node)
|
| 185 |
+
_registerProxy(self, doc, self._c_node)
|
| 186 |
+
self._init()
|
| 187 |
+
|
| 188 |
+
|
| 189 |
+
cdef int _validateNodeClass(xmlNode* c_node, cls) except -1:
|
| 190 |
+
if c_node.type == tree.XML_ELEMENT_NODE:
|
| 191 |
+
expected = ElementBase
|
| 192 |
+
elif c_node.type == tree.XML_COMMENT_NODE:
|
| 193 |
+
expected = CommentBase
|
| 194 |
+
elif c_node.type == tree.XML_ENTITY_REF_NODE:
|
| 195 |
+
expected = EntityBase
|
| 196 |
+
elif c_node.type == tree.XML_PI_NODE:
|
| 197 |
+
expected = PIBase
|
| 198 |
+
else:
|
| 199 |
+
assert False, f"Unknown node type: {c_node.type}"
|
| 200 |
+
|
| 201 |
+
if not (isinstance(cls, type) and issubclass(cls, expected)):
|
| 202 |
+
raise TypeError(
|
| 203 |
+
f"result of class lookup must be subclass of {type(expected)}, got {type(cls)}")
|
| 204 |
+
return 0
|
| 205 |
+
|
| 206 |
+
|
| 207 |
+
################################################################################
|
| 208 |
+
# Element class lookup
|
| 209 |
+
|
| 210 |
+
ctypedef public object (*_element_class_lookup_function)(object, _Document, xmlNode*)
|
| 211 |
+
|
| 212 |
+
# class to store element class lookup functions
|
| 213 |
+
cdef public class ElementClassLookup [ type LxmlElementClassLookupType,
|
| 214 |
+
object LxmlElementClassLookup ]:
|
| 215 |
+
"""ElementClassLookup(self)
|
| 216 |
+
Superclass of Element class lookups.
|
| 217 |
+
"""
|
| 218 |
+
cdef _element_class_lookup_function _lookup_function
|
| 219 |
+
|
| 220 |
+
|
| 221 |
+
cdef public class FallbackElementClassLookup(ElementClassLookup) \
|
| 222 |
+
[ type LxmlFallbackElementClassLookupType,
|
| 223 |
+
object LxmlFallbackElementClassLookup ]:
|
| 224 |
+
"""FallbackElementClassLookup(self, fallback=None)
|
| 225 |
+
|
| 226 |
+
Superclass of Element class lookups with additional fallback.
|
| 227 |
+
"""
|
| 228 |
+
cdef readonly ElementClassLookup fallback
|
| 229 |
+
cdef _element_class_lookup_function _fallback_function
|
| 230 |
+
def __cinit__(self):
|
| 231 |
+
# fall back to default lookup
|
| 232 |
+
self._fallback_function = _lookupDefaultElementClass
|
| 233 |
+
|
| 234 |
+
def __init__(self, ElementClassLookup fallback=None):
|
| 235 |
+
if fallback is not None:
|
| 236 |
+
self._setFallback(fallback)
|
| 237 |
+
else:
|
| 238 |
+
self._fallback_function = _lookupDefaultElementClass
|
| 239 |
+
|
| 240 |
+
cdef void _setFallback(self, ElementClassLookup lookup):
|
| 241 |
+
"""Sets the fallback scheme for this lookup method.
|
| 242 |
+
"""
|
| 243 |
+
self.fallback = lookup
|
| 244 |
+
self._fallback_function = lookup._lookup_function
|
| 245 |
+
if self._fallback_function is NULL:
|
| 246 |
+
self._fallback_function = _lookupDefaultElementClass
|
| 247 |
+
|
| 248 |
+
def set_fallback(self, ElementClassLookup lookup not None):
|
| 249 |
+
"""set_fallback(self, lookup)
|
| 250 |
+
|
| 251 |
+
Sets the fallback scheme for this lookup method.
|
| 252 |
+
"""
|
| 253 |
+
self._setFallback(lookup)
|
| 254 |
+
|
| 255 |
+
cdef inline object _callLookupFallback(FallbackElementClassLookup lookup,
|
| 256 |
+
_Document doc, xmlNode* c_node):
|
| 257 |
+
return lookup._fallback_function(lookup.fallback, doc, c_node)
|
| 258 |
+
|
| 259 |
+
|
| 260 |
+
################################################################################
|
| 261 |
+
# default lookup scheme
|
| 262 |
+
|
| 263 |
+
cdef class ElementDefaultClassLookup(ElementClassLookup):
|
| 264 |
+
"""ElementDefaultClassLookup(self, element=None, comment=None, pi=None, entity=None)
|
| 265 |
+
Element class lookup scheme that always returns the default Element
|
| 266 |
+
class.
|
| 267 |
+
|
| 268 |
+
The keyword arguments ``element``, ``comment``, ``pi`` and ``entity``
|
| 269 |
+
accept the respective Element classes.
|
| 270 |
+
"""
|
| 271 |
+
cdef readonly object element_class
|
| 272 |
+
cdef readonly object comment_class
|
| 273 |
+
cdef readonly object pi_class
|
| 274 |
+
cdef readonly object entity_class
|
| 275 |
+
def __cinit__(self):
|
| 276 |
+
self._lookup_function = _lookupDefaultElementClass
|
| 277 |
+
|
| 278 |
+
def __init__(self, element=None, comment=None, pi=None, entity=None):
|
| 279 |
+
if element is None:
|
| 280 |
+
self.element_class = _Element
|
| 281 |
+
elif issubclass(element, ElementBase):
|
| 282 |
+
self.element_class = element
|
| 283 |
+
else:
|
| 284 |
+
raise TypeError, "element class must be subclass of ElementBase"
|
| 285 |
+
|
| 286 |
+
if comment is None:
|
| 287 |
+
self.comment_class = _Comment
|
| 288 |
+
elif issubclass(comment, CommentBase):
|
| 289 |
+
self.comment_class = comment
|
| 290 |
+
else:
|
| 291 |
+
raise TypeError, "comment class must be subclass of CommentBase"
|
| 292 |
+
|
| 293 |
+
if entity is None:
|
| 294 |
+
self.entity_class = _Entity
|
| 295 |
+
elif issubclass(entity, EntityBase):
|
| 296 |
+
self.entity_class = entity
|
| 297 |
+
else:
|
| 298 |
+
raise TypeError, "Entity class must be subclass of EntityBase"
|
| 299 |
+
|
| 300 |
+
if pi is None:
|
| 301 |
+
self.pi_class = None # special case, see below
|
| 302 |
+
elif issubclass(pi, PIBase):
|
| 303 |
+
self.pi_class = pi
|
| 304 |
+
else:
|
| 305 |
+
raise TypeError, "PI class must be subclass of PIBase"
|
| 306 |
+
|
| 307 |
+
cdef object _lookupDefaultElementClass(state, _Document _doc, xmlNode* c_node):
|
| 308 |
+
"Trivial class lookup function that always returns the default class."
|
| 309 |
+
if c_node.type == tree.XML_ELEMENT_NODE:
|
| 310 |
+
if state is not None:
|
| 311 |
+
return (<ElementDefaultClassLookup>state).element_class
|
| 312 |
+
else:
|
| 313 |
+
return _Element
|
| 314 |
+
elif c_node.type == tree.XML_COMMENT_NODE:
|
| 315 |
+
if state is not None:
|
| 316 |
+
return (<ElementDefaultClassLookup>state).comment_class
|
| 317 |
+
else:
|
| 318 |
+
return _Comment
|
| 319 |
+
elif c_node.type == tree.XML_ENTITY_REF_NODE:
|
| 320 |
+
if state is not None:
|
| 321 |
+
return (<ElementDefaultClassLookup>state).entity_class
|
| 322 |
+
else:
|
| 323 |
+
return _Entity
|
| 324 |
+
elif c_node.type == tree.XML_PI_NODE:
|
| 325 |
+
if state is None or (<ElementDefaultClassLookup>state).pi_class is None:
|
| 326 |
+
# special case XSLT-PI
|
| 327 |
+
if c_node.name is not NULL and c_node.content is not NULL:
|
| 328 |
+
if tree.xmlStrcmp(c_node.name, <unsigned char*>"xml-stylesheet") == 0:
|
| 329 |
+
if tree.xmlStrstr(c_node.content, <unsigned char*>"text/xsl") is not NULL or \
|
| 330 |
+
tree.xmlStrstr(c_node.content, <unsigned char*>"text/xml") is not NULL:
|
| 331 |
+
return _XSLTProcessingInstruction
|
| 332 |
+
return _ProcessingInstruction
|
| 333 |
+
else:
|
| 334 |
+
return (<ElementDefaultClassLookup>state).pi_class
|
| 335 |
+
else:
|
| 336 |
+
assert False, f"Unknown node type: {c_node.type}"
|
| 337 |
+
|
| 338 |
+
|
| 339 |
+
################################################################################
|
| 340 |
+
# attribute based lookup scheme
|
| 341 |
+
|
| 342 |
+
cdef class AttributeBasedElementClassLookup(FallbackElementClassLookup):
|
| 343 |
+
"""AttributeBasedElementClassLookup(self, attribute_name, class_mapping, fallback=None)
|
| 344 |
+
Checks an attribute of an Element and looks up the value in a
|
| 345 |
+
class dictionary.
|
| 346 |
+
|
| 347 |
+
Arguments:
|
| 348 |
+
- attribute name - '{ns}name' style string
|
| 349 |
+
- class mapping - Python dict mapping attribute values to Element classes
|
| 350 |
+
- fallback - optional fallback lookup mechanism
|
| 351 |
+
|
| 352 |
+
A None key in the class mapping will be checked if the attribute is
|
| 353 |
+
missing.
|
| 354 |
+
"""
|
| 355 |
+
cdef object _class_mapping
|
| 356 |
+
cdef tuple _pytag
|
| 357 |
+
cdef const_xmlChar* _c_ns
|
| 358 |
+
cdef const_xmlChar* _c_name
|
| 359 |
+
def __cinit__(self):
|
| 360 |
+
self._lookup_function = _attribute_class_lookup
|
| 361 |
+
|
| 362 |
+
def __init__(self, attribute_name, class_mapping,
|
| 363 |
+
ElementClassLookup fallback=None):
|
| 364 |
+
self._pytag = _getNsTag(attribute_name)
|
| 365 |
+
ns, name = self._pytag
|
| 366 |
+
if ns is None:
|
| 367 |
+
self._c_ns = NULL
|
| 368 |
+
else:
|
| 369 |
+
self._c_ns = _xcstr(ns)
|
| 370 |
+
self._c_name = _xcstr(name)
|
| 371 |
+
self._class_mapping = dict(class_mapping)
|
| 372 |
+
|
| 373 |
+
FallbackElementClassLookup.__init__(self, fallback)
|
| 374 |
+
|
| 375 |
+
cdef object _attribute_class_lookup(state, _Document doc, xmlNode* c_node):
|
| 376 |
+
cdef AttributeBasedElementClassLookup lookup
|
| 377 |
+
cdef python.PyObject* dict_result
|
| 378 |
+
|
| 379 |
+
lookup = <AttributeBasedElementClassLookup>state
|
| 380 |
+
if c_node.type == tree.XML_ELEMENT_NODE:
|
| 381 |
+
value = _attributeValueFromNsName(
|
| 382 |
+
c_node, lookup._c_ns, lookup._c_name)
|
| 383 |
+
dict_result = python.PyDict_GetItem(lookup._class_mapping, value)
|
| 384 |
+
if dict_result is not NULL:
|
| 385 |
+
cls = <object>dict_result
|
| 386 |
+
_validateNodeClass(c_node, cls)
|
| 387 |
+
return cls
|
| 388 |
+
return _callLookupFallback(lookup, doc, c_node)
|
| 389 |
+
|
| 390 |
+
|
| 391 |
+
################################################################################
|
| 392 |
+
# per-parser lookup scheme
|
| 393 |
+
|
| 394 |
+
cdef class ParserBasedElementClassLookup(FallbackElementClassLookup):
|
| 395 |
+
"""ParserBasedElementClassLookup(self, fallback=None)
|
| 396 |
+
Element class lookup based on the XML parser.
|
| 397 |
+
"""
|
| 398 |
+
def __cinit__(self):
|
| 399 |
+
self._lookup_function = _parser_class_lookup
|
| 400 |
+
|
| 401 |
+
cdef object _parser_class_lookup(state, _Document doc, xmlNode* c_node):
|
| 402 |
+
if doc._parser._class_lookup is not None:
|
| 403 |
+
return doc._parser._class_lookup._lookup_function(
|
| 404 |
+
doc._parser._class_lookup, doc, c_node)
|
| 405 |
+
return _callLookupFallback(<FallbackElementClassLookup>state, doc, c_node)
|
| 406 |
+
|
| 407 |
+
|
| 408 |
+
################################################################################
|
| 409 |
+
# custom class lookup based on node type, namespace, name
|
| 410 |
+
|
| 411 |
+
cdef class CustomElementClassLookup(FallbackElementClassLookup):
|
| 412 |
+
"""CustomElementClassLookup(self, fallback=None)
|
| 413 |
+
Element class lookup based on a subclass method.
|
| 414 |
+
|
| 415 |
+
You can inherit from this class and override the method::
|
| 416 |
+
|
| 417 |
+
lookup(self, type, doc, namespace, name)
|
| 418 |
+
|
| 419 |
+
to lookup the element class for a node. Arguments of the method:
|
| 420 |
+
* type: one of 'element', 'comment', 'PI', 'entity'
|
| 421 |
+
* doc: document that the node is in
|
| 422 |
+
* namespace: namespace URI of the node (or None for comments/PIs/entities)
|
| 423 |
+
* name: name of the element/entity, None for comments, target for PIs
|
| 424 |
+
|
| 425 |
+
If you return None from this method, the fallback will be called.
|
| 426 |
+
"""
|
| 427 |
+
def __cinit__(self):
|
| 428 |
+
self._lookup_function = _custom_class_lookup
|
| 429 |
+
|
| 430 |
+
def lookup(self, type, doc, namespace, name):
|
| 431 |
+
"lookup(self, type, doc, namespace, name)"
|
| 432 |
+
return None
|
| 433 |
+
|
| 434 |
+
cdef object _custom_class_lookup(state, _Document doc, xmlNode* c_node):
|
| 435 |
+
cdef CustomElementClassLookup lookup
|
| 436 |
+
|
| 437 |
+
lookup = <CustomElementClassLookup>state
|
| 438 |
+
|
| 439 |
+
if c_node.type == tree.XML_ELEMENT_NODE:
|
| 440 |
+
element_type = "element"
|
| 441 |
+
elif c_node.type == tree.XML_COMMENT_NODE:
|
| 442 |
+
element_type = "comment"
|
| 443 |
+
elif c_node.type == tree.XML_PI_NODE:
|
| 444 |
+
element_type = "PI"
|
| 445 |
+
elif c_node.type == tree.XML_ENTITY_REF_NODE:
|
| 446 |
+
element_type = "entity"
|
| 447 |
+
else:
|
| 448 |
+
element_type = "element"
|
| 449 |
+
if c_node.name is NULL:
|
| 450 |
+
name = None
|
| 451 |
+
else:
|
| 452 |
+
name = funicode(c_node.name)
|
| 453 |
+
c_str = tree._getNs(c_node)
|
| 454 |
+
ns = funicode(c_str) if c_str is not NULL else None
|
| 455 |
+
|
| 456 |
+
cls = lookup.lookup(element_type, doc, ns, name)
|
| 457 |
+
if cls is not None:
|
| 458 |
+
_validateNodeClass(c_node, cls)
|
| 459 |
+
return cls
|
| 460 |
+
return _callLookupFallback(lookup, doc, c_node)
|
| 461 |
+
|
| 462 |
+
|
| 463 |
+
################################################################################
|
| 464 |
+
# read-only tree based class lookup
|
| 465 |
+
|
| 466 |
+
cdef class PythonElementClassLookup(FallbackElementClassLookup):
|
| 467 |
+
"""PythonElementClassLookup(self, fallback=None)
|
| 468 |
+
Element class lookup based on a subclass method.
|
| 469 |
+
|
| 470 |
+
This class lookup scheme allows access to the entire XML tree in
|
| 471 |
+
read-only mode. To use it, re-implement the ``lookup(self, doc,
|
| 472 |
+
root)`` method in a subclass::
|
| 473 |
+
|
| 474 |
+
from lxml import etree, pyclasslookup
|
| 475 |
+
|
| 476 |
+
class MyElementClass(etree.ElementBase):
|
| 477 |
+
honkey = True
|
| 478 |
+
|
| 479 |
+
class MyLookup(pyclasslookup.PythonElementClassLookup):
|
| 480 |
+
def lookup(self, doc, root):
|
| 481 |
+
if root.tag == "sometag":
|
| 482 |
+
return MyElementClass
|
| 483 |
+
else:
|
| 484 |
+
for child in root:
|
| 485 |
+
if child.tag == "someothertag":
|
| 486 |
+
return MyElementClass
|
| 487 |
+
# delegate to default
|
| 488 |
+
return None
|
| 489 |
+
|
| 490 |
+
If you return None from this method, the fallback will be called.
|
| 491 |
+
|
| 492 |
+
The first argument is the opaque document instance that contains
|
| 493 |
+
the Element. The second argument is a lightweight Element proxy
|
| 494 |
+
implementation that is only valid during the lookup. Do not try
|
| 495 |
+
to keep a reference to it. Once the lookup is done, the proxy
|
| 496 |
+
will be invalid.
|
| 497 |
+
|
| 498 |
+
Also, you cannot wrap such a read-only Element in an ElementTree,
|
| 499 |
+
and you must take care not to keep a reference to them outside of
|
| 500 |
+
the `lookup()` method.
|
| 501 |
+
|
| 502 |
+
Note that the API of the Element objects is not complete. It is
|
| 503 |
+
purely read-only and does not support all features of the normal
|
| 504 |
+
`lxml.etree` API (such as XPath, extended slicing or some
|
| 505 |
+
iteration methods).
|
| 506 |
+
|
| 507 |
+
See https://lxml.de/element_classes.html
|
| 508 |
+
"""
|
| 509 |
+
def __cinit__(self):
|
| 510 |
+
self._lookup_function = _python_class_lookup
|
| 511 |
+
|
| 512 |
+
def lookup(self, doc, element):
|
| 513 |
+
"""lookup(self, doc, element)
|
| 514 |
+
|
| 515 |
+
Override this method to implement your own lookup scheme.
|
| 516 |
+
"""
|
| 517 |
+
return None
|
| 518 |
+
|
| 519 |
+
cdef object _python_class_lookup(state, _Document doc, tree.xmlNode* c_node):
|
| 520 |
+
cdef PythonElementClassLookup lookup
|
| 521 |
+
cdef _ReadOnlyProxy proxy
|
| 522 |
+
lookup = <PythonElementClassLookup>state
|
| 523 |
+
|
| 524 |
+
proxy = _newReadOnlyProxy(None, c_node)
|
| 525 |
+
cls = lookup.lookup(doc, proxy)
|
| 526 |
+
_freeReadOnlyProxies(proxy)
|
| 527 |
+
|
| 528 |
+
if cls is not None:
|
| 529 |
+
_validateNodeClass(c_node, cls)
|
| 530 |
+
return cls
|
| 531 |
+
return _callLookupFallback(lookup, doc, c_node)
|
| 532 |
+
|
| 533 |
+
################################################################################
|
| 534 |
+
# Global setup
|
| 535 |
+
|
| 536 |
+
cdef _element_class_lookup_function LOOKUP_ELEMENT_CLASS
|
| 537 |
+
cdef object ELEMENT_CLASS_LOOKUP_STATE
|
| 538 |
+
|
| 539 |
+
cdef void _setElementClassLookupFunction(
|
| 540 |
+
_element_class_lookup_function function, object state):
|
| 541 |
+
global LOOKUP_ELEMENT_CLASS, ELEMENT_CLASS_LOOKUP_STATE
|
| 542 |
+
if function is NULL:
|
| 543 |
+
state = DEFAULT_ELEMENT_CLASS_LOOKUP
|
| 544 |
+
function = DEFAULT_ELEMENT_CLASS_LOOKUP._lookup_function
|
| 545 |
+
|
| 546 |
+
ELEMENT_CLASS_LOOKUP_STATE = state
|
| 547 |
+
LOOKUP_ELEMENT_CLASS = function
|
| 548 |
+
|
| 549 |
+
def set_element_class_lookup(ElementClassLookup lookup = None):
|
| 550 |
+
"""set_element_class_lookup(lookup = None)
|
| 551 |
+
|
| 552 |
+
Set the global element class lookup method.
|
| 553 |
+
|
| 554 |
+
This defines the main entry point for looking up element implementations.
|
| 555 |
+
The standard implementation uses the :class:`ParserBasedElementClassLookup`
|
| 556 |
+
to delegate to different lookup schemes for each parser.
|
| 557 |
+
|
| 558 |
+
.. warning::
|
| 559 |
+
|
| 560 |
+
This should only be changed by applications, not by library packages.
|
| 561 |
+
In most cases, parser specific lookups should be preferred,
|
| 562 |
+
which can be configured via
|
| 563 |
+
:meth:`~lxml.etree.XMLParser.set_element_class_lookup`
|
| 564 |
+
(and the same for HTML parsers).
|
| 565 |
+
|
| 566 |
+
Globally replacing the element class lookup by something other than a
|
| 567 |
+
:class:`ParserBasedElementClassLookup` will prevent parser specific lookup
|
| 568 |
+
schemes from working. Several tools rely on parser specific lookups,
|
| 569 |
+
including :mod:`lxml.html` and :mod:`lxml.objectify`.
|
| 570 |
+
"""
|
| 571 |
+
if lookup is None or lookup._lookup_function is NULL:
|
| 572 |
+
_setElementClassLookupFunction(NULL, None)
|
| 573 |
+
else:
|
| 574 |
+
_setElementClassLookupFunction(lookup._lookup_function, lookup)
|
| 575 |
+
|
| 576 |
+
# default setup: parser delegation
|
| 577 |
+
cdef ParserBasedElementClassLookup DEFAULT_ELEMENT_CLASS_LOOKUP
|
| 578 |
+
DEFAULT_ELEMENT_CLASS_LOOKUP = ParserBasedElementClassLookup()
|
| 579 |
+
|
| 580 |
+
set_element_class_lookup(DEFAULT_ELEMENT_CLASS_LOOKUP)
|
omnilmm/lib/python3.10/site-packages/lxml/cleanup.pxi
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
| 1 |
+
# functions for tree cleanup and removing elements from subtrees
|
| 2 |
+
|
| 3 |
+
def cleanup_namespaces(tree_or_element, top_nsmap=None, keep_ns_prefixes=None):
|
| 4 |
+
"""cleanup_namespaces(tree_or_element, top_nsmap=None, keep_ns_prefixes=None)
|
| 5 |
+
|
| 6 |
+
Remove all namespace declarations from a subtree that are not used
|
| 7 |
+
by any of the elements or attributes in that tree.
|
| 8 |
+
|
| 9 |
+
If a 'top_nsmap' is provided, it must be a mapping from prefixes
|
| 10 |
+
to namespace URIs. These namespaces will be declared on the top
|
| 11 |
+
element of the subtree before running the cleanup, which allows
|
| 12 |
+
moving namespace declarations to the top of the tree.
|
| 13 |
+
|
| 14 |
+
If a 'keep_ns_prefixes' is provided, it must be a list of prefixes.
|
| 15 |
+
These prefixes will not be removed as part of the cleanup.
|
| 16 |
+
"""
|
| 17 |
+
element = _rootNodeOrRaise(tree_or_element)
|
| 18 |
+
c_element = element._c_node
|
| 19 |
+
|
| 20 |
+
if top_nsmap:
|
| 21 |
+
doc = element._doc
|
| 22 |
+
# declare namespaces from nsmap, then apply them to the subtree
|
| 23 |
+
_setNodeNamespaces(c_element, doc, None, top_nsmap)
|
| 24 |
+
moveNodeToDocument(doc, c_element.doc, c_element)
|
| 25 |
+
|
| 26 |
+
keep_ns_prefixes = (
|
| 27 |
+
set([_utf8(prefix) for prefix in keep_ns_prefixes])
|
| 28 |
+
if keep_ns_prefixes else None)
|
| 29 |
+
|
| 30 |
+
_removeUnusedNamespaceDeclarations(c_element, keep_ns_prefixes)
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
def strip_attributes(tree_or_element, *attribute_names):
|
| 34 |
+
"""strip_attributes(tree_or_element, *attribute_names)
|
| 35 |
+
|
| 36 |
+
Delete all attributes with the provided attribute names from an
|
| 37 |
+
Element (or ElementTree) and its descendants.
|
| 38 |
+
|
| 39 |
+
Attribute names can contain wildcards as in `_Element.iter`.
|
| 40 |
+
|
| 41 |
+
Example usage::
|
| 42 |
+
|
| 43 |
+
strip_attributes(root_element,
|
| 44 |
+
'simpleattr',
|
| 45 |
+
'{http://some/ns}attrname',
|
| 46 |
+
'{http://other/ns}*')
|
| 47 |
+
"""
|
| 48 |
+
cdef _MultiTagMatcher matcher
|
| 49 |
+
element = _rootNodeOrRaise(tree_or_element)
|
| 50 |
+
if not attribute_names:
|
| 51 |
+
return
|
| 52 |
+
|
| 53 |
+
matcher = _MultiTagMatcher.__new__(_MultiTagMatcher, attribute_names)
|
| 54 |
+
matcher.cacheTags(element._doc)
|
| 55 |
+
if matcher.rejectsAllAttributes():
|
| 56 |
+
return
|
| 57 |
+
_strip_attributes(element._c_node, matcher)
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
cdef _strip_attributes(xmlNode* c_node, _MultiTagMatcher matcher):
|
| 61 |
+
cdef xmlAttr* c_attr
|
| 62 |
+
cdef xmlAttr* c_next_attr
|
| 63 |
+
tree.BEGIN_FOR_EACH_ELEMENT_FROM(c_node, c_node, 1)
|
| 64 |
+
if c_node.type == tree.XML_ELEMENT_NODE:
|
| 65 |
+
c_attr = c_node.properties
|
| 66 |
+
while c_attr is not NULL:
|
| 67 |
+
c_next_attr = c_attr.next
|
| 68 |
+
if matcher.matchesAttribute(c_attr):
|
| 69 |
+
tree.xmlRemoveProp(c_attr)
|
| 70 |
+
c_attr = c_next_attr
|
| 71 |
+
tree.END_FOR_EACH_ELEMENT_FROM(c_node)
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
def strip_elements(tree_or_element, *tag_names, bint with_tail=True):
|
| 75 |
+
"""strip_elements(tree_or_element, *tag_names, with_tail=True)
|
| 76 |
+
|
| 77 |
+
Delete all elements with the provided tag names from a tree or
|
| 78 |
+
subtree. This will remove the elements and their entire subtree,
|
| 79 |
+
including all their attributes, text content and descendants. It
|
| 80 |
+
will also remove the tail text of the element unless you
|
| 81 |
+
explicitly set the ``with_tail`` keyword argument option to False.
|
| 82 |
+
|
| 83 |
+
Tag names can contain wildcards as in `_Element.iter`.
|
| 84 |
+
|
| 85 |
+
Note that this will not delete the element (or ElementTree root
|
| 86 |
+
element) that you passed even if it matches. It will only treat
|
| 87 |
+
its descendants. If you want to include the root element, check
|
| 88 |
+
its tag name directly before even calling this function.
|
| 89 |
+
|
| 90 |
+
Example usage::
|
| 91 |
+
|
| 92 |
+
strip_elements(some_element,
|
| 93 |
+
'simpletagname', # non-namespaced tag
|
| 94 |
+
'{http://some/ns}tagname', # namespaced tag
|
| 95 |
+
'{http://some/other/ns}*' # any tag from a namespace
|
| 96 |
+
lxml.etree.Comment # comments
|
| 97 |
+
)
|
| 98 |
+
"""
|
| 99 |
+
cdef _MultiTagMatcher matcher
|
| 100 |
+
doc = _documentOrRaise(tree_or_element)
|
| 101 |
+
element = _rootNodeOrRaise(tree_or_element)
|
| 102 |
+
if not tag_names:
|
| 103 |
+
return
|
| 104 |
+
|
| 105 |
+
matcher = _MultiTagMatcher.__new__(_MultiTagMatcher, tag_names)
|
| 106 |
+
matcher.cacheTags(doc)
|
| 107 |
+
if matcher.rejectsAll():
|
| 108 |
+
return
|
| 109 |
+
|
| 110 |
+
if isinstance(tree_or_element, _ElementTree):
|
| 111 |
+
# include PIs and comments next to the root node
|
| 112 |
+
if matcher.matchesType(tree.XML_COMMENT_NODE):
|
| 113 |
+
_removeSiblings(element._c_node, tree.XML_COMMENT_NODE, with_tail)
|
| 114 |
+
if matcher.matchesType(tree.XML_PI_NODE):
|
| 115 |
+
_removeSiblings(element._c_node, tree.XML_PI_NODE, with_tail)
|
| 116 |
+
_strip_elements(doc, element._c_node, matcher, with_tail)
|
| 117 |
+
|
| 118 |
+
cdef _strip_elements(_Document doc, xmlNode* c_node, _MultiTagMatcher matcher,
|
| 119 |
+
bint with_tail):
|
| 120 |
+
cdef xmlNode* c_child
|
| 121 |
+
cdef xmlNode* c_next
|
| 122 |
+
|
| 123 |
+
tree.BEGIN_FOR_EACH_ELEMENT_FROM(c_node, c_node, 1)
|
| 124 |
+
if c_node.type == tree.XML_ELEMENT_NODE:
|
| 125 |
+
# we run through the children here to prevent any problems
|
| 126 |
+
# with the tree iteration which would occur if we unlinked the
|
| 127 |
+
# c_node itself
|
| 128 |
+
c_child = _findChildForwards(c_node, 0)
|
| 129 |
+
while c_child is not NULL:
|
| 130 |
+
c_next = _nextElement(c_child)
|
| 131 |
+
if matcher.matches(c_child):
|
| 132 |
+
if c_child.type == tree.XML_ELEMENT_NODE:
|
| 133 |
+
if not with_tail:
|
| 134 |
+
tree.xmlUnlinkNode(c_child)
|
| 135 |
+
_removeNode(doc, c_child)
|
| 136 |
+
else:
|
| 137 |
+
if with_tail:
|
| 138 |
+
_removeText(c_child.next)
|
| 139 |
+
tree.xmlUnlinkNode(c_child)
|
| 140 |
+
attemptDeallocation(c_child)
|
| 141 |
+
c_child = c_next
|
| 142 |
+
tree.END_FOR_EACH_ELEMENT_FROM(c_node)
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
def strip_tags(tree_or_element, *tag_names):
|
| 146 |
+
"""strip_tags(tree_or_element, *tag_names)
|
| 147 |
+
|
| 148 |
+
Delete all elements with the provided tag names from a tree or
|
| 149 |
+
subtree. This will remove the elements and their attributes, but
|
| 150 |
+
*not* their text/tail content or descendants. Instead, it will
|
| 151 |
+
merge the text content and children of the element into its
|
| 152 |
+
parent.
|
| 153 |
+
|
| 154 |
+
Tag names can contain wildcards as in `_Element.iter`.
|
| 155 |
+
|
| 156 |
+
Note that this will not delete the element (or ElementTree root
|
| 157 |
+
element) that you passed even if it matches. It will only treat
|
| 158 |
+
its descendants.
|
| 159 |
+
|
| 160 |
+
Example usage::
|
| 161 |
+
|
| 162 |
+
strip_tags(some_element,
|
| 163 |
+
'simpletagname', # non-namespaced tag
|
| 164 |
+
'{http://some/ns}tagname', # namespaced tag
|
| 165 |
+
'{http://some/other/ns}*' # any tag from a namespace
|
| 166 |
+
Comment # comments (including their text!)
|
| 167 |
+
)
|
| 168 |
+
"""
|
| 169 |
+
cdef _MultiTagMatcher matcher
|
| 170 |
+
doc = _documentOrRaise(tree_or_element)
|
| 171 |
+
element = _rootNodeOrRaise(tree_or_element)
|
| 172 |
+
if not tag_names:
|
| 173 |
+
return
|
| 174 |
+
|
| 175 |
+
matcher = _MultiTagMatcher.__new__(_MultiTagMatcher, tag_names)
|
| 176 |
+
matcher.cacheTags(doc)
|
| 177 |
+
if matcher.rejectsAll():
|
| 178 |
+
return
|
| 179 |
+
|
| 180 |
+
if isinstance(tree_or_element, _ElementTree):
|
| 181 |
+
# include PIs and comments next to the root node
|
| 182 |
+
if matcher.matchesType(tree.XML_COMMENT_NODE):
|
| 183 |
+
_removeSiblings(element._c_node, tree.XML_COMMENT_NODE, 0)
|
| 184 |
+
if matcher.matchesType(tree.XML_PI_NODE):
|
| 185 |
+
_removeSiblings(element._c_node, tree.XML_PI_NODE, 0)
|
| 186 |
+
_strip_tags(doc, element._c_node, matcher)
|
| 187 |
+
|
| 188 |
+
cdef _strip_tags(_Document doc, xmlNode* c_node, _MultiTagMatcher matcher):
|
| 189 |
+
cdef xmlNode* c_child
|
| 190 |
+
cdef xmlNode* c_next
|
| 191 |
+
|
| 192 |
+
tree.BEGIN_FOR_EACH_ELEMENT_FROM(c_node, c_node, 1)
|
| 193 |
+
if c_node.type == tree.XML_ELEMENT_NODE:
|
| 194 |
+
# we run through the children here to prevent any problems
|
| 195 |
+
# with the tree iteration which would occur if we unlinked the
|
| 196 |
+
# c_node itself
|
| 197 |
+
c_child = _findChildForwards(c_node, 0)
|
| 198 |
+
while c_child is not NULL:
|
| 199 |
+
if not matcher.matches(c_child):
|
| 200 |
+
c_child = _nextElement(c_child)
|
| 201 |
+
continue
|
| 202 |
+
if c_child.type == tree.XML_ELEMENT_NODE:
|
| 203 |
+
c_next = _findChildForwards(c_child, 0) or _nextElement(c_child)
|
| 204 |
+
_replaceNodeByChildren(doc, c_child)
|
| 205 |
+
if not attemptDeallocation(c_child):
|
| 206 |
+
if c_child.nsDef is not NULL:
|
| 207 |
+
# make namespaces absolute
|
| 208 |
+
moveNodeToDocument(doc, doc._c_doc, c_child)
|
| 209 |
+
c_child = c_next
|
| 210 |
+
else:
|
| 211 |
+
c_next = _nextElement(c_child)
|
| 212 |
+
tree.xmlUnlinkNode(c_child)
|
| 213 |
+
attemptDeallocation(c_child)
|
| 214 |
+
c_child = c_next
|
| 215 |
+
tree.END_FOR_EACH_ELEMENT_FROM(c_node)
|
omnilmm/lib/python3.10/site-packages/lxml/cssselect.py
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""CSS Selectors based on XPath.
|
| 2 |
+
|
| 3 |
+
This module supports selecting XML/HTML tags based on CSS selectors.
|
| 4 |
+
See the `CSSSelector` class for details.
|
| 5 |
+
|
| 6 |
+
This is a thin wrapper around cssselect 0.7 or later.
|
| 7 |
+
"""
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
from . import etree
|
| 11 |
+
try:
|
| 12 |
+
import cssselect as external_cssselect
|
| 13 |
+
except ImportError:
|
| 14 |
+
raise ImportError(
|
| 15 |
+
'cssselect does not seem to be installed. '
|
| 16 |
+
'See https://pypi.org/project/cssselect/')
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
SelectorSyntaxError = external_cssselect.SelectorSyntaxError
|
| 20 |
+
ExpressionError = external_cssselect.ExpressionError
|
| 21 |
+
SelectorError = external_cssselect.SelectorError
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
__all__ = ['SelectorSyntaxError', 'ExpressionError', 'SelectorError',
|
| 25 |
+
'CSSSelector']
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
class LxmlTranslator(external_cssselect.GenericTranslator):
|
| 29 |
+
"""
|
| 30 |
+
A custom CSS selector to XPath translator with lxml-specific extensions.
|
| 31 |
+
"""
|
| 32 |
+
def xpath_contains_function(self, xpath, function):
|
| 33 |
+
# Defined there, removed in later drafts:
|
| 34 |
+
# http://www.w3.org/TR/2001/CR-css3-selectors-20011113/#content-selectors
|
| 35 |
+
if function.argument_types() not in (['STRING'], ['IDENT']):
|
| 36 |
+
raise ExpressionError(
|
| 37 |
+
"Expected a single string or ident for :contains(), got %r"
|
| 38 |
+
% function.arguments)
|
| 39 |
+
value = function.arguments[0].value
|
| 40 |
+
return xpath.add_condition(
|
| 41 |
+
'contains(__lxml_internal_css:lower-case(string(.)), %s)'
|
| 42 |
+
% self.xpath_literal(value.lower()))
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
class LxmlHTMLTranslator(LxmlTranslator, external_cssselect.HTMLTranslator):
|
| 46 |
+
"""
|
| 47 |
+
lxml extensions + HTML support.
|
| 48 |
+
"""
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
def _make_lower_case(context, s):
|
| 52 |
+
return s.lower()
|
| 53 |
+
|
| 54 |
+
ns = etree.FunctionNamespace('http://codespeak.net/lxml/css/')
|
| 55 |
+
ns.prefix = '__lxml_internal_css'
|
| 56 |
+
ns['lower-case'] = _make_lower_case
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
class CSSSelector(etree.XPath):
|
| 60 |
+
"""A CSS selector.
|
| 61 |
+
|
| 62 |
+
Usage::
|
| 63 |
+
|
| 64 |
+
>>> from lxml import etree, cssselect
|
| 65 |
+
>>> select = cssselect.CSSSelector("a tag > child")
|
| 66 |
+
|
| 67 |
+
>>> root = etree.XML("<a><b><c/><tag><child>TEXT</child></tag></b></a>")
|
| 68 |
+
>>> [ el.tag for el in select(root) ]
|
| 69 |
+
['child']
|
| 70 |
+
|
| 71 |
+
To use CSS namespaces, you need to pass a prefix-to-namespace
|
| 72 |
+
mapping as ``namespaces`` keyword argument::
|
| 73 |
+
|
| 74 |
+
>>> rdfns = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
|
| 75 |
+
>>> select_ns = cssselect.CSSSelector('root > rdf|Description',
|
| 76 |
+
... namespaces={'rdf': rdfns})
|
| 77 |
+
|
| 78 |
+
>>> rdf = etree.XML((
|
| 79 |
+
... '<root xmlns:rdf="%s">'
|
| 80 |
+
... '<rdf:Description>blah</rdf:Description>'
|
| 81 |
+
... '</root>') % rdfns)
|
| 82 |
+
>>> [(el.tag, el.text) for el in select_ns(rdf)]
|
| 83 |
+
[('{http://www.w3.org/1999/02/22-rdf-syntax-ns#}Description', 'blah')]
|
| 84 |
+
|
| 85 |
+
"""
|
| 86 |
+
def __init__(self, css, namespaces=None, translator='xml'):
|
| 87 |
+
if translator == 'xml':
|
| 88 |
+
translator = LxmlTranslator()
|
| 89 |
+
elif translator == 'html':
|
| 90 |
+
translator = LxmlHTMLTranslator()
|
| 91 |
+
elif translator == 'xhtml':
|
| 92 |
+
translator = LxmlHTMLTranslator(xhtml=True)
|
| 93 |
+
path = translator.css_to_xpath(css)
|
| 94 |
+
super().__init__(path, namespaces=namespaces)
|
| 95 |
+
self.css = css
|
| 96 |
+
|
| 97 |
+
def __repr__(self):
|
| 98 |
+
return '<%s %x for %r>' % (
|
| 99 |
+
self.__class__.__name__,
|
| 100 |
+
abs(id(self)),
|
| 101 |
+
self.css)
|
omnilmm/lib/python3.10/site-packages/lxml/debug.pxi
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
@cython.final
|
| 2 |
+
@cython.internal
|
| 3 |
+
cdef class _MemDebug:
|
| 4 |
+
"""Debugging support for the memory allocation in libxml2.
|
| 5 |
+
"""
|
| 6 |
+
def bytes_used(self):
|
| 7 |
+
"""bytes_used(self)
|
| 8 |
+
|
| 9 |
+
Returns the total amount of memory (in bytes) currently used by libxml2.
|
| 10 |
+
Note that libxml2 constrains this value to a C int, which limits
|
| 11 |
+
the accuracy on 64 bit systems.
|
| 12 |
+
"""
|
| 13 |
+
return tree.xmlMemUsed()
|
| 14 |
+
|
| 15 |
+
def blocks_used(self):
|
| 16 |
+
"""blocks_used(self)
|
| 17 |
+
|
| 18 |
+
Returns the total number of memory blocks currently allocated by libxml2.
|
| 19 |
+
Note that libxml2 constrains this value to a C int, which limits
|
| 20 |
+
the accuracy on 64 bit systems.
|
| 21 |
+
"""
|
| 22 |
+
return tree.xmlMemBlocks()
|
| 23 |
+
|
| 24 |
+
def dict_size(self):
|
| 25 |
+
"""dict_size(self)
|
| 26 |
+
|
| 27 |
+
Returns the current size of the global name dictionary used by libxml2
|
| 28 |
+
for the current thread. Each thread has its own dictionary.
|
| 29 |
+
"""
|
| 30 |
+
c_dict = __GLOBAL_PARSER_CONTEXT._getThreadDict(NULL)
|
| 31 |
+
if c_dict is NULL:
|
| 32 |
+
raise MemoryError()
|
| 33 |
+
return tree.xmlDictSize(c_dict)
|
| 34 |
+
|
| 35 |
+
def dump(self, output_file=None, byte_count=None):
|
| 36 |
+
"""dump(self, output_file=None, byte_count=None)
|
| 37 |
+
|
| 38 |
+
Dumps the current memory blocks allocated by libxml2 to a file.
|
| 39 |
+
|
| 40 |
+
The optional parameter 'output_file' specifies the file path. It defaults
|
| 41 |
+
to the file ".memorylist" in the current directory.
|
| 42 |
+
|
| 43 |
+
The optional parameter 'byte_count' limits the number of bytes in the dump.
|
| 44 |
+
Note that this parameter is ignored when lxml is compiled against a libxml2
|
| 45 |
+
version before 2.7.0.
|
| 46 |
+
"""
|
| 47 |
+
cdef Py_ssize_t c_count
|
| 48 |
+
if output_file is None:
|
| 49 |
+
output_file = b'.memorylist'
|
| 50 |
+
elif isinstance(output_file, unicode):
|
| 51 |
+
output_file.encode(sys.getfilesystemencoding())
|
| 52 |
+
|
| 53 |
+
f = stdio.fopen(output_file, "w")
|
| 54 |
+
if f is NULL:
|
| 55 |
+
raise IOError(f"Failed to create file {output_file.decode(sys.getfilesystemencoding())}")
|
| 56 |
+
try:
|
| 57 |
+
if byte_count is None:
|
| 58 |
+
tree.xmlMemDisplay(f)
|
| 59 |
+
else:
|
| 60 |
+
c_count = byte_count
|
| 61 |
+
tree.xmlMemDisplayLast(f, c_count)
|
| 62 |
+
finally:
|
| 63 |
+
stdio.fclose(f)
|
| 64 |
+
|
| 65 |
+
def show(self, output_file=None, block_count=None):
|
| 66 |
+
"""show(self, output_file=None, block_count=None)
|
| 67 |
+
|
| 68 |
+
Dumps the current memory blocks allocated by libxml2 to a file.
|
| 69 |
+
The output file format is suitable for line diffing.
|
| 70 |
+
|
| 71 |
+
The optional parameter 'output_file' specifies the file path. It defaults
|
| 72 |
+
to the file ".memorydump" in the current directory.
|
| 73 |
+
|
| 74 |
+
The optional parameter 'block_count' limits the number of blocks
|
| 75 |
+
in the dump.
|
| 76 |
+
"""
|
| 77 |
+
if output_file is None:
|
| 78 |
+
output_file = b'.memorydump'
|
| 79 |
+
elif isinstance(output_file, unicode):
|
| 80 |
+
output_file.encode(sys.getfilesystemencoding())
|
| 81 |
+
|
| 82 |
+
f = stdio.fopen(output_file, "w")
|
| 83 |
+
if f is NULL:
|
| 84 |
+
raise IOError(f"Failed to create file {output_file.decode(sys.getfilesystemencoding())}")
|
| 85 |
+
try:
|
| 86 |
+
tree.xmlMemShow(f, block_count if block_count is not None else tree.xmlMemBlocks())
|
| 87 |
+
finally:
|
| 88 |
+
stdio.fclose(f)
|
| 89 |
+
|
| 90 |
+
memory_debugger = _MemDebug()
|
omnilmm/lib/python3.10/site-packages/lxml/docloader.pxi
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Custom resolver API
|
| 2 |
+
|
| 3 |
+
ctypedef enum _InputDocumentDataType:
|
| 4 |
+
PARSER_DATA_INVALID
|
| 5 |
+
PARSER_DATA_EMPTY
|
| 6 |
+
PARSER_DATA_STRING
|
| 7 |
+
PARSER_DATA_FILENAME
|
| 8 |
+
PARSER_DATA_FILE
|
| 9 |
+
|
| 10 |
+
@cython.final
|
| 11 |
+
@cython.internal
|
| 12 |
+
cdef class _InputDocument:
|
| 13 |
+
cdef _InputDocumentDataType _type
|
| 14 |
+
cdef bytes _data_bytes
|
| 15 |
+
cdef object _filename
|
| 16 |
+
cdef object _file
|
| 17 |
+
cdef bint _close_file
|
| 18 |
+
|
| 19 |
+
def __cinit__(self):
|
| 20 |
+
self._type = PARSER_DATA_INVALID
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
cdef class Resolver:
|
| 24 |
+
"This is the base class of all resolvers."
|
| 25 |
+
def resolve(self, system_url, public_id, context):
|
| 26 |
+
"""resolve(self, system_url, public_id, context)
|
| 27 |
+
|
| 28 |
+
Override this method to resolve an external source by
|
| 29 |
+
``system_url`` and ``public_id``. The third argument is an
|
| 30 |
+
opaque context object.
|
| 31 |
+
|
| 32 |
+
Return the result of one of the ``resolve_*()`` methods.
|
| 33 |
+
"""
|
| 34 |
+
return None
|
| 35 |
+
|
| 36 |
+
def resolve_empty(self, context):
|
| 37 |
+
"""resolve_empty(self, context)
|
| 38 |
+
|
| 39 |
+
Return an empty input document.
|
| 40 |
+
|
| 41 |
+
Pass context as parameter.
|
| 42 |
+
"""
|
| 43 |
+
cdef _InputDocument doc_ref
|
| 44 |
+
doc_ref = _InputDocument()
|
| 45 |
+
doc_ref._type = PARSER_DATA_EMPTY
|
| 46 |
+
return doc_ref
|
| 47 |
+
|
| 48 |
+
def resolve_string(self, string, context, *, base_url=None):
|
| 49 |
+
"""resolve_string(self, string, context, base_url=None)
|
| 50 |
+
|
| 51 |
+
Return a parsable string as input document.
|
| 52 |
+
|
| 53 |
+
Pass data string and context as parameters. You can pass the
|
| 54 |
+
source URL or filename through the ``base_url`` keyword
|
| 55 |
+
argument.
|
| 56 |
+
"""
|
| 57 |
+
cdef _InputDocument doc_ref
|
| 58 |
+
if isinstance(string, unicode):
|
| 59 |
+
string = (<unicode>string).encode('utf8')
|
| 60 |
+
elif not isinstance(string, bytes):
|
| 61 |
+
raise TypeError, "argument must be a byte string or unicode string"
|
| 62 |
+
doc_ref = _InputDocument()
|
| 63 |
+
doc_ref._type = PARSER_DATA_STRING
|
| 64 |
+
doc_ref._data_bytes = string
|
| 65 |
+
if base_url is not None:
|
| 66 |
+
doc_ref._filename = _encodeFilename(base_url)
|
| 67 |
+
return doc_ref
|
| 68 |
+
|
| 69 |
+
def resolve_filename(self, filename, context):
|
| 70 |
+
"""resolve_filename(self, filename, context)
|
| 71 |
+
|
| 72 |
+
Return the name of a parsable file as input document.
|
| 73 |
+
|
| 74 |
+
Pass filename and context as parameters. You can also pass a
|
| 75 |
+
URL with an HTTP, FTP or file target.
|
| 76 |
+
"""
|
| 77 |
+
cdef _InputDocument doc_ref
|
| 78 |
+
doc_ref = _InputDocument()
|
| 79 |
+
doc_ref._type = PARSER_DATA_FILENAME
|
| 80 |
+
doc_ref._filename = _encodeFilename(filename)
|
| 81 |
+
return doc_ref
|
| 82 |
+
|
| 83 |
+
def resolve_file(self, f, context, *, base_url=None, bint close=True):
|
| 84 |
+
"""resolve_file(self, f, context, base_url=None, close=True)
|
| 85 |
+
|
| 86 |
+
Return an open file-like object as input document.
|
| 87 |
+
|
| 88 |
+
Pass open file and context as parameters. You can pass the
|
| 89 |
+
base URL or filename of the file through the ``base_url``
|
| 90 |
+
keyword argument. If the ``close`` flag is True (the
|
| 91 |
+
default), the file will be closed after reading.
|
| 92 |
+
|
| 93 |
+
Note that using ``.resolve_filename()`` is more efficient,
|
| 94 |
+
especially in threaded environments.
|
| 95 |
+
"""
|
| 96 |
+
cdef _InputDocument doc_ref
|
| 97 |
+
try:
|
| 98 |
+
f.read
|
| 99 |
+
except AttributeError:
|
| 100 |
+
raise TypeError, "Argument is not a file-like object"
|
| 101 |
+
doc_ref = _InputDocument()
|
| 102 |
+
doc_ref._type = PARSER_DATA_FILE
|
| 103 |
+
if base_url is not None:
|
| 104 |
+
doc_ref._filename = _encodeFilename(base_url)
|
| 105 |
+
else:
|
| 106 |
+
doc_ref._filename = _getFilenameForFile(f)
|
| 107 |
+
doc_ref._close_file = close
|
| 108 |
+
doc_ref._file = f
|
| 109 |
+
return doc_ref
|
| 110 |
+
|
| 111 |
+
@cython.final
|
| 112 |
+
@cython.internal
|
| 113 |
+
cdef class _ResolverRegistry:
|
| 114 |
+
cdef object _resolvers
|
| 115 |
+
cdef Resolver _default_resolver
|
| 116 |
+
def __cinit__(self, Resolver default_resolver=None):
|
| 117 |
+
self._resolvers = set()
|
| 118 |
+
self._default_resolver = default_resolver
|
| 119 |
+
|
| 120 |
+
def add(self, Resolver resolver not None):
|
| 121 |
+
"""add(self, resolver)
|
| 122 |
+
|
| 123 |
+
Register a resolver.
|
| 124 |
+
|
| 125 |
+
For each requested entity, the 'resolve' method of the resolver will
|
| 126 |
+
be called and the result will be passed to the parser. If this method
|
| 127 |
+
returns None, the request will be delegated to other resolvers or the
|
| 128 |
+
default resolver. The resolvers will be tested in an arbitrary order
|
| 129 |
+
until the first match is found.
|
| 130 |
+
"""
|
| 131 |
+
self._resolvers.add(resolver)
|
| 132 |
+
|
| 133 |
+
def remove(self, resolver):
|
| 134 |
+
"remove(self, resolver)"
|
| 135 |
+
self._resolvers.discard(resolver)
|
| 136 |
+
|
| 137 |
+
cdef _ResolverRegistry _copy(self):
|
| 138 |
+
cdef _ResolverRegistry registry
|
| 139 |
+
registry = _ResolverRegistry(self._default_resolver)
|
| 140 |
+
registry._resolvers = self._resolvers.copy()
|
| 141 |
+
return registry
|
| 142 |
+
|
| 143 |
+
def copy(self):
|
| 144 |
+
"copy(self)"
|
| 145 |
+
return self._copy()
|
| 146 |
+
|
| 147 |
+
def resolve(self, system_url, public_id, context):
|
| 148 |
+
"resolve(self, system_url, public_id, context)"
|
| 149 |
+
for resolver in self._resolvers:
|
| 150 |
+
result = resolver.resolve(system_url, public_id, context)
|
| 151 |
+
if result is not None:
|
| 152 |
+
return result
|
| 153 |
+
if self._default_resolver is None:
|
| 154 |
+
return None
|
| 155 |
+
return self._default_resolver.resolve(system_url, public_id, context)
|
| 156 |
+
|
| 157 |
+
def __repr__(self):
|
| 158 |
+
return repr(self._resolvers)
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
@cython.internal
|
| 162 |
+
cdef class _ResolverContext(_ExceptionContext):
|
| 163 |
+
cdef _ResolverRegistry _resolvers
|
| 164 |
+
cdef _TempStore _storage
|
| 165 |
+
|
| 166 |
+
cdef int clear(self) except -1:
|
| 167 |
+
_ExceptionContext.clear(self)
|
| 168 |
+
self._storage.clear()
|
| 169 |
+
return 0
|
| 170 |
+
|
| 171 |
+
|
| 172 |
+
cdef _initResolverContext(_ResolverContext context,
|
| 173 |
+
_ResolverRegistry resolvers):
|
| 174 |
+
if resolvers is None:
|
| 175 |
+
context._resolvers = _ResolverRegistry()
|
| 176 |
+
else:
|
| 177 |
+
context._resolvers = resolvers
|
| 178 |
+
context._storage = _TempStore()
|
omnilmm/lib/python3.10/site-packages/lxml/doctestcompare.py
ADDED
|
@@ -0,0 +1,488 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
lxml-based doctest output comparison.
|
| 3 |
+
|
| 4 |
+
Note: normally, you should just import the `lxml.usedoctest` and
|
| 5 |
+
`lxml.html.usedoctest` modules from within a doctest, instead of this
|
| 6 |
+
one::
|
| 7 |
+
|
| 8 |
+
>>> import lxml.usedoctest # for XML output
|
| 9 |
+
|
| 10 |
+
>>> import lxml.html.usedoctest # for HTML output
|
| 11 |
+
|
| 12 |
+
To use this module directly, you must call ``lxmldoctest.install()``,
|
| 13 |
+
which will cause doctest to use this in all subsequent calls.
|
| 14 |
+
|
| 15 |
+
This changes the way output is checked and comparisons are made for
|
| 16 |
+
XML or HTML-like content.
|
| 17 |
+
|
| 18 |
+
XML or HTML content is noticed because the example starts with ``<``
|
| 19 |
+
(it's HTML if it starts with ``<html``). You can also use the
|
| 20 |
+
``PARSE_HTML`` and ``PARSE_XML`` flags to force parsing.
|
| 21 |
+
|
| 22 |
+
Some rough wildcard-like things are allowed. Whitespace is generally
|
| 23 |
+
ignored (except in attributes). In text (attributes and text in the
|
| 24 |
+
body) you can use ``...`` as a wildcard. In an example it also
|
| 25 |
+
matches any trailing tags in the element, though it does not match
|
| 26 |
+
leading tags. You may create a tag ``<any>`` or include an ``any``
|
| 27 |
+
attribute in the tag. An ``any`` tag matches any tag, while the
|
| 28 |
+
attribute matches any and all attributes.
|
| 29 |
+
|
| 30 |
+
When a match fails, the reformatted example and gotten text is
|
| 31 |
+
displayed (indented), and a rough diff-like output is given. Anything
|
| 32 |
+
marked with ``+`` is in the output but wasn't supposed to be, and
|
| 33 |
+
similarly ``-`` means its in the example but wasn't in the output.
|
| 34 |
+
|
| 35 |
+
You can disable parsing on one line with ``# doctest:+NOPARSE_MARKUP``
|
| 36 |
+
"""
|
| 37 |
+
|
| 38 |
+
from lxml import etree
|
| 39 |
+
import sys
|
| 40 |
+
import re
|
| 41 |
+
import doctest
|
| 42 |
+
try:
|
| 43 |
+
from html import escape as html_escape
|
| 44 |
+
except ImportError:
|
| 45 |
+
from cgi import escape as html_escape
|
| 46 |
+
|
| 47 |
+
__all__ = ['PARSE_HTML', 'PARSE_XML', 'NOPARSE_MARKUP', 'LXMLOutputChecker',
|
| 48 |
+
'LHTMLOutputChecker', 'install', 'temp_install']
|
| 49 |
+
|
| 50 |
+
PARSE_HTML = doctest.register_optionflag('PARSE_HTML')
|
| 51 |
+
PARSE_XML = doctest.register_optionflag('PARSE_XML')
|
| 52 |
+
NOPARSE_MARKUP = doctest.register_optionflag('NOPARSE_MARKUP')
|
| 53 |
+
|
| 54 |
+
OutputChecker = doctest.OutputChecker
|
| 55 |
+
|
| 56 |
+
def strip(v):
|
| 57 |
+
if v is None:
|
| 58 |
+
return None
|
| 59 |
+
else:
|
| 60 |
+
return v.strip()
|
| 61 |
+
|
| 62 |
+
def norm_whitespace(v):
|
| 63 |
+
return _norm_whitespace_re.sub(' ', v)
|
| 64 |
+
|
| 65 |
+
_html_parser = etree.HTMLParser(recover=False, remove_blank_text=True)
|
| 66 |
+
|
| 67 |
+
def html_fromstring(html):
|
| 68 |
+
return etree.fromstring(html, _html_parser)
|
| 69 |
+
|
| 70 |
+
# We use this to distinguish repr()s from elements:
|
| 71 |
+
_repr_re = re.compile(r'^<[^>]+ (at|object) ')
|
| 72 |
+
_norm_whitespace_re = re.compile(r'[ \t\n][ \t\n]+')
|
| 73 |
+
|
| 74 |
+
class LXMLOutputChecker(OutputChecker):
|
| 75 |
+
|
| 76 |
+
empty_tags = (
|
| 77 |
+
'param', 'img', 'area', 'br', 'basefont', 'input',
|
| 78 |
+
'base', 'meta', 'link', 'col')
|
| 79 |
+
|
| 80 |
+
def get_default_parser(self):
|
| 81 |
+
return etree.XML
|
| 82 |
+
|
| 83 |
+
def check_output(self, want, got, optionflags):
|
| 84 |
+
alt_self = getattr(self, '_temp_override_self', None)
|
| 85 |
+
if alt_self is not None:
|
| 86 |
+
super_method = self._temp_call_super_check_output
|
| 87 |
+
self = alt_self
|
| 88 |
+
else:
|
| 89 |
+
super_method = OutputChecker.check_output
|
| 90 |
+
parser = self.get_parser(want, got, optionflags)
|
| 91 |
+
if not parser:
|
| 92 |
+
return super_method(
|
| 93 |
+
self, want, got, optionflags)
|
| 94 |
+
try:
|
| 95 |
+
want_doc = parser(want)
|
| 96 |
+
except etree.XMLSyntaxError:
|
| 97 |
+
return False
|
| 98 |
+
try:
|
| 99 |
+
got_doc = parser(got)
|
| 100 |
+
except etree.XMLSyntaxError:
|
| 101 |
+
return False
|
| 102 |
+
return self.compare_docs(want_doc, got_doc)
|
| 103 |
+
|
| 104 |
+
def get_parser(self, want, got, optionflags):
|
| 105 |
+
parser = None
|
| 106 |
+
if NOPARSE_MARKUP & optionflags:
|
| 107 |
+
return None
|
| 108 |
+
if PARSE_HTML & optionflags:
|
| 109 |
+
parser = html_fromstring
|
| 110 |
+
elif PARSE_XML & optionflags:
|
| 111 |
+
parser = etree.XML
|
| 112 |
+
elif (want.strip().lower().startswith('<html')
|
| 113 |
+
and got.strip().startswith('<html')):
|
| 114 |
+
parser = html_fromstring
|
| 115 |
+
elif (self._looks_like_markup(want)
|
| 116 |
+
and self._looks_like_markup(got)):
|
| 117 |
+
parser = self.get_default_parser()
|
| 118 |
+
return parser
|
| 119 |
+
|
| 120 |
+
def _looks_like_markup(self, s):
|
| 121 |
+
s = s.strip()
|
| 122 |
+
return (s.startswith('<')
|
| 123 |
+
and not _repr_re.search(s))
|
| 124 |
+
|
| 125 |
+
def compare_docs(self, want, got):
|
| 126 |
+
if not self.tag_compare(want.tag, got.tag):
|
| 127 |
+
return False
|
| 128 |
+
if not self.text_compare(want.text, got.text, True):
|
| 129 |
+
return False
|
| 130 |
+
if not self.text_compare(want.tail, got.tail, True):
|
| 131 |
+
return False
|
| 132 |
+
if 'any' not in want.attrib:
|
| 133 |
+
want_keys = sorted(want.attrib.keys())
|
| 134 |
+
got_keys = sorted(got.attrib.keys())
|
| 135 |
+
if want_keys != got_keys:
|
| 136 |
+
return False
|
| 137 |
+
for key in want_keys:
|
| 138 |
+
if not self.text_compare(want.attrib[key], got.attrib[key], False):
|
| 139 |
+
return False
|
| 140 |
+
if want.text != '...' or len(want):
|
| 141 |
+
want_children = list(want)
|
| 142 |
+
got_children = list(got)
|
| 143 |
+
while want_children or got_children:
|
| 144 |
+
if not want_children or not got_children:
|
| 145 |
+
return False
|
| 146 |
+
want_first = want_children.pop(0)
|
| 147 |
+
got_first = got_children.pop(0)
|
| 148 |
+
if not self.compare_docs(want_first, got_first):
|
| 149 |
+
return False
|
| 150 |
+
if not got_children and want_first.tail == '...':
|
| 151 |
+
break
|
| 152 |
+
return True
|
| 153 |
+
|
| 154 |
+
def text_compare(self, want, got, strip):
|
| 155 |
+
want = want or ''
|
| 156 |
+
got = got or ''
|
| 157 |
+
if strip:
|
| 158 |
+
want = norm_whitespace(want).strip()
|
| 159 |
+
got = norm_whitespace(got).strip()
|
| 160 |
+
want = '^%s$' % re.escape(want)
|
| 161 |
+
want = want.replace(r'\.\.\.', '.*')
|
| 162 |
+
if re.search(want, got):
|
| 163 |
+
return True
|
| 164 |
+
else:
|
| 165 |
+
return False
|
| 166 |
+
|
| 167 |
+
def tag_compare(self, want, got):
|
| 168 |
+
if want == 'any':
|
| 169 |
+
return True
|
| 170 |
+
if (not isinstance(want, (str, bytes))
|
| 171 |
+
or not isinstance(got, (str, bytes))):
|
| 172 |
+
return want == got
|
| 173 |
+
want = want or ''
|
| 174 |
+
got = got or ''
|
| 175 |
+
if want.startswith('{...}'):
|
| 176 |
+
# Ellipsis on the namespace
|
| 177 |
+
return want.split('}')[-1] == got.split('}')[-1]
|
| 178 |
+
else:
|
| 179 |
+
return want == got
|
| 180 |
+
|
| 181 |
+
def output_difference(self, example, got, optionflags):
|
| 182 |
+
want = example.want
|
| 183 |
+
parser = self.get_parser(want, got, optionflags)
|
| 184 |
+
errors = []
|
| 185 |
+
if parser is not None:
|
| 186 |
+
try:
|
| 187 |
+
want_doc = parser(want)
|
| 188 |
+
except etree.XMLSyntaxError:
|
| 189 |
+
e = sys.exc_info()[1]
|
| 190 |
+
errors.append('In example: %s' % e)
|
| 191 |
+
try:
|
| 192 |
+
got_doc = parser(got)
|
| 193 |
+
except etree.XMLSyntaxError:
|
| 194 |
+
e = sys.exc_info()[1]
|
| 195 |
+
errors.append('In actual output: %s' % e)
|
| 196 |
+
if parser is None or errors:
|
| 197 |
+
value = OutputChecker.output_difference(
|
| 198 |
+
self, example, got, optionflags)
|
| 199 |
+
if errors:
|
| 200 |
+
errors.append(value)
|
| 201 |
+
return '\n'.join(errors)
|
| 202 |
+
else:
|
| 203 |
+
return value
|
| 204 |
+
html = parser is html_fromstring
|
| 205 |
+
diff_parts = ['Expected:',
|
| 206 |
+
self.format_doc(want_doc, html, 2),
|
| 207 |
+
'Got:',
|
| 208 |
+
self.format_doc(got_doc, html, 2),
|
| 209 |
+
'Diff:',
|
| 210 |
+
self.collect_diff(want_doc, got_doc, html, 2)]
|
| 211 |
+
return '\n'.join(diff_parts)
|
| 212 |
+
|
| 213 |
+
def html_empty_tag(self, el, html=True):
|
| 214 |
+
if not html:
|
| 215 |
+
return False
|
| 216 |
+
if el.tag not in self.empty_tags:
|
| 217 |
+
return False
|
| 218 |
+
if el.text or len(el):
|
| 219 |
+
# This shouldn't happen (contents in an empty tag)
|
| 220 |
+
return False
|
| 221 |
+
return True
|
| 222 |
+
|
| 223 |
+
def format_doc(self, doc, html, indent, prefix=''):
|
| 224 |
+
parts = []
|
| 225 |
+
if not len(doc):
|
| 226 |
+
# No children...
|
| 227 |
+
parts.append(' '*indent)
|
| 228 |
+
parts.append(prefix)
|
| 229 |
+
parts.append(self.format_tag(doc))
|
| 230 |
+
if not self.html_empty_tag(doc, html):
|
| 231 |
+
if strip(doc.text):
|
| 232 |
+
parts.append(self.format_text(doc.text))
|
| 233 |
+
parts.append(self.format_end_tag(doc))
|
| 234 |
+
if strip(doc.tail):
|
| 235 |
+
parts.append(self.format_text(doc.tail))
|
| 236 |
+
parts.append('\n')
|
| 237 |
+
return ''.join(parts)
|
| 238 |
+
parts.append(' '*indent)
|
| 239 |
+
parts.append(prefix)
|
| 240 |
+
parts.append(self.format_tag(doc))
|
| 241 |
+
if not self.html_empty_tag(doc, html):
|
| 242 |
+
parts.append('\n')
|
| 243 |
+
if strip(doc.text):
|
| 244 |
+
parts.append(' '*indent)
|
| 245 |
+
parts.append(self.format_text(doc.text))
|
| 246 |
+
parts.append('\n')
|
| 247 |
+
for el in doc:
|
| 248 |
+
parts.append(self.format_doc(el, html, indent+2))
|
| 249 |
+
parts.append(' '*indent)
|
| 250 |
+
parts.append(self.format_end_tag(doc))
|
| 251 |
+
parts.append('\n')
|
| 252 |
+
if strip(doc.tail):
|
| 253 |
+
parts.append(' '*indent)
|
| 254 |
+
parts.append(self.format_text(doc.tail))
|
| 255 |
+
parts.append('\n')
|
| 256 |
+
return ''.join(parts)
|
| 257 |
+
|
| 258 |
+
def format_text(self, text, strip=True):
|
| 259 |
+
if text is None:
|
| 260 |
+
return ''
|
| 261 |
+
if strip:
|
| 262 |
+
text = text.strip()
|
| 263 |
+
return html_escape(text, 1)
|
| 264 |
+
|
| 265 |
+
def format_tag(self, el):
|
| 266 |
+
attrs = []
|
| 267 |
+
if isinstance(el, etree.CommentBase):
|
| 268 |
+
# FIXME: probably PIs should be handled specially too?
|
| 269 |
+
return '<!--'
|
| 270 |
+
for name, value in sorted(el.attrib.items()):
|
| 271 |
+
attrs.append('%s="%s"' % (name, self.format_text(value, False)))
|
| 272 |
+
if not attrs:
|
| 273 |
+
return '<%s>' % el.tag
|
| 274 |
+
return '<%s %s>' % (el.tag, ' '.join(attrs))
|
| 275 |
+
|
| 276 |
+
def format_end_tag(self, el):
|
| 277 |
+
if isinstance(el, etree.CommentBase):
|
| 278 |
+
# FIXME: probably PIs should be handled specially too?
|
| 279 |
+
return '-->'
|
| 280 |
+
return '</%s>' % el.tag
|
| 281 |
+
|
| 282 |
+
def collect_diff(self, want, got, html, indent):
|
| 283 |
+
parts = []
|
| 284 |
+
if not len(want) and not len(got):
|
| 285 |
+
parts.append(' '*indent)
|
| 286 |
+
parts.append(self.collect_diff_tag(want, got))
|
| 287 |
+
if not self.html_empty_tag(got, html):
|
| 288 |
+
parts.append(self.collect_diff_text(want.text, got.text))
|
| 289 |
+
parts.append(self.collect_diff_end_tag(want, got))
|
| 290 |
+
parts.append(self.collect_diff_text(want.tail, got.tail))
|
| 291 |
+
parts.append('\n')
|
| 292 |
+
return ''.join(parts)
|
| 293 |
+
parts.append(' '*indent)
|
| 294 |
+
parts.append(self.collect_diff_tag(want, got))
|
| 295 |
+
parts.append('\n')
|
| 296 |
+
if strip(want.text) or strip(got.text):
|
| 297 |
+
parts.append(' '*indent)
|
| 298 |
+
parts.append(self.collect_diff_text(want.text, got.text))
|
| 299 |
+
parts.append('\n')
|
| 300 |
+
want_children = list(want)
|
| 301 |
+
got_children = list(got)
|
| 302 |
+
while want_children or got_children:
|
| 303 |
+
if not want_children:
|
| 304 |
+
parts.append(self.format_doc(got_children.pop(0), html, indent+2, '+'))
|
| 305 |
+
continue
|
| 306 |
+
if not got_children:
|
| 307 |
+
parts.append(self.format_doc(want_children.pop(0), html, indent+2, '-'))
|
| 308 |
+
continue
|
| 309 |
+
parts.append(self.collect_diff(
|
| 310 |
+
want_children.pop(0), got_children.pop(0), html, indent+2))
|
| 311 |
+
parts.append(' '*indent)
|
| 312 |
+
parts.append(self.collect_diff_end_tag(want, got))
|
| 313 |
+
parts.append('\n')
|
| 314 |
+
if strip(want.tail) or strip(got.tail):
|
| 315 |
+
parts.append(' '*indent)
|
| 316 |
+
parts.append(self.collect_diff_text(want.tail, got.tail))
|
| 317 |
+
parts.append('\n')
|
| 318 |
+
return ''.join(parts)
|
| 319 |
+
|
| 320 |
+
def collect_diff_tag(self, want, got):
|
| 321 |
+
if not self.tag_compare(want.tag, got.tag):
|
| 322 |
+
tag = '%s (got: %s)' % (want.tag, got.tag)
|
| 323 |
+
else:
|
| 324 |
+
tag = got.tag
|
| 325 |
+
attrs = []
|
| 326 |
+
any = want.tag == 'any' or 'any' in want.attrib
|
| 327 |
+
for name, value in sorted(got.attrib.items()):
|
| 328 |
+
if name not in want.attrib and not any:
|
| 329 |
+
attrs.append('+%s="%s"' % (name, self.format_text(value, False)))
|
| 330 |
+
else:
|
| 331 |
+
if name in want.attrib:
|
| 332 |
+
text = self.collect_diff_text(want.attrib[name], value, False)
|
| 333 |
+
else:
|
| 334 |
+
text = self.format_text(value, False)
|
| 335 |
+
attrs.append('%s="%s"' % (name, text))
|
| 336 |
+
if not any:
|
| 337 |
+
for name, value in sorted(want.attrib.items()):
|
| 338 |
+
if name in got.attrib:
|
| 339 |
+
continue
|
| 340 |
+
attrs.append('-%s="%s"' % (name, self.format_text(value, False)))
|
| 341 |
+
if attrs:
|
| 342 |
+
tag = '<%s %s>' % (tag, ' '.join(attrs))
|
| 343 |
+
else:
|
| 344 |
+
tag = '<%s>' % tag
|
| 345 |
+
return tag
|
| 346 |
+
|
| 347 |
+
def collect_diff_end_tag(self, want, got):
|
| 348 |
+
if want.tag != got.tag:
|
| 349 |
+
tag = '%s (got: %s)' % (want.tag, got.tag)
|
| 350 |
+
else:
|
| 351 |
+
tag = got.tag
|
| 352 |
+
return '</%s>' % tag
|
| 353 |
+
|
| 354 |
+
def collect_diff_text(self, want, got, strip=True):
|
| 355 |
+
if self.text_compare(want, got, strip):
|
| 356 |
+
if not got:
|
| 357 |
+
return ''
|
| 358 |
+
return self.format_text(got, strip)
|
| 359 |
+
text = '%s (got: %s)' % (want, got)
|
| 360 |
+
return self.format_text(text, strip)
|
| 361 |
+
|
| 362 |
+
class LHTMLOutputChecker(LXMLOutputChecker):
|
| 363 |
+
def get_default_parser(self):
|
| 364 |
+
return html_fromstring
|
| 365 |
+
|
| 366 |
+
def install(html=False):
|
| 367 |
+
"""
|
| 368 |
+
Install doctestcompare for all future doctests.
|
| 369 |
+
|
| 370 |
+
If html is true, then by default the HTML parser will be used;
|
| 371 |
+
otherwise the XML parser is used.
|
| 372 |
+
"""
|
| 373 |
+
if html:
|
| 374 |
+
doctest.OutputChecker = LHTMLOutputChecker
|
| 375 |
+
else:
|
| 376 |
+
doctest.OutputChecker = LXMLOutputChecker
|
| 377 |
+
|
| 378 |
+
def temp_install(html=False, del_module=None):
|
| 379 |
+
"""
|
| 380 |
+
Use this *inside* a doctest to enable this checker for this
|
| 381 |
+
doctest only.
|
| 382 |
+
|
| 383 |
+
If html is true, then by default the HTML parser will be used;
|
| 384 |
+
otherwise the XML parser is used.
|
| 385 |
+
"""
|
| 386 |
+
if html:
|
| 387 |
+
Checker = LHTMLOutputChecker
|
| 388 |
+
else:
|
| 389 |
+
Checker = LXMLOutputChecker
|
| 390 |
+
frame = _find_doctest_frame()
|
| 391 |
+
dt_self = frame.f_locals['self']
|
| 392 |
+
checker = Checker()
|
| 393 |
+
old_checker = dt_self._checker
|
| 394 |
+
dt_self._checker = checker
|
| 395 |
+
# The unfortunate thing is that there is a local variable 'check'
|
| 396 |
+
# in the function that runs the doctests, that is a bound method
|
| 397 |
+
# into the output checker. We have to update that. We can't
|
| 398 |
+
# modify the frame, so we have to modify the object in place. The
|
| 399 |
+
# only way to do this is to actually change the func_code
|
| 400 |
+
# attribute of the method. We change it, and then wait for
|
| 401 |
+
# __record_outcome to be run, which signals the end of the __run
|
| 402 |
+
# method, at which point we restore the previous check_output
|
| 403 |
+
# implementation.
|
| 404 |
+
check_func = frame.f_locals['check'].__func__
|
| 405 |
+
checker_check_func = checker.check_output.__func__
|
| 406 |
+
# Because we can't patch up func_globals, this is the only global
|
| 407 |
+
# in check_output that we care about:
|
| 408 |
+
doctest.etree = etree
|
| 409 |
+
_RestoreChecker(dt_self, old_checker, checker,
|
| 410 |
+
check_func, checker_check_func,
|
| 411 |
+
del_module)
|
| 412 |
+
|
| 413 |
+
class _RestoreChecker:
|
| 414 |
+
def __init__(self, dt_self, old_checker, new_checker, check_func, clone_func,
|
| 415 |
+
del_module):
|
| 416 |
+
self.dt_self = dt_self
|
| 417 |
+
self.checker = old_checker
|
| 418 |
+
self.checker._temp_call_super_check_output = self.call_super
|
| 419 |
+
self.checker._temp_override_self = new_checker
|
| 420 |
+
self.check_func = check_func
|
| 421 |
+
self.clone_func = clone_func
|
| 422 |
+
self.del_module = del_module
|
| 423 |
+
self.install_clone()
|
| 424 |
+
self.install_dt_self()
|
| 425 |
+
def install_clone(self):
|
| 426 |
+
self.func_code = self.check_func.__code__
|
| 427 |
+
self.func_globals = self.check_func.__globals__
|
| 428 |
+
self.check_func.__code__ = self.clone_func.__code__
|
| 429 |
+
def uninstall_clone(self):
|
| 430 |
+
self.check_func.__code__ = self.func_code
|
| 431 |
+
def install_dt_self(self):
|
| 432 |
+
self.prev_func = self.dt_self._DocTestRunner__record_outcome
|
| 433 |
+
self.dt_self._DocTestRunner__record_outcome = self
|
| 434 |
+
def uninstall_dt_self(self):
|
| 435 |
+
self.dt_self._DocTestRunner__record_outcome = self.prev_func
|
| 436 |
+
def uninstall_module(self):
|
| 437 |
+
if self.del_module:
|
| 438 |
+
import sys
|
| 439 |
+
del sys.modules[self.del_module]
|
| 440 |
+
if '.' in self.del_module:
|
| 441 |
+
package, module = self.del_module.rsplit('.', 1)
|
| 442 |
+
package_mod = sys.modules[package]
|
| 443 |
+
delattr(package_mod, module)
|
| 444 |
+
def __call__(self, *args, **kw):
|
| 445 |
+
self.uninstall_clone()
|
| 446 |
+
self.uninstall_dt_self()
|
| 447 |
+
del self.checker._temp_override_self
|
| 448 |
+
del self.checker._temp_call_super_check_output
|
| 449 |
+
result = self.prev_func(*args, **kw)
|
| 450 |
+
self.uninstall_module()
|
| 451 |
+
return result
|
| 452 |
+
def call_super(self, *args, **kw):
|
| 453 |
+
self.uninstall_clone()
|
| 454 |
+
try:
|
| 455 |
+
return self.check_func(*args, **kw)
|
| 456 |
+
finally:
|
| 457 |
+
self.install_clone()
|
| 458 |
+
|
| 459 |
+
def _find_doctest_frame():
|
| 460 |
+
import sys
|
| 461 |
+
frame = sys._getframe(1)
|
| 462 |
+
while frame:
|
| 463 |
+
l = frame.f_locals
|
| 464 |
+
if 'BOOM' in l:
|
| 465 |
+
# Sign of doctest
|
| 466 |
+
return frame
|
| 467 |
+
frame = frame.f_back
|
| 468 |
+
raise LookupError(
|
| 469 |
+
"Could not find doctest (only use this function *inside* a doctest)")
|
| 470 |
+
|
| 471 |
+
__test__ = {
|
| 472 |
+
'basic': '''
|
| 473 |
+
>>> temp_install()
|
| 474 |
+
>>> print """<xml a="1" b="2">stuff</xml>"""
|
| 475 |
+
<xml b="2" a="1">...</xml>
|
| 476 |
+
>>> print """<xml xmlns="http://example.com"><tag attr="bar" /></xml>"""
|
| 477 |
+
<xml xmlns="...">
|
| 478 |
+
<tag attr="..." />
|
| 479 |
+
</xml>
|
| 480 |
+
>>> print """<xml>blahblahblah<foo /></xml>""" # doctest: +NOPARSE_MARKUP, +ELLIPSIS
|
| 481 |
+
<xml>...foo /></xml>
|
| 482 |
+
'''}
|
| 483 |
+
|
| 484 |
+
if __name__ == '__main__':
|
| 485 |
+
import doctest
|
| 486 |
+
doctest.testmod()
|
| 487 |
+
|
| 488 |
+
|
omnilmm/lib/python3.10/site-packages/lxml/dtd.pxi
ADDED
|
@@ -0,0 +1,478 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# support for DTD validation
|
| 2 |
+
from lxml.includes cimport dtdvalid
|
| 3 |
+
|
| 4 |
+
cdef class DTDError(LxmlError):
|
| 5 |
+
"""Base class for DTD errors.
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
cdef class DTDParseError(DTDError):
|
| 9 |
+
"""Error while parsing a DTD.
|
| 10 |
+
"""
|
| 11 |
+
|
| 12 |
+
cdef class DTDValidateError(DTDError):
|
| 13 |
+
"""Error while validating an XML document with a DTD.
|
| 14 |
+
"""
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
cdef inline int _assertValidDTDNode(node, void *c_node) except -1:
|
| 18 |
+
assert c_node is not NULL, "invalid DTD proxy at %s" % id(node)
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
@cython.final
|
| 22 |
+
@cython.internal
|
| 23 |
+
@cython.freelist(8)
|
| 24 |
+
cdef class _DTDElementContentDecl:
|
| 25 |
+
cdef DTD _dtd
|
| 26 |
+
cdef tree.xmlElementContent* _c_node
|
| 27 |
+
|
| 28 |
+
def __repr__(self):
|
| 29 |
+
return "<%s.%s object name=%r type=%r occur=%r at 0x%x>" % (self.__class__.__module__, self.__class__.__name__, self.name, self.type, self.occur, id(self))
|
| 30 |
+
|
| 31 |
+
@property
|
| 32 |
+
def name(self):
|
| 33 |
+
_assertValidDTDNode(self, self._c_node)
|
| 34 |
+
return funicodeOrNone(self._c_node.name)
|
| 35 |
+
|
| 36 |
+
@property
|
| 37 |
+
def type(self):
|
| 38 |
+
_assertValidDTDNode(self, self._c_node)
|
| 39 |
+
cdef int type = self._c_node.type
|
| 40 |
+
if type == tree.XML_ELEMENT_CONTENT_PCDATA:
|
| 41 |
+
return "pcdata"
|
| 42 |
+
elif type == tree.XML_ELEMENT_CONTENT_ELEMENT:
|
| 43 |
+
return "element"
|
| 44 |
+
elif type == tree.XML_ELEMENT_CONTENT_SEQ:
|
| 45 |
+
return "seq"
|
| 46 |
+
elif type == tree.XML_ELEMENT_CONTENT_OR:
|
| 47 |
+
return "or"
|
| 48 |
+
else:
|
| 49 |
+
return None
|
| 50 |
+
|
| 51 |
+
@property
|
| 52 |
+
def occur(self):
|
| 53 |
+
_assertValidDTDNode(self, self._c_node)
|
| 54 |
+
cdef int occur = self._c_node.ocur
|
| 55 |
+
if occur == tree.XML_ELEMENT_CONTENT_ONCE:
|
| 56 |
+
return "once"
|
| 57 |
+
elif occur == tree.XML_ELEMENT_CONTENT_OPT:
|
| 58 |
+
return "opt"
|
| 59 |
+
elif occur == tree.XML_ELEMENT_CONTENT_MULT:
|
| 60 |
+
return "mult"
|
| 61 |
+
elif occur == tree.XML_ELEMENT_CONTENT_PLUS:
|
| 62 |
+
return "plus"
|
| 63 |
+
else:
|
| 64 |
+
return None
|
| 65 |
+
|
| 66 |
+
@property
|
| 67 |
+
def left(self):
|
| 68 |
+
_assertValidDTDNode(self, self._c_node)
|
| 69 |
+
c1 = self._c_node.c1
|
| 70 |
+
if c1:
|
| 71 |
+
node = <_DTDElementContentDecl>_DTDElementContentDecl.__new__(_DTDElementContentDecl)
|
| 72 |
+
node._dtd = self._dtd
|
| 73 |
+
node._c_node = <tree.xmlElementContent*>c1
|
| 74 |
+
return node
|
| 75 |
+
else:
|
| 76 |
+
return None
|
| 77 |
+
|
| 78 |
+
@property
|
| 79 |
+
def right(self):
|
| 80 |
+
_assertValidDTDNode(self, self._c_node)
|
| 81 |
+
c2 = self._c_node.c2
|
| 82 |
+
if c2:
|
| 83 |
+
node = <_DTDElementContentDecl>_DTDElementContentDecl.__new__(_DTDElementContentDecl)
|
| 84 |
+
node._dtd = self._dtd
|
| 85 |
+
node._c_node = <tree.xmlElementContent*>c2
|
| 86 |
+
return node
|
| 87 |
+
else:
|
| 88 |
+
return None
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
@cython.final
|
| 92 |
+
@cython.internal
|
| 93 |
+
@cython.freelist(8)
|
| 94 |
+
cdef class _DTDAttributeDecl:
|
| 95 |
+
cdef DTD _dtd
|
| 96 |
+
cdef tree.xmlAttribute* _c_node
|
| 97 |
+
|
| 98 |
+
def __repr__(self):
|
| 99 |
+
return "<%s.%s object name=%r elemname=%r prefix=%r type=%r default=%r default_value=%r at 0x%x>" % (self.__class__.__module__, self.__class__.__name__, self.name, self.elemname, self.prefix, self.type, self.default, self.default_value, id(self))
|
| 100 |
+
|
| 101 |
+
@property
|
| 102 |
+
def name(self):
|
| 103 |
+
_assertValidDTDNode(self, self._c_node)
|
| 104 |
+
return funicodeOrNone(self._c_node.name)
|
| 105 |
+
|
| 106 |
+
@property
|
| 107 |
+
def elemname(self):
|
| 108 |
+
_assertValidDTDNode(self, self._c_node)
|
| 109 |
+
return funicodeOrNone(self._c_node.elem)
|
| 110 |
+
|
| 111 |
+
@property
|
| 112 |
+
def prefix(self):
|
| 113 |
+
_assertValidDTDNode(self, self._c_node)
|
| 114 |
+
return funicodeOrNone(self._c_node.prefix)
|
| 115 |
+
|
| 116 |
+
@property
|
| 117 |
+
def type(self):
|
| 118 |
+
_assertValidDTDNode(self, self._c_node)
|
| 119 |
+
cdef int type = self._c_node.atype
|
| 120 |
+
if type == tree.XML_ATTRIBUTE_CDATA:
|
| 121 |
+
return "cdata"
|
| 122 |
+
elif type == tree.XML_ATTRIBUTE_ID:
|
| 123 |
+
return "id"
|
| 124 |
+
elif type == tree.XML_ATTRIBUTE_IDREF:
|
| 125 |
+
return "idref"
|
| 126 |
+
elif type == tree.XML_ATTRIBUTE_IDREFS:
|
| 127 |
+
return "idrefs"
|
| 128 |
+
elif type == tree.XML_ATTRIBUTE_ENTITY:
|
| 129 |
+
return "entity"
|
| 130 |
+
elif type == tree.XML_ATTRIBUTE_ENTITIES:
|
| 131 |
+
return "entities"
|
| 132 |
+
elif type == tree.XML_ATTRIBUTE_NMTOKEN:
|
| 133 |
+
return "nmtoken"
|
| 134 |
+
elif type == tree.XML_ATTRIBUTE_NMTOKENS:
|
| 135 |
+
return "nmtokens"
|
| 136 |
+
elif type == tree.XML_ATTRIBUTE_ENUMERATION:
|
| 137 |
+
return "enumeration"
|
| 138 |
+
elif type == tree.XML_ATTRIBUTE_NOTATION:
|
| 139 |
+
return "notation"
|
| 140 |
+
else:
|
| 141 |
+
return None
|
| 142 |
+
|
| 143 |
+
@property
|
| 144 |
+
def default(self):
|
| 145 |
+
_assertValidDTDNode(self, self._c_node)
|
| 146 |
+
cdef int default = self._c_node.def_
|
| 147 |
+
if default == tree.XML_ATTRIBUTE_NONE:
|
| 148 |
+
return "none"
|
| 149 |
+
elif default == tree.XML_ATTRIBUTE_REQUIRED:
|
| 150 |
+
return "required"
|
| 151 |
+
elif default == tree.XML_ATTRIBUTE_IMPLIED:
|
| 152 |
+
return "implied"
|
| 153 |
+
elif default == tree.XML_ATTRIBUTE_FIXED:
|
| 154 |
+
return "fixed"
|
| 155 |
+
else:
|
| 156 |
+
return None
|
| 157 |
+
|
| 158 |
+
@property
|
| 159 |
+
def default_value(self):
|
| 160 |
+
_assertValidDTDNode(self, self._c_node)
|
| 161 |
+
return funicodeOrNone(self._c_node.defaultValue)
|
| 162 |
+
|
| 163 |
+
def itervalues(self):
|
| 164 |
+
_assertValidDTDNode(self, self._c_node)
|
| 165 |
+
cdef tree.xmlEnumeration *c_node = self._c_node.tree
|
| 166 |
+
while c_node is not NULL:
|
| 167 |
+
yield funicode(c_node.name)
|
| 168 |
+
c_node = c_node.next
|
| 169 |
+
|
| 170 |
+
def values(self):
|
| 171 |
+
return list(self.itervalues())
|
| 172 |
+
|
| 173 |
+
|
| 174 |
+
@cython.final
|
| 175 |
+
@cython.internal
|
| 176 |
+
@cython.freelist(8)
|
| 177 |
+
cdef class _DTDElementDecl:
|
| 178 |
+
cdef DTD _dtd
|
| 179 |
+
cdef tree.xmlElement* _c_node
|
| 180 |
+
|
| 181 |
+
def __repr__(self):
|
| 182 |
+
return "<%s.%s object name=%r prefix=%r type=%r at 0x%x>" % (self.__class__.__module__, self.__class__.__name__, self.name, self.prefix, self.type, id(self))
|
| 183 |
+
|
| 184 |
+
@property
|
| 185 |
+
def name(self):
|
| 186 |
+
_assertValidDTDNode(self, self._c_node)
|
| 187 |
+
return funicodeOrNone(self._c_node.name)
|
| 188 |
+
|
| 189 |
+
@property
|
| 190 |
+
def prefix(self):
|
| 191 |
+
_assertValidDTDNode(self, self._c_node)
|
| 192 |
+
return funicodeOrNone(self._c_node.prefix)
|
| 193 |
+
|
| 194 |
+
@property
|
| 195 |
+
def type(self):
|
| 196 |
+
_assertValidDTDNode(self, self._c_node)
|
| 197 |
+
cdef int type = self._c_node.etype
|
| 198 |
+
if type == tree.XML_ELEMENT_TYPE_UNDEFINED:
|
| 199 |
+
return "undefined"
|
| 200 |
+
elif type == tree.XML_ELEMENT_TYPE_EMPTY:
|
| 201 |
+
return "empty"
|
| 202 |
+
elif type == tree.XML_ELEMENT_TYPE_ANY:
|
| 203 |
+
return "any"
|
| 204 |
+
elif type == tree.XML_ELEMENT_TYPE_MIXED:
|
| 205 |
+
return "mixed"
|
| 206 |
+
elif type == tree.XML_ELEMENT_TYPE_ELEMENT:
|
| 207 |
+
return "element"
|
| 208 |
+
else:
|
| 209 |
+
return None
|
| 210 |
+
|
| 211 |
+
@property
|
| 212 |
+
def content(self):
|
| 213 |
+
_assertValidDTDNode(self, self._c_node)
|
| 214 |
+
cdef tree.xmlElementContent *content = self._c_node.content
|
| 215 |
+
if content:
|
| 216 |
+
node = <_DTDElementContentDecl>_DTDElementContentDecl.__new__(_DTDElementContentDecl)
|
| 217 |
+
node._dtd = self._dtd
|
| 218 |
+
node._c_node = content
|
| 219 |
+
return node
|
| 220 |
+
else:
|
| 221 |
+
return None
|
| 222 |
+
|
| 223 |
+
def iterattributes(self):
|
| 224 |
+
_assertValidDTDNode(self, self._c_node)
|
| 225 |
+
cdef tree.xmlAttribute *c_node = self._c_node.attributes
|
| 226 |
+
while c_node:
|
| 227 |
+
node = <_DTDAttributeDecl>_DTDAttributeDecl.__new__(_DTDAttributeDecl)
|
| 228 |
+
node._dtd = self._dtd
|
| 229 |
+
node._c_node = c_node
|
| 230 |
+
yield node
|
| 231 |
+
c_node = c_node.nexth
|
| 232 |
+
|
| 233 |
+
def attributes(self):
|
| 234 |
+
return list(self.iterattributes())
|
| 235 |
+
|
| 236 |
+
|
| 237 |
+
@cython.final
|
| 238 |
+
@cython.internal
|
| 239 |
+
@cython.freelist(8)
|
| 240 |
+
cdef class _DTDEntityDecl:
|
| 241 |
+
cdef DTD _dtd
|
| 242 |
+
cdef tree.xmlEntity* _c_node
|
| 243 |
+
def __repr__(self):
|
| 244 |
+
return "<%s.%s object name=%r at 0x%x>" % (self.__class__.__module__, self.__class__.__name__, self.name, id(self))
|
| 245 |
+
|
| 246 |
+
@property
|
| 247 |
+
def name(self):
|
| 248 |
+
_assertValidDTDNode(self, self._c_node)
|
| 249 |
+
return funicodeOrNone(self._c_node.name)
|
| 250 |
+
|
| 251 |
+
@property
|
| 252 |
+
def orig(self):
|
| 253 |
+
_assertValidDTDNode(self, self._c_node)
|
| 254 |
+
return funicodeOrNone(self._c_node.orig)
|
| 255 |
+
|
| 256 |
+
@property
|
| 257 |
+
def content(self):
|
| 258 |
+
_assertValidDTDNode(self, self._c_node)
|
| 259 |
+
return funicodeOrNone(self._c_node.content)
|
| 260 |
+
|
| 261 |
+
@property
|
| 262 |
+
def system_url(self):
|
| 263 |
+
_assertValidDTDNode(self, self._c_node)
|
| 264 |
+
return funicodeOrNone(self._c_node.SystemID)
|
| 265 |
+
|
| 266 |
+
|
| 267 |
+
################################################################################
|
| 268 |
+
# DTD
|
| 269 |
+
|
| 270 |
+
cdef class DTD(_Validator):
|
| 271 |
+
"""DTD(self, file=None, external_id=None)
|
| 272 |
+
A DTD validator.
|
| 273 |
+
|
| 274 |
+
Can load from filesystem directly given a filename or file-like object.
|
| 275 |
+
Alternatively, pass the keyword parameter ``external_id`` to load from a
|
| 276 |
+
catalog.
|
| 277 |
+
"""
|
| 278 |
+
cdef tree.xmlDtd* _c_dtd
|
| 279 |
+
def __init__(self, file=None, *, external_id=None):
|
| 280 |
+
_Validator.__init__(self)
|
| 281 |
+
if file is not None:
|
| 282 |
+
file = _getFSPathOrObject(file)
|
| 283 |
+
if _isString(file):
|
| 284 |
+
file = _encodeFilename(file)
|
| 285 |
+
with self._error_log:
|
| 286 |
+
orig_loader = _register_document_loader()
|
| 287 |
+
self._c_dtd = xmlparser.xmlParseDTD(NULL, _xcstr(file))
|
| 288 |
+
_reset_document_loader(orig_loader)
|
| 289 |
+
elif hasattr(file, 'read'):
|
| 290 |
+
orig_loader = _register_document_loader()
|
| 291 |
+
self._c_dtd = _parseDtdFromFilelike(file)
|
| 292 |
+
_reset_document_loader(orig_loader)
|
| 293 |
+
else:
|
| 294 |
+
raise DTDParseError, "file must be a filename, file-like or path-like object"
|
| 295 |
+
elif external_id is not None:
|
| 296 |
+
with self._error_log:
|
| 297 |
+
orig_loader = _register_document_loader()
|
| 298 |
+
self._c_dtd = xmlparser.xmlParseDTD(<const_xmlChar*>external_id, NULL)
|
| 299 |
+
_reset_document_loader(orig_loader)
|
| 300 |
+
else:
|
| 301 |
+
raise DTDParseError, "either filename or external ID required"
|
| 302 |
+
|
| 303 |
+
if self._c_dtd is NULL:
|
| 304 |
+
raise DTDParseError(
|
| 305 |
+
self._error_log._buildExceptionMessage("error parsing DTD"),
|
| 306 |
+
self._error_log)
|
| 307 |
+
|
| 308 |
+
@property
|
| 309 |
+
def name(self):
|
| 310 |
+
if self._c_dtd is NULL:
|
| 311 |
+
return None
|
| 312 |
+
return funicodeOrNone(self._c_dtd.name)
|
| 313 |
+
|
| 314 |
+
@property
|
| 315 |
+
def external_id(self):
|
| 316 |
+
if self._c_dtd is NULL:
|
| 317 |
+
return None
|
| 318 |
+
return funicodeOrNone(self._c_dtd.ExternalID)
|
| 319 |
+
|
| 320 |
+
@property
|
| 321 |
+
def system_url(self):
|
| 322 |
+
if self._c_dtd is NULL:
|
| 323 |
+
return None
|
| 324 |
+
return funicodeOrNone(self._c_dtd.SystemID)
|
| 325 |
+
|
| 326 |
+
def iterelements(self):
|
| 327 |
+
cdef tree.xmlNode *c_node = self._c_dtd.children if self._c_dtd is not NULL else NULL
|
| 328 |
+
while c_node is not NULL:
|
| 329 |
+
if c_node.type == tree.XML_ELEMENT_DECL:
|
| 330 |
+
node = _DTDElementDecl()
|
| 331 |
+
node._dtd = self
|
| 332 |
+
node._c_node = <tree.xmlElement*>c_node
|
| 333 |
+
yield node
|
| 334 |
+
c_node = c_node.next
|
| 335 |
+
|
| 336 |
+
def elements(self):
|
| 337 |
+
return list(self.iterelements())
|
| 338 |
+
|
| 339 |
+
def iterentities(self):
|
| 340 |
+
cdef tree.xmlNode *c_node = self._c_dtd.children if self._c_dtd is not NULL else NULL
|
| 341 |
+
while c_node is not NULL:
|
| 342 |
+
if c_node.type == tree.XML_ENTITY_DECL:
|
| 343 |
+
node = _DTDEntityDecl()
|
| 344 |
+
node._dtd = self
|
| 345 |
+
node._c_node = <tree.xmlEntity*>c_node
|
| 346 |
+
yield node
|
| 347 |
+
c_node = c_node.next
|
| 348 |
+
|
| 349 |
+
def entities(self):
|
| 350 |
+
return list(self.iterentities())
|
| 351 |
+
|
| 352 |
+
def __dealloc__(self):
|
| 353 |
+
tree.xmlFreeDtd(self._c_dtd)
|
| 354 |
+
|
| 355 |
+
def __call__(self, etree):
|
| 356 |
+
"""__call__(self, etree)
|
| 357 |
+
|
| 358 |
+
Validate doc using the DTD.
|
| 359 |
+
|
| 360 |
+
Returns true if the document is valid, false if not.
|
| 361 |
+
"""
|
| 362 |
+
cdef _Document doc
|
| 363 |
+
cdef _Element root_node
|
| 364 |
+
cdef xmlDoc* c_doc
|
| 365 |
+
cdef dtdvalid.xmlValidCtxt* valid_ctxt
|
| 366 |
+
cdef int ret = -1
|
| 367 |
+
|
| 368 |
+
assert self._c_dtd is not NULL, "DTD not initialised"
|
| 369 |
+
doc = _documentOrRaise(etree)
|
| 370 |
+
root_node = _rootNodeOrRaise(etree)
|
| 371 |
+
|
| 372 |
+
valid_ctxt = dtdvalid.xmlNewValidCtxt()
|
| 373 |
+
if valid_ctxt is NULL:
|
| 374 |
+
raise DTDError("Failed to create validation context")
|
| 375 |
+
|
| 376 |
+
# work around error reporting bug in libxml2 <= 2.9.1 (and later?)
|
| 377 |
+
# https://bugzilla.gnome.org/show_bug.cgi?id=724903
|
| 378 |
+
valid_ctxt.error = <dtdvalid.xmlValidityErrorFunc>_nullGenericErrorFunc
|
| 379 |
+
valid_ctxt.userData = NULL
|
| 380 |
+
|
| 381 |
+
try:
|
| 382 |
+
with self._error_log:
|
| 383 |
+
c_doc = _fakeRootDoc(doc._c_doc, root_node._c_node)
|
| 384 |
+
ret = dtdvalid.xmlValidateDtd(valid_ctxt, c_doc, self._c_dtd)
|
| 385 |
+
_destroyFakeDoc(doc._c_doc, c_doc)
|
| 386 |
+
finally:
|
| 387 |
+
dtdvalid.xmlFreeValidCtxt(valid_ctxt)
|
| 388 |
+
|
| 389 |
+
if ret == -1:
|
| 390 |
+
raise DTDValidateError("Internal error in DTD validation",
|
| 391 |
+
self._error_log)
|
| 392 |
+
return ret == 1
|
| 393 |
+
|
| 394 |
+
|
| 395 |
+
cdef tree.xmlDtd* _parseDtdFromFilelike(file) except NULL:
|
| 396 |
+
cdef _ExceptionContext exc_context
|
| 397 |
+
cdef _FileReaderContext dtd_parser
|
| 398 |
+
cdef _ErrorLog error_log
|
| 399 |
+
cdef tree.xmlDtd* c_dtd = NULL
|
| 400 |
+
exc_context = _ExceptionContext()
|
| 401 |
+
dtd_parser = _FileReaderContext(file, exc_context, None)
|
| 402 |
+
error_log = _ErrorLog()
|
| 403 |
+
|
| 404 |
+
with error_log:
|
| 405 |
+
c_dtd = dtd_parser._readDtd()
|
| 406 |
+
|
| 407 |
+
exc_context._raise_if_stored()
|
| 408 |
+
if c_dtd is NULL:
|
| 409 |
+
raise DTDParseError("error parsing DTD", error_log)
|
| 410 |
+
return c_dtd
|
| 411 |
+
|
| 412 |
+
cdef DTD _dtdFactory(tree.xmlDtd* c_dtd):
|
| 413 |
+
# do not run through DTD.__init__()!
|
| 414 |
+
cdef DTD dtd
|
| 415 |
+
if c_dtd is NULL:
|
| 416 |
+
return None
|
| 417 |
+
dtd = DTD.__new__(DTD)
|
| 418 |
+
dtd._c_dtd = _copyDtd(c_dtd)
|
| 419 |
+
_Validator.__init__(dtd)
|
| 420 |
+
return dtd
|
| 421 |
+
|
| 422 |
+
|
| 423 |
+
cdef tree.xmlDtd* _copyDtd(tree.xmlDtd* c_orig_dtd) except NULL:
|
| 424 |
+
"""
|
| 425 |
+
Copy a DTD. libxml2 (currently) fails to set up the element->attributes
|
| 426 |
+
links when copying DTDs, so we have to rebuild them here.
|
| 427 |
+
"""
|
| 428 |
+
c_dtd = tree.xmlCopyDtd(c_orig_dtd)
|
| 429 |
+
if not c_dtd:
|
| 430 |
+
raise MemoryError
|
| 431 |
+
cdef tree.xmlNode* c_node = c_dtd.children
|
| 432 |
+
while c_node:
|
| 433 |
+
if c_node.type == tree.XML_ATTRIBUTE_DECL:
|
| 434 |
+
_linkDtdAttribute(c_dtd, <tree.xmlAttribute*>c_node)
|
| 435 |
+
c_node = c_node.next
|
| 436 |
+
return c_dtd
|
| 437 |
+
|
| 438 |
+
|
| 439 |
+
cdef void _linkDtdAttribute(tree.xmlDtd* c_dtd, tree.xmlAttribute* c_attr) noexcept:
|
| 440 |
+
"""
|
| 441 |
+
Create the link to the DTD attribute declaration from the corresponding
|
| 442 |
+
element declaration.
|
| 443 |
+
"""
|
| 444 |
+
c_elem = dtdvalid.xmlGetDtdElementDesc(c_dtd, c_attr.elem)
|
| 445 |
+
if not c_elem:
|
| 446 |
+
# no such element? something is wrong with the DTD ...
|
| 447 |
+
return
|
| 448 |
+
c_pos = c_elem.attributes
|
| 449 |
+
if not c_pos:
|
| 450 |
+
c_elem.attributes = c_attr
|
| 451 |
+
c_attr.nexth = NULL
|
| 452 |
+
return
|
| 453 |
+
# libxml2 keeps namespace declarations first, and we need to make
|
| 454 |
+
# sure we don't re-insert attributes that are already there
|
| 455 |
+
if _isDtdNsDecl(c_attr):
|
| 456 |
+
if not _isDtdNsDecl(c_pos):
|
| 457 |
+
c_elem.attributes = c_attr
|
| 458 |
+
c_attr.nexth = c_pos
|
| 459 |
+
return
|
| 460 |
+
while c_pos != c_attr and c_pos.nexth and _isDtdNsDecl(c_pos.nexth):
|
| 461 |
+
c_pos = c_pos.nexth
|
| 462 |
+
else:
|
| 463 |
+
# append at end
|
| 464 |
+
while c_pos != c_attr and c_pos.nexth:
|
| 465 |
+
c_pos = c_pos.nexth
|
| 466 |
+
if c_pos == c_attr:
|
| 467 |
+
return
|
| 468 |
+
c_attr.nexth = c_pos.nexth
|
| 469 |
+
c_pos.nexth = c_attr
|
| 470 |
+
|
| 471 |
+
|
| 472 |
+
cdef bint _isDtdNsDecl(tree.xmlAttribute* c_attr) noexcept:
|
| 473 |
+
if cstring_h.strcmp(<const_char*>c_attr.name, "xmlns") == 0:
|
| 474 |
+
return True
|
| 475 |
+
if (c_attr.prefix is not NULL and
|
| 476 |
+
cstring_h.strcmp(<const_char*>c_attr.prefix, "xmlns") == 0):
|
| 477 |
+
return True
|
| 478 |
+
return False
|
omnilmm/lib/python3.10/site-packages/lxml/etree.cpython-310-x86_64-linux-gnu.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0952a7f38625f1a836074c56f80fe902e1b10224fb8472c89c7c91eb6ae83989
|
| 3 |
+
size 5349832
|
omnilmm/lib/python3.10/site-packages/lxml/etree.h
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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ndef __PYX_HAVE__lxml__etree
|
| 4 |
+
#define __PYX_HAVE__lxml__etree
|
| 5 |
+
|
| 6 |
+
#include "Python.h"
|
| 7 |
+
struct LxmlDocument;
|
| 8 |
+
struct LxmlElement;
|
| 9 |
+
struct LxmlElementTree;
|
| 10 |
+
struct LxmlElementTagMatcher;
|
| 11 |
+
struct LxmlElementIterator;
|
| 12 |
+
struct LxmlElementBase;
|
| 13 |
+
struct LxmlElementClassLookup;
|
| 14 |
+
struct LxmlFallbackElementClassLookup;
|
| 15 |
+
|
| 16 |
+
/* "lxml/etree.pyx":355
|
| 17 |
+
*
|
| 18 |
+
* # type of a function that steps from node to node
|
| 19 |
+
* ctypedef public xmlNode* (*_node_to_node_function)(xmlNode*) # <<<<<<<<<<<<<<
|
| 20 |
+
*
|
| 21 |
+
*
|
| 22 |
+
*/
|
| 23 |
+
typedef xmlNode *(*_node_to_node_function)(xmlNode *);
|
| 24 |
+
|
| 25 |
+
/* "lxml/etree.pyx":371
|
| 26 |
+
* @cython.final
|
| 27 |
+
* @cython.freelist(8)
|
| 28 |
+
* cdef public class _Document [ type LxmlDocumentType, object LxmlDocument ]: # <<<<<<<<<<<<<<
|
| 29 |
+
* """Internal base class to reference a libxml document.
|
| 30 |
+
*
|
| 31 |
+
*/
|
| 32 |
+
struct LxmlDocument {
|
| 33 |
+
PyObject_HEAD
|
| 34 |
+
struct __pyx_vtabstruct_4lxml_5etree__Document *__pyx_vtab;
|
| 35 |
+
int _ns_counter;
|
| 36 |
+
PyObject *_prefix_tail;
|
| 37 |
+
xmlDoc *_c_doc;
|
| 38 |
+
struct __pyx_obj_4lxml_5etree__BaseParser *_parser;
|
| 39 |
+
};
|
| 40 |
+
|
| 41 |
+
/* "lxml/etree.pyx":720
|
| 42 |
+
*
|
| 43 |
+
* @cython.no_gc_clear
|
| 44 |
+
* cdef public class _Element [ type LxmlElementType, object LxmlElement ]: # <<<<<<<<<<<<<<
|
| 45 |
+
* """Element class.
|
| 46 |
+
*
|
| 47 |
+
*/
|
| 48 |
+
struct LxmlElement {
|
| 49 |
+
PyObject_HEAD
|
| 50 |
+
struct LxmlDocument *_doc;
|
| 51 |
+
xmlNode *_c_node;
|
| 52 |
+
PyObject *_tag;
|
| 53 |
+
};
|
| 54 |
+
|
| 55 |
+
/* "lxml/etree.pyx":1894
|
| 56 |
+
*
|
| 57 |
+
*
|
| 58 |
+
* cdef public class _ElementTree [ type LxmlElementTreeType, # <<<<<<<<<<<<<<
|
| 59 |
+
* object LxmlElementTree ]:
|
| 60 |
+
* cdef _Document _doc
|
| 61 |
+
*/
|
| 62 |
+
struct LxmlElementTree {
|
| 63 |
+
PyObject_HEAD
|
| 64 |
+
struct __pyx_vtabstruct_4lxml_5etree__ElementTree *__pyx_vtab;
|
| 65 |
+
struct LxmlDocument *_doc;
|
| 66 |
+
struct LxmlElement *_context_node;
|
| 67 |
+
};
|
| 68 |
+
|
| 69 |
+
/* "lxml/etree.pyx":2668
|
| 70 |
+
*
|
| 71 |
+
*
|
| 72 |
+
* cdef public class _ElementTagMatcher [ object LxmlElementTagMatcher, # <<<<<<<<<<<<<<
|
| 73 |
+
* type LxmlElementTagMatcherType ]:
|
| 74 |
+
* """
|
| 75 |
+
*/
|
| 76 |
+
struct LxmlElementTagMatcher {
|
| 77 |
+
PyObject_HEAD
|
| 78 |
+
struct __pyx_vtabstruct_4lxml_5etree__ElementTagMatcher *__pyx_vtab;
|
| 79 |
+
PyObject *_pystrings;
|
| 80 |
+
int _node_type;
|
| 81 |
+
char *_href;
|
| 82 |
+
char *_name;
|
| 83 |
+
};
|
| 84 |
+
|
| 85 |
+
/* "lxml/etree.pyx":2699
|
| 86 |
+
* self._name = NULL
|
| 87 |
+
*
|
| 88 |
+
* cdef public class _ElementIterator(_ElementTagMatcher) [ # <<<<<<<<<<<<<<
|
| 89 |
+
* object LxmlElementIterator, type LxmlElementIteratorType ]:
|
| 90 |
+
* """
|
| 91 |
+
*/
|
| 92 |
+
struct LxmlElementIterator {
|
| 93 |
+
struct LxmlElementTagMatcher __pyx_base;
|
| 94 |
+
struct LxmlElement *_node;
|
| 95 |
+
_node_to_node_function _next_element;
|
| 96 |
+
};
|
| 97 |
+
|
| 98 |
+
/* "src/lxml/classlookup.pxi":6
|
| 99 |
+
* # Custom Element classes
|
| 100 |
+
*
|
| 101 |
+
* cdef public class ElementBase(_Element) [ type LxmlElementBaseType, # <<<<<<<<<<<<<<
|
| 102 |
+
* object LxmlElementBase ]:
|
| 103 |
+
* """ElementBase(*children, attrib=None, nsmap=None, **_extra)
|
| 104 |
+
*/
|
| 105 |
+
struct LxmlElementBase {
|
| 106 |
+
struct LxmlElement __pyx_base;
|
| 107 |
+
};
|
| 108 |
+
|
| 109 |
+
/* "src/lxml/classlookup.pxi":210
|
| 110 |
+
* # Element class lookup
|
| 111 |
+
*
|
| 112 |
+
* ctypedef public object (*_element_class_lookup_function)(object, _Document, xmlNode*) # <<<<<<<<<<<<<<
|
| 113 |
+
*
|
| 114 |
+
* # class to store element class lookup functions
|
| 115 |
+
*/
|
| 116 |
+
typedef PyObject *(*_element_class_lookup_function)(PyObject *, struct LxmlDocument *, xmlNode *);
|
| 117 |
+
|
| 118 |
+
/* "src/lxml/classlookup.pxi":213
|
| 119 |
+
*
|
| 120 |
+
* # class to store element class lookup functions
|
| 121 |
+
* cdef public class ElementClassLookup [ type LxmlElementClassLookupType, # <<<<<<<<<<<<<<
|
| 122 |
+
* object LxmlElementClassLookup ]:
|
| 123 |
+
* """ElementClassLookup(self)
|
| 124 |
+
*/
|
| 125 |
+
struct LxmlElementClassLookup {
|
| 126 |
+
PyObject_HEAD
|
| 127 |
+
_element_class_lookup_function _lookup_function;
|
| 128 |
+
};
|
| 129 |
+
|
| 130 |
+
/* "src/lxml/classlookup.pxi":221
|
| 131 |
+
*
|
| 132 |
+
*
|
| 133 |
+
* cdef public class FallbackElementClassLookup(ElementClassLookup) \ # <<<<<<<<<<<<<<
|
| 134 |
+
* [ type LxmlFallbackElementClassLookupType,
|
| 135 |
+
* object LxmlFallbackElementClassLookup ]:
|
| 136 |
+
*/
|
| 137 |
+
struct LxmlFallbackElementClassLookup {
|
| 138 |
+
struct LxmlElementClassLookup __pyx_base;
|
| 139 |
+
struct __pyx_vtabstruct_4lxml_5etree_FallbackElementClassLookup *__pyx_vtab;
|
| 140 |
+
struct LxmlElementClassLookup *fallback;
|
| 141 |
+
_element_class_lookup_function _fallback_function;
|
| 142 |
+
};
|
| 143 |
+
|
| 144 |
+
#ifndef __PYX_HAVE_API__lxml__etree
|
| 145 |
+
|
| 146 |
+
#ifdef CYTHON_EXTERN_C
|
| 147 |
+
#undef __PYX_EXTERN_C
|
| 148 |
+
#define __PYX_EXTERN_C CYTHON_EXTERN_C
|
| 149 |
+
#elif defined(__PYX_EXTERN_C)
|
| 150 |
+
#ifdef _MSC_VER
|
| 151 |
+
#pragma message ("Please do not define the '__PYX_EXTERN_C' macro externally. Use 'CYTHON_EXTERN_C' instead.")
|
| 152 |
+
#else
|
| 153 |
+
#warning Please do not define the '__PYX_EXTERN_C' macro externally. Use 'CYTHON_EXTERN_C' instead.
|
| 154 |
+
#endif
|
| 155 |
+
#else
|
| 156 |
+
#ifdef __cplusplus
|
| 157 |
+
#define __PYX_EXTERN_C extern "C"
|
| 158 |
+
#else
|
| 159 |
+
#define __PYX_EXTERN_C extern
|
| 160 |
+
#endif
|
| 161 |
+
#endif
|
| 162 |
+
|
| 163 |
+
#ifndef DL_IMPORT
|
| 164 |
+
#define DL_IMPORT(_T) _T
|
| 165 |
+
#endif
|
| 166 |
+
|
| 167 |
+
__PYX_EXTERN_C DL_IMPORT(PyTypeObject) LxmlDocumentType;
|
| 168 |
+
__PYX_EXTERN_C DL_IMPORT(PyTypeObject) LxmlElementType;
|
| 169 |
+
__PYX_EXTERN_C DL_IMPORT(PyTypeObject) LxmlElementTreeType;
|
| 170 |
+
__PYX_EXTERN_C DL_IMPORT(PyTypeObject) LxmlElementTagMatcherType;
|
| 171 |
+
__PYX_EXTERN_C DL_IMPORT(PyTypeObject) LxmlElementIteratorType;
|
| 172 |
+
__PYX_EXTERN_C DL_IMPORT(PyTypeObject) LxmlElementBaseType;
|
| 173 |
+
__PYX_EXTERN_C DL_IMPORT(PyTypeObject) LxmlElementClassLookupType;
|
| 174 |
+
__PYX_EXTERN_C DL_IMPORT(PyTypeObject) LxmlFallbackElementClassLookupType;
|
| 175 |
+
|
| 176 |
+
__PYX_EXTERN_C struct LxmlElement *deepcopyNodeToDocument(struct LxmlDocument *, xmlNode *);
|
| 177 |
+
__PYX_EXTERN_C struct LxmlElementTree *elementTreeFactory(struct LxmlElement *);
|
| 178 |
+
__PYX_EXTERN_C struct LxmlElementTree *newElementTree(struct LxmlElement *, PyObject *);
|
| 179 |
+
__PYX_EXTERN_C struct LxmlElementTree *adoptExternalDocument(xmlDoc *, PyObject *, int);
|
| 180 |
+
__PYX_EXTERN_C struct LxmlElement *elementFactory(struct LxmlDocument *, xmlNode *);
|
| 181 |
+
__PYX_EXTERN_C struct LxmlElement *makeElement(PyObject *, struct LxmlDocument *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *);
|
| 182 |
+
__PYX_EXTERN_C struct LxmlElement *makeSubElement(struct LxmlElement *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *);
|
| 183 |
+
__PYX_EXTERN_C void setElementClassLookupFunction(_element_class_lookup_function, PyObject *);
|
| 184 |
+
__PYX_EXTERN_C PyObject *lookupDefaultElementClass(PyObject *, PyObject *, xmlNode *);
|
| 185 |
+
__PYX_EXTERN_C PyObject *lookupNamespaceElementClass(PyObject *, PyObject *, xmlNode *);
|
| 186 |
+
__PYX_EXTERN_C PyObject *callLookupFallback(struct LxmlFallbackElementClassLookup *, struct LxmlDocument *, xmlNode *);
|
| 187 |
+
__PYX_EXTERN_C int tagMatches(xmlNode *, const xmlChar *, const xmlChar *);
|
| 188 |
+
__PYX_EXTERN_C struct LxmlDocument *documentOrRaise(PyObject *);
|
| 189 |
+
__PYX_EXTERN_C struct LxmlElement *rootNodeOrRaise(PyObject *);
|
| 190 |
+
__PYX_EXTERN_C int hasText(xmlNode *);
|
| 191 |
+
__PYX_EXTERN_C int hasTail(xmlNode *);
|
| 192 |
+
__PYX_EXTERN_C PyObject *textOf(xmlNode *);
|
| 193 |
+
__PYX_EXTERN_C PyObject *tailOf(xmlNode *);
|
| 194 |
+
__PYX_EXTERN_C int setNodeText(xmlNode *, PyObject *);
|
| 195 |
+
__PYX_EXTERN_C int setTailText(xmlNode *, PyObject *);
|
| 196 |
+
__PYX_EXTERN_C PyObject *attributeValue(xmlNode *, xmlAttr *);
|
| 197 |
+
__PYX_EXTERN_C PyObject *attributeValueFromNsName(xmlNode *, const xmlChar *, const xmlChar *);
|
| 198 |
+
__PYX_EXTERN_C PyObject *getAttributeValue(struct LxmlElement *, PyObject *, PyObject *);
|
| 199 |
+
__PYX_EXTERN_C PyObject *iterattributes(struct LxmlElement *, int);
|
| 200 |
+
__PYX_EXTERN_C PyObject *collectAttributes(xmlNode *, int);
|
| 201 |
+
__PYX_EXTERN_C int setAttributeValue(struct LxmlElement *, PyObject *, PyObject *);
|
| 202 |
+
__PYX_EXTERN_C int delAttribute(struct LxmlElement *, PyObject *);
|
| 203 |
+
__PYX_EXTERN_C int delAttributeFromNsName(xmlNode *, const xmlChar *, const xmlChar *);
|
| 204 |
+
__PYX_EXTERN_C int hasChild(xmlNode *);
|
| 205 |
+
__PYX_EXTERN_C xmlNode *findChild(xmlNode *, Py_ssize_t);
|
| 206 |
+
__PYX_EXTERN_C xmlNode *findChildForwards(xmlNode *, Py_ssize_t);
|
| 207 |
+
__PYX_EXTERN_C xmlNode *findChildBackwards(xmlNode *, Py_ssize_t);
|
| 208 |
+
__PYX_EXTERN_C xmlNode *nextElement(xmlNode *);
|
| 209 |
+
__PYX_EXTERN_C xmlNode *previousElement(xmlNode *);
|
| 210 |
+
__PYX_EXTERN_C void appendChild(struct LxmlElement *, struct LxmlElement *);
|
| 211 |
+
__PYX_EXTERN_C int appendChildToElement(struct LxmlElement *, struct LxmlElement *);
|
| 212 |
+
__PYX_EXTERN_C PyObject *pyunicode(const xmlChar *);
|
| 213 |
+
__PYX_EXTERN_C PyObject *utf8(PyObject *);
|
| 214 |
+
__PYX_EXTERN_C PyObject *getNsTag(PyObject *);
|
| 215 |
+
__PYX_EXTERN_C PyObject *getNsTagWithEmptyNs(PyObject *);
|
| 216 |
+
__PYX_EXTERN_C PyObject *namespacedName(xmlNode *);
|
| 217 |
+
__PYX_EXTERN_C PyObject *namespacedNameFromNsName(const xmlChar *, const xmlChar *);
|
| 218 |
+
__PYX_EXTERN_C void iteratorStoreNext(struct LxmlElementIterator *, struct LxmlElement *);
|
| 219 |
+
__PYX_EXTERN_C void initTagMatch(struct LxmlElementTagMatcher *, PyObject *);
|
| 220 |
+
__PYX_EXTERN_C xmlNs *findOrBuildNodeNsPrefix(struct LxmlDocument *, xmlNode *, const xmlChar *, const xmlChar *);
|
| 221 |
+
|
| 222 |
+
#endif /* !__PYX_HAVE_API__lxml__etree */
|
| 223 |
+
|
| 224 |
+
/* WARNING: the interface of the module init function changed in CPython 3.5. */
|
| 225 |
+
/* It now returns a PyModuleDef instance instead of a PyModule instance. */
|
| 226 |
+
|
| 227 |
+
#if PY_MAJOR_VERSION < 3
|
| 228 |
+
PyMODINIT_FUNC initetree(void);
|
| 229 |
+
#else
|
| 230 |
+
/* WARNING: Use PyImport_AppendInittab("etree", PyInit_etree) instead of calling PyInit_etree directly from Python 3.5 */
|
| 231 |
+
PyMODINIT_FUNC PyInit_etree(void);
|
| 232 |
+
|
| 233 |
+
#if PY_VERSION_HEX >= 0x03050000 && (defined(__GNUC__) || defined(__clang__) || defined(_MSC_VER) || (defined(__cplusplus) && __cplusplus >= 201402L))
|
| 234 |
+
#if defined(__cplusplus) && __cplusplus >= 201402L
|
| 235 |
+
[[deprecated("Use PyImport_AppendInittab(\"etree\", PyInit_etree) instead of calling PyInit_etree directly.")]] inline
|
| 236 |
+
#elif defined(__GNUC__) || defined(__clang__)
|
| 237 |
+
__attribute__ ((__deprecated__("Use PyImport_AppendInittab(\"etree\", PyInit_etree) instead of calling PyInit_etree directly."), __unused__)) __inline__
|
| 238 |
+
#elif defined(_MSC_VER)
|
| 239 |
+
__declspec(deprecated("Use PyImport_AppendInittab(\"etree\", PyInit_etree) instead of calling PyInit_etree directly.")) __inline
|
| 240 |
+
#endif
|
| 241 |
+
static PyObject* __PYX_WARN_IF_PyInit_etree_INIT_CALLED(PyObject* res) {
|
| 242 |
+
return res;
|
| 243 |
+
}
|
| 244 |
+
#define PyInit_etree() __PYX_WARN_IF_PyInit_etree_INIT_CALLED(PyInit_etree())
|
| 245 |
+
#endif
|
| 246 |
+
#endif
|
| 247 |
+
|
| 248 |
+
#endif /* !__PYX_HAVE__lxml__etree */
|
omnilmm/lib/python3.10/site-packages/lxml/etree.pyx
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
omnilmm/lib/python3.10/site-packages/lxml/etree_api.h
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* Generated by Cython 3.0.11 */
|
| 2 |
+
|
| 3 |
+
#ifndef __PYX_HAVE_API__lxml__etree
|
| 4 |
+
#define __PYX_HAVE_API__lxml__etree
|
| 5 |
+
#ifdef __MINGW64__
|
| 6 |
+
#define MS_WIN64
|
| 7 |
+
#endif
|
| 8 |
+
#include "Python.h"
|
| 9 |
+
#include "etree.h"
|
| 10 |
+
|
| 11 |
+
static struct LxmlElement *(*__pyx_api_f_4lxml_5etree_deepcopyNodeToDocument)(struct LxmlDocument *, xmlNode *) = 0;
|
| 12 |
+
#define deepcopyNodeToDocument __pyx_api_f_4lxml_5etree_deepcopyNodeToDocument
|
| 13 |
+
static struct LxmlElementTree *(*__pyx_api_f_4lxml_5etree_elementTreeFactory)(struct LxmlElement *) = 0;
|
| 14 |
+
#define elementTreeFactory __pyx_api_f_4lxml_5etree_elementTreeFactory
|
| 15 |
+
static struct LxmlElementTree *(*__pyx_api_f_4lxml_5etree_newElementTree)(struct LxmlElement *, PyObject *) = 0;
|
| 16 |
+
#define newElementTree __pyx_api_f_4lxml_5etree_newElementTree
|
| 17 |
+
static struct LxmlElementTree *(*__pyx_api_f_4lxml_5etree_adoptExternalDocument)(xmlDoc *, PyObject *, int) = 0;
|
| 18 |
+
#define adoptExternalDocument __pyx_api_f_4lxml_5etree_adoptExternalDocument
|
| 19 |
+
static struct LxmlElement *(*__pyx_api_f_4lxml_5etree_elementFactory)(struct LxmlDocument *, xmlNode *) = 0;
|
| 20 |
+
#define elementFactory __pyx_api_f_4lxml_5etree_elementFactory
|
| 21 |
+
static struct LxmlElement *(*__pyx_api_f_4lxml_5etree_makeElement)(PyObject *, struct LxmlDocument *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *) = 0;
|
| 22 |
+
#define makeElement __pyx_api_f_4lxml_5etree_makeElement
|
| 23 |
+
static struct LxmlElement *(*__pyx_api_f_4lxml_5etree_makeSubElement)(struct LxmlElement *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *) = 0;
|
| 24 |
+
#define makeSubElement __pyx_api_f_4lxml_5etree_makeSubElement
|
| 25 |
+
static void (*__pyx_api_f_4lxml_5etree_setElementClassLookupFunction)(_element_class_lookup_function, PyObject *) = 0;
|
| 26 |
+
#define setElementClassLookupFunction __pyx_api_f_4lxml_5etree_setElementClassLookupFunction
|
| 27 |
+
static PyObject *(*__pyx_api_f_4lxml_5etree_lookupDefaultElementClass)(PyObject *, PyObject *, xmlNode *) = 0;
|
| 28 |
+
#define lookupDefaultElementClass __pyx_api_f_4lxml_5etree_lookupDefaultElementClass
|
| 29 |
+
static PyObject *(*__pyx_api_f_4lxml_5etree_lookupNamespaceElementClass)(PyObject *, PyObject *, xmlNode *) = 0;
|
| 30 |
+
#define lookupNamespaceElementClass __pyx_api_f_4lxml_5etree_lookupNamespaceElementClass
|
| 31 |
+
static PyObject *(*__pyx_api_f_4lxml_5etree_callLookupFallback)(struct LxmlFallbackElementClassLookup *, struct LxmlDocument *, xmlNode *) = 0;
|
| 32 |
+
#define callLookupFallback __pyx_api_f_4lxml_5etree_callLookupFallback
|
| 33 |
+
static int (*__pyx_api_f_4lxml_5etree_tagMatches)(xmlNode *, const xmlChar *, const xmlChar *) = 0;
|
| 34 |
+
#define tagMatches __pyx_api_f_4lxml_5etree_tagMatches
|
| 35 |
+
static struct LxmlDocument *(*__pyx_api_f_4lxml_5etree_documentOrRaise)(PyObject *) = 0;
|
| 36 |
+
#define documentOrRaise __pyx_api_f_4lxml_5etree_documentOrRaise
|
| 37 |
+
static struct LxmlElement *(*__pyx_api_f_4lxml_5etree_rootNodeOrRaise)(PyObject *) = 0;
|
| 38 |
+
#define rootNodeOrRaise __pyx_api_f_4lxml_5etree_rootNodeOrRaise
|
| 39 |
+
static int (*__pyx_api_f_4lxml_5etree_hasText)(xmlNode *) = 0;
|
| 40 |
+
#define hasText __pyx_api_f_4lxml_5etree_hasText
|
| 41 |
+
static int (*__pyx_api_f_4lxml_5etree_hasTail)(xmlNode *) = 0;
|
| 42 |
+
#define hasTail __pyx_api_f_4lxml_5etree_hasTail
|
| 43 |
+
static PyObject *(*__pyx_api_f_4lxml_5etree_textOf)(xmlNode *) = 0;
|
| 44 |
+
#define textOf __pyx_api_f_4lxml_5etree_textOf
|
| 45 |
+
static PyObject *(*__pyx_api_f_4lxml_5etree_tailOf)(xmlNode *) = 0;
|
| 46 |
+
#define tailOf __pyx_api_f_4lxml_5etree_tailOf
|
| 47 |
+
static int (*__pyx_api_f_4lxml_5etree_setNodeText)(xmlNode *, PyObject *) = 0;
|
| 48 |
+
#define setNodeText __pyx_api_f_4lxml_5etree_setNodeText
|
| 49 |
+
static int (*__pyx_api_f_4lxml_5etree_setTailText)(xmlNode *, PyObject *) = 0;
|
| 50 |
+
#define setTailText __pyx_api_f_4lxml_5etree_setTailText
|
| 51 |
+
static PyObject *(*__pyx_api_f_4lxml_5etree_attributeValue)(xmlNode *, xmlAttr *) = 0;
|
| 52 |
+
#define attributeValue __pyx_api_f_4lxml_5etree_attributeValue
|
| 53 |
+
static PyObject *(*__pyx_api_f_4lxml_5etree_attributeValueFromNsName)(xmlNode *, const xmlChar *, const xmlChar *) = 0;
|
| 54 |
+
#define attributeValueFromNsName __pyx_api_f_4lxml_5etree_attributeValueFromNsName
|
| 55 |
+
static PyObject *(*__pyx_api_f_4lxml_5etree_getAttributeValue)(struct LxmlElement *, PyObject *, PyObject *) = 0;
|
| 56 |
+
#define getAttributeValue __pyx_api_f_4lxml_5etree_getAttributeValue
|
| 57 |
+
static PyObject *(*__pyx_api_f_4lxml_5etree_iterattributes)(struct LxmlElement *, int) = 0;
|
| 58 |
+
#define iterattributes __pyx_api_f_4lxml_5etree_iterattributes
|
| 59 |
+
static PyObject *(*__pyx_api_f_4lxml_5etree_collectAttributes)(xmlNode *, int) = 0;
|
| 60 |
+
#define collectAttributes __pyx_api_f_4lxml_5etree_collectAttributes
|
| 61 |
+
static int (*__pyx_api_f_4lxml_5etree_setAttributeValue)(struct LxmlElement *, PyObject *, PyObject *) = 0;
|
| 62 |
+
#define setAttributeValue __pyx_api_f_4lxml_5etree_setAttributeValue
|
| 63 |
+
static int (*__pyx_api_f_4lxml_5etree_delAttribute)(struct LxmlElement *, PyObject *) = 0;
|
| 64 |
+
#define delAttribute __pyx_api_f_4lxml_5etree_delAttribute
|
| 65 |
+
static int (*__pyx_api_f_4lxml_5etree_delAttributeFromNsName)(xmlNode *, const xmlChar *, const xmlChar *) = 0;
|
| 66 |
+
#define delAttributeFromNsName __pyx_api_f_4lxml_5etree_delAttributeFromNsName
|
| 67 |
+
static int (*__pyx_api_f_4lxml_5etree_hasChild)(xmlNode *) = 0;
|
| 68 |
+
#define hasChild __pyx_api_f_4lxml_5etree_hasChild
|
| 69 |
+
static xmlNode *(*__pyx_api_f_4lxml_5etree_findChild)(xmlNode *, Py_ssize_t) = 0;
|
| 70 |
+
#define findChild __pyx_api_f_4lxml_5etree_findChild
|
| 71 |
+
static xmlNode *(*__pyx_api_f_4lxml_5etree_findChildForwards)(xmlNode *, Py_ssize_t) = 0;
|
| 72 |
+
#define findChildForwards __pyx_api_f_4lxml_5etree_findChildForwards
|
| 73 |
+
static xmlNode *(*__pyx_api_f_4lxml_5etree_findChildBackwards)(xmlNode *, Py_ssize_t) = 0;
|
| 74 |
+
#define findChildBackwards __pyx_api_f_4lxml_5etree_findChildBackwards
|
| 75 |
+
static xmlNode *(*__pyx_api_f_4lxml_5etree_nextElement)(xmlNode *) = 0;
|
| 76 |
+
#define nextElement __pyx_api_f_4lxml_5etree_nextElement
|
| 77 |
+
static xmlNode *(*__pyx_api_f_4lxml_5etree_previousElement)(xmlNode *) = 0;
|
| 78 |
+
#define previousElement __pyx_api_f_4lxml_5etree_previousElement
|
| 79 |
+
static void (*__pyx_api_f_4lxml_5etree_appendChild)(struct LxmlElement *, struct LxmlElement *) = 0;
|
| 80 |
+
#define appendChild __pyx_api_f_4lxml_5etree_appendChild
|
| 81 |
+
static int (*__pyx_api_f_4lxml_5etree_appendChildToElement)(struct LxmlElement *, struct LxmlElement *) = 0;
|
| 82 |
+
#define appendChildToElement __pyx_api_f_4lxml_5etree_appendChildToElement
|
| 83 |
+
static PyObject *(*__pyx_api_f_4lxml_5etree_pyunicode)(const xmlChar *) = 0;
|
| 84 |
+
#define pyunicode __pyx_api_f_4lxml_5etree_pyunicode
|
| 85 |
+
static PyObject *(*__pyx_api_f_4lxml_5etree_utf8)(PyObject *) = 0;
|
| 86 |
+
#define utf8 __pyx_api_f_4lxml_5etree_utf8
|
| 87 |
+
static PyObject *(*__pyx_api_f_4lxml_5etree_getNsTag)(PyObject *) = 0;
|
| 88 |
+
#define getNsTag __pyx_api_f_4lxml_5etree_getNsTag
|
| 89 |
+
static PyObject *(*__pyx_api_f_4lxml_5etree_getNsTagWithEmptyNs)(PyObject *) = 0;
|
| 90 |
+
#define getNsTagWithEmptyNs __pyx_api_f_4lxml_5etree_getNsTagWithEmptyNs
|
| 91 |
+
static PyObject *(*__pyx_api_f_4lxml_5etree_namespacedName)(xmlNode *) = 0;
|
| 92 |
+
#define namespacedName __pyx_api_f_4lxml_5etree_namespacedName
|
| 93 |
+
static PyObject *(*__pyx_api_f_4lxml_5etree_namespacedNameFromNsName)(const xmlChar *, const xmlChar *) = 0;
|
| 94 |
+
#define namespacedNameFromNsName __pyx_api_f_4lxml_5etree_namespacedNameFromNsName
|
| 95 |
+
static void (*__pyx_api_f_4lxml_5etree_iteratorStoreNext)(struct LxmlElementIterator *, struct LxmlElement *) = 0;
|
| 96 |
+
#define iteratorStoreNext __pyx_api_f_4lxml_5etree_iteratorStoreNext
|
| 97 |
+
static void (*__pyx_api_f_4lxml_5etree_initTagMatch)(struct LxmlElementTagMatcher *, PyObject *) = 0;
|
| 98 |
+
#define initTagMatch __pyx_api_f_4lxml_5etree_initTagMatch
|
| 99 |
+
static xmlNs *(*__pyx_api_f_4lxml_5etree_findOrBuildNodeNsPrefix)(struct LxmlDocument *, xmlNode *, const xmlChar *, const xmlChar *) = 0;
|
| 100 |
+
#define findOrBuildNodeNsPrefix __pyx_api_f_4lxml_5etree_findOrBuildNodeNsPrefix
|
| 101 |
+
#ifndef __PYX_HAVE_RT_ImportFunction_3_0_11
|
| 102 |
+
#define __PYX_HAVE_RT_ImportFunction_3_0_11
|
| 103 |
+
static int __Pyx_ImportFunction_3_0_11(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
|
| 104 |
+
PyObject *d = 0;
|
| 105 |
+
PyObject *cobj = 0;
|
| 106 |
+
union {
|
| 107 |
+
void (*fp)(void);
|
| 108 |
+
void *p;
|
| 109 |
+
} tmp;
|
| 110 |
+
d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
|
| 111 |
+
if (!d)
|
| 112 |
+
goto bad;
|
| 113 |
+
cobj = PyDict_GetItemString(d, funcname);
|
| 114 |
+
if (!cobj) {
|
| 115 |
+
PyErr_Format(PyExc_ImportError,
|
| 116 |
+
"%.200s does not export expected C function %.200s",
|
| 117 |
+
PyModule_GetName(module), funcname);
|
| 118 |
+
goto bad;
|
| 119 |
+
}
|
| 120 |
+
if (!PyCapsule_IsValid(cobj, sig)) {
|
| 121 |
+
PyErr_Format(PyExc_TypeError,
|
| 122 |
+
"C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)",
|
| 123 |
+
PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
|
| 124 |
+
goto bad;
|
| 125 |
+
}
|
| 126 |
+
tmp.p = PyCapsule_GetPointer(cobj, sig);
|
| 127 |
+
*f = tmp.fp;
|
| 128 |
+
if (!(*f))
|
| 129 |
+
goto bad;
|
| 130 |
+
Py_DECREF(d);
|
| 131 |
+
return 0;
|
| 132 |
+
bad:
|
| 133 |
+
Py_XDECREF(d);
|
| 134 |
+
return -1;
|
| 135 |
+
}
|
| 136 |
+
#endif
|
| 137 |
+
|
| 138 |
+
|
| 139 |
+
static int import_lxml__etree(void) {
|
| 140 |
+
PyObject *module = 0;
|
| 141 |
+
module = PyImport_ImportModule("lxml.etree");
|
| 142 |
+
if (!module) goto bad;
|
| 143 |
+
if (__Pyx_ImportFunction_3_0_11(module, "deepcopyNodeToDocument", (void (**)(void))&__pyx_api_f_4lxml_5etree_deepcopyNodeToDocument, "struct LxmlElement *(struct LxmlDocument *, xmlNode *)") < 0) goto bad;
|
| 144 |
+
if (__Pyx_ImportFunction_3_0_11(module, "elementTreeFactory", (void (**)(void))&__pyx_api_f_4lxml_5etree_elementTreeFactory, "struct LxmlElementTree *(struct LxmlElement *)") < 0) goto bad;
|
| 145 |
+
if (__Pyx_ImportFunction_3_0_11(module, "newElementTree", (void (**)(void))&__pyx_api_f_4lxml_5etree_newElementTree, "struct LxmlElementTree *(struct LxmlElement *, PyObject *)") < 0) goto bad;
|
| 146 |
+
if (__Pyx_ImportFunction_3_0_11(module, "adoptExternalDocument", (void (**)(void))&__pyx_api_f_4lxml_5etree_adoptExternalDocument, "struct LxmlElementTree *(xmlDoc *, PyObject *, int)") < 0) goto bad;
|
| 147 |
+
if (__Pyx_ImportFunction_3_0_11(module, "elementFactory", (void (**)(void))&__pyx_api_f_4lxml_5etree_elementFactory, "struct LxmlElement *(struct LxmlDocument *, xmlNode *)") < 0) goto bad;
|
| 148 |
+
if (__Pyx_ImportFunction_3_0_11(module, "makeElement", (void (**)(void))&__pyx_api_f_4lxml_5etree_makeElement, "struct LxmlElement *(PyObject *, struct LxmlDocument *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *)") < 0) goto bad;
|
| 149 |
+
if (__Pyx_ImportFunction_3_0_11(module, "makeSubElement", (void (**)(void))&__pyx_api_f_4lxml_5etree_makeSubElement, "struct LxmlElement *(struct LxmlElement *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *)") < 0) goto bad;
|
| 150 |
+
if (__Pyx_ImportFunction_3_0_11(module, "setElementClassLookupFunction", (void (**)(void))&__pyx_api_f_4lxml_5etree_setElementClassLookupFunction, "void (_element_class_lookup_function, PyObject *)") < 0) goto bad;
|
| 151 |
+
if (__Pyx_ImportFunction_3_0_11(module, "lookupDefaultElementClass", (void (**)(void))&__pyx_api_f_4lxml_5etree_lookupDefaultElementClass, "PyObject *(PyObject *, PyObject *, xmlNode *)") < 0) goto bad;
|
| 152 |
+
if (__Pyx_ImportFunction_3_0_11(module, "lookupNamespaceElementClass", (void (**)(void))&__pyx_api_f_4lxml_5etree_lookupNamespaceElementClass, "PyObject *(PyObject *, PyObject *, xmlNode *)") < 0) goto bad;
|
| 153 |
+
if (__Pyx_ImportFunction_3_0_11(module, "callLookupFallback", (void (**)(void))&__pyx_api_f_4lxml_5etree_callLookupFallback, "PyObject *(struct LxmlFallbackElementClassLookup *, struct LxmlDocument *, xmlNode *)") < 0) goto bad;
|
| 154 |
+
if (__Pyx_ImportFunction_3_0_11(module, "tagMatches", (void (**)(void))&__pyx_api_f_4lxml_5etree_tagMatches, "int (xmlNode *, const xmlChar *, const xmlChar *)") < 0) goto bad;
|
| 155 |
+
if (__Pyx_ImportFunction_3_0_11(module, "documentOrRaise", (void (**)(void))&__pyx_api_f_4lxml_5etree_documentOrRaise, "struct LxmlDocument *(PyObject *)") < 0) goto bad;
|
| 156 |
+
if (__Pyx_ImportFunction_3_0_11(module, "rootNodeOrRaise", (void (**)(void))&__pyx_api_f_4lxml_5etree_rootNodeOrRaise, "struct LxmlElement *(PyObject *)") < 0) goto bad;
|
| 157 |
+
if (__Pyx_ImportFunction_3_0_11(module, "hasText", (void (**)(void))&__pyx_api_f_4lxml_5etree_hasText, "int (xmlNode *)") < 0) goto bad;
|
| 158 |
+
if (__Pyx_ImportFunction_3_0_11(module, "hasTail", (void (**)(void))&__pyx_api_f_4lxml_5etree_hasTail, "int (xmlNode *)") < 0) goto bad;
|
| 159 |
+
if (__Pyx_ImportFunction_3_0_11(module, "textOf", (void (**)(void))&__pyx_api_f_4lxml_5etree_textOf, "PyObject *(xmlNode *)") < 0) goto bad;
|
| 160 |
+
if (__Pyx_ImportFunction_3_0_11(module, "tailOf", (void (**)(void))&__pyx_api_f_4lxml_5etree_tailOf, "PyObject *(xmlNode *)") < 0) goto bad;
|
| 161 |
+
if (__Pyx_ImportFunction_3_0_11(module, "setNodeText", (void (**)(void))&__pyx_api_f_4lxml_5etree_setNodeText, "int (xmlNode *, PyObject *)") < 0) goto bad;
|
| 162 |
+
if (__Pyx_ImportFunction_3_0_11(module, "setTailText", (void (**)(void))&__pyx_api_f_4lxml_5etree_setTailText, "int (xmlNode *, PyObject *)") < 0) goto bad;
|
| 163 |
+
if (__Pyx_ImportFunction_3_0_11(module, "attributeValue", (void (**)(void))&__pyx_api_f_4lxml_5etree_attributeValue, "PyObject *(xmlNode *, xmlAttr *)") < 0) goto bad;
|
| 164 |
+
if (__Pyx_ImportFunction_3_0_11(module, "attributeValueFromNsName", (void (**)(void))&__pyx_api_f_4lxml_5etree_attributeValueFromNsName, "PyObject *(xmlNode *, const xmlChar *, const xmlChar *)") < 0) goto bad;
|
| 165 |
+
if (__Pyx_ImportFunction_3_0_11(module, "getAttributeValue", (void (**)(void))&__pyx_api_f_4lxml_5etree_getAttributeValue, "PyObject *(struct LxmlElement *, PyObject *, PyObject *)") < 0) goto bad;
|
| 166 |
+
if (__Pyx_ImportFunction_3_0_11(module, "iterattributes", (void (**)(void))&__pyx_api_f_4lxml_5etree_iterattributes, "PyObject *(struct LxmlElement *, int)") < 0) goto bad;
|
| 167 |
+
if (__Pyx_ImportFunction_3_0_11(module, "collectAttributes", (void (**)(void))&__pyx_api_f_4lxml_5etree_collectAttributes, "PyObject *(xmlNode *, int)") < 0) goto bad;
|
| 168 |
+
if (__Pyx_ImportFunction_3_0_11(module, "setAttributeValue", (void (**)(void))&__pyx_api_f_4lxml_5etree_setAttributeValue, "int (struct LxmlElement *, PyObject *, PyObject *)") < 0) goto bad;
|
| 169 |
+
if (__Pyx_ImportFunction_3_0_11(module, "delAttribute", (void (**)(void))&__pyx_api_f_4lxml_5etree_delAttribute, "int (struct LxmlElement *, PyObject *)") < 0) goto bad;
|
| 170 |
+
if (__Pyx_ImportFunction_3_0_11(module, "delAttributeFromNsName", (void (**)(void))&__pyx_api_f_4lxml_5etree_delAttributeFromNsName, "int (xmlNode *, const xmlChar *, const xmlChar *)") < 0) goto bad;
|
| 171 |
+
if (__Pyx_ImportFunction_3_0_11(module, "hasChild", (void (**)(void))&__pyx_api_f_4lxml_5etree_hasChild, "int (xmlNode *)") < 0) goto bad;
|
| 172 |
+
if (__Pyx_ImportFunction_3_0_11(module, "findChild", (void (**)(void))&__pyx_api_f_4lxml_5etree_findChild, "xmlNode *(xmlNode *, Py_ssize_t)") < 0) goto bad;
|
| 173 |
+
if (__Pyx_ImportFunction_3_0_11(module, "findChildForwards", (void (**)(void))&__pyx_api_f_4lxml_5etree_findChildForwards, "xmlNode *(xmlNode *, Py_ssize_t)") < 0) goto bad;
|
| 174 |
+
if (__Pyx_ImportFunction_3_0_11(module, "findChildBackwards", (void (**)(void))&__pyx_api_f_4lxml_5etree_findChildBackwards, "xmlNode *(xmlNode *, Py_ssize_t)") < 0) goto bad;
|
| 175 |
+
if (__Pyx_ImportFunction_3_0_11(module, "nextElement", (void (**)(void))&__pyx_api_f_4lxml_5etree_nextElement, "xmlNode *(xmlNode *)") < 0) goto bad;
|
| 176 |
+
if (__Pyx_ImportFunction_3_0_11(module, "previousElement", (void (**)(void))&__pyx_api_f_4lxml_5etree_previousElement, "xmlNode *(xmlNode *)") < 0) goto bad;
|
| 177 |
+
if (__Pyx_ImportFunction_3_0_11(module, "appendChild", (void (**)(void))&__pyx_api_f_4lxml_5etree_appendChild, "void (struct LxmlElement *, struct LxmlElement *)") < 0) goto bad;
|
| 178 |
+
if (__Pyx_ImportFunction_3_0_11(module, "appendChildToElement", (void (**)(void))&__pyx_api_f_4lxml_5etree_appendChildToElement, "int (struct LxmlElement *, struct LxmlElement *)") < 0) goto bad;
|
| 179 |
+
if (__Pyx_ImportFunction_3_0_11(module, "pyunicode", (void (**)(void))&__pyx_api_f_4lxml_5etree_pyunicode, "PyObject *(const xmlChar *)") < 0) goto bad;
|
| 180 |
+
if (__Pyx_ImportFunction_3_0_11(module, "utf8", (void (**)(void))&__pyx_api_f_4lxml_5etree_utf8, "PyObject *(PyObject *)") < 0) goto bad;
|
| 181 |
+
if (__Pyx_ImportFunction_3_0_11(module, "getNsTag", (void (**)(void))&__pyx_api_f_4lxml_5etree_getNsTag, "PyObject *(PyObject *)") < 0) goto bad;
|
| 182 |
+
if (__Pyx_ImportFunction_3_0_11(module, "getNsTagWithEmptyNs", (void (**)(void))&__pyx_api_f_4lxml_5etree_getNsTagWithEmptyNs, "PyObject *(PyObject *)") < 0) goto bad;
|
| 183 |
+
if (__Pyx_ImportFunction_3_0_11(module, "namespacedName", (void (**)(void))&__pyx_api_f_4lxml_5etree_namespacedName, "PyObject *(xmlNode *)") < 0) goto bad;
|
| 184 |
+
if (__Pyx_ImportFunction_3_0_11(module, "namespacedNameFromNsName", (void (**)(void))&__pyx_api_f_4lxml_5etree_namespacedNameFromNsName, "PyObject *(const xmlChar *, const xmlChar *)") < 0) goto bad;
|
| 185 |
+
if (__Pyx_ImportFunction_3_0_11(module, "iteratorStoreNext", (void (**)(void))&__pyx_api_f_4lxml_5etree_iteratorStoreNext, "void (struct LxmlElementIterator *, struct LxmlElement *)") < 0) goto bad;
|
| 186 |
+
if (__Pyx_ImportFunction_3_0_11(module, "initTagMatch", (void (**)(void))&__pyx_api_f_4lxml_5etree_initTagMatch, "void (struct LxmlElementTagMatcher *, PyObject *)") < 0) goto bad;
|
| 187 |
+
if (__Pyx_ImportFunction_3_0_11(module, "findOrBuildNodeNsPrefix", (void (**)(void))&__pyx_api_f_4lxml_5etree_findOrBuildNodeNsPrefix, "xmlNs *(struct LxmlDocument *, xmlNode *, const xmlChar *, const xmlChar *)") < 0) goto bad;
|
| 188 |
+
Py_DECREF(module); module = 0;
|
| 189 |
+
return 0;
|
| 190 |
+
bad:
|
| 191 |
+
Py_XDECREF(module);
|
| 192 |
+
return -1;
|
| 193 |
+
}
|
| 194 |
+
|
| 195 |
+
#endif /* !__PYX_HAVE_API__lxml__etree */
|
omnilmm/lib/python3.10/site-packages/lxml/extensions.pxi
ADDED
|
@@ -0,0 +1,833 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# support for extension functions in XPath and XSLT
|
| 2 |
+
|
| 3 |
+
cdef class XPathError(LxmlError):
|
| 4 |
+
"""Base class of all XPath errors.
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
cdef class XPathEvalError(XPathError):
|
| 8 |
+
"""Error during XPath evaluation.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
cdef class XPathFunctionError(XPathEvalError):
|
| 12 |
+
"""Internal error looking up an XPath extension function.
|
| 13 |
+
"""
|
| 14 |
+
|
| 15 |
+
cdef class XPathResultError(XPathEvalError):
|
| 16 |
+
"""Error handling an XPath result.
|
| 17 |
+
"""
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
# forward declarations
|
| 21 |
+
|
| 22 |
+
ctypedef int (*_register_function)(void* ctxt, name_utf, ns_uri_utf)
|
| 23 |
+
cdef class _ExsltRegExp
|
| 24 |
+
|
| 25 |
+
################################################################################
|
| 26 |
+
# Base class for XSLT and XPath evaluation contexts: functions, namespaces, ...
|
| 27 |
+
|
| 28 |
+
@cython.internal
|
| 29 |
+
cdef class _BaseContext:
|
| 30 |
+
cdef xpath.xmlXPathContext* _xpathCtxt
|
| 31 |
+
cdef _Document _doc
|
| 32 |
+
cdef dict _extensions
|
| 33 |
+
cdef list _namespaces
|
| 34 |
+
cdef list _global_namespaces
|
| 35 |
+
cdef dict _utf_refs
|
| 36 |
+
cdef dict _function_cache
|
| 37 |
+
cdef dict _eval_context_dict
|
| 38 |
+
cdef bint _build_smart_strings
|
| 39 |
+
# for exception handling and temporary reference keeping:
|
| 40 |
+
cdef _TempStore _temp_refs
|
| 41 |
+
cdef set _temp_documents
|
| 42 |
+
cdef _ExceptionContext _exc
|
| 43 |
+
cdef _ErrorLog _error_log
|
| 44 |
+
|
| 45 |
+
def __cinit__(self):
|
| 46 |
+
self._xpathCtxt = NULL
|
| 47 |
+
|
| 48 |
+
def __init__(self, namespaces, extensions, error_log, enable_regexp,
|
| 49 |
+
build_smart_strings):
|
| 50 |
+
cdef _ExsltRegExp _regexp
|
| 51 |
+
cdef dict new_extensions
|
| 52 |
+
cdef list ns
|
| 53 |
+
self._utf_refs = {}
|
| 54 |
+
self._global_namespaces = []
|
| 55 |
+
self._function_cache = {}
|
| 56 |
+
self._eval_context_dict = None
|
| 57 |
+
self._error_log = error_log
|
| 58 |
+
|
| 59 |
+
if extensions is not None:
|
| 60 |
+
# convert extensions to UTF-8
|
| 61 |
+
if isinstance(extensions, dict):
|
| 62 |
+
extensions = (extensions,)
|
| 63 |
+
# format: [ {(ns, name):function} ] -> {(ns_utf, name_utf):function}
|
| 64 |
+
new_extensions = {}
|
| 65 |
+
for extension in extensions:
|
| 66 |
+
for (ns_uri, name), function in extension.items():
|
| 67 |
+
if name is None:
|
| 68 |
+
raise ValueError, "extensions must have non empty names"
|
| 69 |
+
ns_utf = self._to_utf(ns_uri)
|
| 70 |
+
name_utf = self._to_utf(name)
|
| 71 |
+
new_extensions[(ns_utf, name_utf)] = function
|
| 72 |
+
extensions = new_extensions or None
|
| 73 |
+
|
| 74 |
+
if namespaces is not None:
|
| 75 |
+
if isinstance(namespaces, dict):
|
| 76 |
+
namespaces = namespaces.items()
|
| 77 |
+
if namespaces:
|
| 78 |
+
ns = []
|
| 79 |
+
for prefix, ns_uri in namespaces:
|
| 80 |
+
if prefix is None or not prefix:
|
| 81 |
+
raise TypeError, \
|
| 82 |
+
"empty namespace prefix is not supported in XPath"
|
| 83 |
+
if ns_uri is None or not ns_uri:
|
| 84 |
+
raise TypeError, \
|
| 85 |
+
"setting default namespace is not supported in XPath"
|
| 86 |
+
prefix_utf = self._to_utf(prefix)
|
| 87 |
+
ns_uri_utf = self._to_utf(ns_uri)
|
| 88 |
+
ns.append( (prefix_utf, ns_uri_utf) )
|
| 89 |
+
namespaces = ns
|
| 90 |
+
else:
|
| 91 |
+
namespaces = None
|
| 92 |
+
|
| 93 |
+
self._doc = None
|
| 94 |
+
self._exc = _ExceptionContext()
|
| 95 |
+
self._extensions = extensions
|
| 96 |
+
self._namespaces = namespaces
|
| 97 |
+
self._temp_refs = _TempStore()
|
| 98 |
+
self._temp_documents = set()
|
| 99 |
+
self._build_smart_strings = build_smart_strings
|
| 100 |
+
|
| 101 |
+
if enable_regexp:
|
| 102 |
+
_regexp = _ExsltRegExp()
|
| 103 |
+
_regexp._register_in_context(self)
|
| 104 |
+
|
| 105 |
+
cdef _BaseContext _copy(self):
|
| 106 |
+
cdef _BaseContext context
|
| 107 |
+
if self._namespaces is not None:
|
| 108 |
+
namespaces = self._namespaces[:]
|
| 109 |
+
else:
|
| 110 |
+
namespaces = None
|
| 111 |
+
context = self.__class__(namespaces, None, self._error_log, False,
|
| 112 |
+
self._build_smart_strings)
|
| 113 |
+
if self._extensions is not None:
|
| 114 |
+
context._extensions = self._extensions.copy()
|
| 115 |
+
return context
|
| 116 |
+
|
| 117 |
+
cdef bytes _to_utf(self, s):
|
| 118 |
+
"Convert to UTF-8 and keep a reference to the encoded string"
|
| 119 |
+
cdef python.PyObject* dict_result
|
| 120 |
+
if s is None:
|
| 121 |
+
return None
|
| 122 |
+
dict_result = python.PyDict_GetItem(self._utf_refs, s)
|
| 123 |
+
if dict_result is not NULL:
|
| 124 |
+
return <bytes>dict_result
|
| 125 |
+
utf = _utf8(s)
|
| 126 |
+
self._utf_refs[s] = utf
|
| 127 |
+
if python.IS_PYPY:
|
| 128 |
+
# use C level refs, PyPy refs are not enough!
|
| 129 |
+
python.Py_INCREF(utf)
|
| 130 |
+
return utf
|
| 131 |
+
|
| 132 |
+
cdef void _set_xpath_context(self, xpath.xmlXPathContext* xpathCtxt) noexcept:
|
| 133 |
+
self._xpathCtxt = xpathCtxt
|
| 134 |
+
xpathCtxt.userData = <void*>self
|
| 135 |
+
# Need a cast here because older libxml2 releases do not use 'const' in the functype.
|
| 136 |
+
xpathCtxt.error = <xmlerror.xmlStructuredErrorFunc> _receiveXPathError
|
| 137 |
+
|
| 138 |
+
@cython.final
|
| 139 |
+
cdef _register_context(self, _Document doc):
|
| 140 |
+
self._doc = doc
|
| 141 |
+
self._exc.clear()
|
| 142 |
+
|
| 143 |
+
@cython.final
|
| 144 |
+
cdef _cleanup_context(self):
|
| 145 |
+
#xpath.xmlXPathRegisteredNsCleanup(self._xpathCtxt)
|
| 146 |
+
#self.unregisterGlobalNamespaces()
|
| 147 |
+
if python.IS_PYPY:
|
| 148 |
+
# clean up double refs in PyPy (see "_to_utf()" method)
|
| 149 |
+
for ref in self._utf_refs.itervalues():
|
| 150 |
+
python.Py_DECREF(ref)
|
| 151 |
+
self._utf_refs.clear()
|
| 152 |
+
self._eval_context_dict = None
|
| 153 |
+
self._doc = None
|
| 154 |
+
|
| 155 |
+
@cython.final
|
| 156 |
+
cdef _release_context(self):
|
| 157 |
+
if self._xpathCtxt is not NULL:
|
| 158 |
+
self._xpathCtxt.userData = NULL
|
| 159 |
+
self._xpathCtxt = NULL
|
| 160 |
+
|
| 161 |
+
# namespaces (internal UTF-8 methods with leading '_')
|
| 162 |
+
|
| 163 |
+
cdef addNamespace(self, prefix, ns_uri):
|
| 164 |
+
cdef list namespaces
|
| 165 |
+
if prefix is None:
|
| 166 |
+
raise TypeError, "empty prefix is not supported in XPath"
|
| 167 |
+
prefix_utf = self._to_utf(prefix)
|
| 168 |
+
ns_uri_utf = self._to_utf(ns_uri)
|
| 169 |
+
new_item = (prefix_utf, ns_uri_utf)
|
| 170 |
+
if self._namespaces is None:
|
| 171 |
+
self._namespaces = [new_item]
|
| 172 |
+
else:
|
| 173 |
+
namespaces = []
|
| 174 |
+
for item in self._namespaces:
|
| 175 |
+
if item[0] == prefix_utf:
|
| 176 |
+
item = new_item
|
| 177 |
+
new_item = None
|
| 178 |
+
namespaces.append(item)
|
| 179 |
+
if new_item is not None:
|
| 180 |
+
namespaces.append(new_item)
|
| 181 |
+
self._namespaces = namespaces
|
| 182 |
+
if self._xpathCtxt is not NULL:
|
| 183 |
+
xpath.xmlXPathRegisterNs(
|
| 184 |
+
self._xpathCtxt, _xcstr(prefix_utf), _xcstr(ns_uri_utf))
|
| 185 |
+
|
| 186 |
+
cdef registerNamespace(self, prefix, ns_uri):
|
| 187 |
+
if prefix is None:
|
| 188 |
+
raise TypeError, "empty prefix is not supported in XPath"
|
| 189 |
+
prefix_utf = self._to_utf(prefix)
|
| 190 |
+
ns_uri_utf = self._to_utf(ns_uri)
|
| 191 |
+
self._global_namespaces.append(prefix_utf)
|
| 192 |
+
xpath.xmlXPathRegisterNs(self._xpathCtxt,
|
| 193 |
+
_xcstr(prefix_utf), _xcstr(ns_uri_utf))
|
| 194 |
+
|
| 195 |
+
cdef registerLocalNamespaces(self):
|
| 196 |
+
if self._namespaces is None:
|
| 197 |
+
return
|
| 198 |
+
for prefix_utf, ns_uri_utf in self._namespaces:
|
| 199 |
+
xpath.xmlXPathRegisterNs(
|
| 200 |
+
self._xpathCtxt, _xcstr(prefix_utf), _xcstr(ns_uri_utf))
|
| 201 |
+
|
| 202 |
+
cdef registerGlobalNamespaces(self):
|
| 203 |
+
cdef list ns_prefixes = _find_all_extension_prefixes()
|
| 204 |
+
if python.PyList_GET_SIZE(ns_prefixes) > 0:
|
| 205 |
+
for prefix_utf, ns_uri_utf in ns_prefixes:
|
| 206 |
+
self._global_namespaces.append(prefix_utf)
|
| 207 |
+
xpath.xmlXPathRegisterNs(
|
| 208 |
+
self._xpathCtxt, _xcstr(prefix_utf), _xcstr(ns_uri_utf))
|
| 209 |
+
|
| 210 |
+
cdef unregisterGlobalNamespaces(self):
|
| 211 |
+
if python.PyList_GET_SIZE(self._global_namespaces) > 0:
|
| 212 |
+
for prefix_utf in self._global_namespaces:
|
| 213 |
+
xpath.xmlXPathRegisterNs(self._xpathCtxt,
|
| 214 |
+
_xcstr(prefix_utf), NULL)
|
| 215 |
+
del self._global_namespaces[:]
|
| 216 |
+
|
| 217 |
+
cdef void _unregisterNamespace(self, prefix_utf) noexcept:
|
| 218 |
+
xpath.xmlXPathRegisterNs(self._xpathCtxt,
|
| 219 |
+
_xcstr(prefix_utf), NULL)
|
| 220 |
+
|
| 221 |
+
# extension functions
|
| 222 |
+
|
| 223 |
+
cdef int _addLocalExtensionFunction(self, ns_utf, name_utf, function) except -1:
|
| 224 |
+
if self._extensions is None:
|
| 225 |
+
self._extensions = {}
|
| 226 |
+
self._extensions[(ns_utf, name_utf)] = function
|
| 227 |
+
return 0
|
| 228 |
+
|
| 229 |
+
cdef registerGlobalFunctions(self, void* ctxt,
|
| 230 |
+
_register_function reg_func):
|
| 231 |
+
cdef python.PyObject* dict_result
|
| 232 |
+
cdef dict d
|
| 233 |
+
for ns_utf, ns_functions in __FUNCTION_NAMESPACE_REGISTRIES.iteritems():
|
| 234 |
+
dict_result = python.PyDict_GetItem(
|
| 235 |
+
self._function_cache, ns_utf)
|
| 236 |
+
if dict_result is not NULL:
|
| 237 |
+
d = <dict>dict_result
|
| 238 |
+
else:
|
| 239 |
+
d = {}
|
| 240 |
+
self._function_cache[ns_utf] = d
|
| 241 |
+
for name_utf, function in ns_functions.iteritems():
|
| 242 |
+
d[name_utf] = function
|
| 243 |
+
reg_func(ctxt, name_utf, ns_utf)
|
| 244 |
+
|
| 245 |
+
cdef registerLocalFunctions(self, void* ctxt,
|
| 246 |
+
_register_function reg_func):
|
| 247 |
+
cdef python.PyObject* dict_result
|
| 248 |
+
cdef dict d
|
| 249 |
+
if self._extensions is None:
|
| 250 |
+
return # done
|
| 251 |
+
last_ns = None
|
| 252 |
+
d = None
|
| 253 |
+
for (ns_utf, name_utf), function in self._extensions.iteritems():
|
| 254 |
+
if ns_utf is not last_ns or d is None:
|
| 255 |
+
last_ns = ns_utf
|
| 256 |
+
dict_result = python.PyDict_GetItem(
|
| 257 |
+
self._function_cache, ns_utf)
|
| 258 |
+
if dict_result is not NULL:
|
| 259 |
+
d = <dict>dict_result
|
| 260 |
+
else:
|
| 261 |
+
d = {}
|
| 262 |
+
self._function_cache[ns_utf] = d
|
| 263 |
+
d[name_utf] = function
|
| 264 |
+
reg_func(ctxt, name_utf, ns_utf)
|
| 265 |
+
|
| 266 |
+
cdef unregisterAllFunctions(self, void* ctxt,
|
| 267 |
+
_register_function unreg_func):
|
| 268 |
+
for ns_utf, functions in self._function_cache.iteritems():
|
| 269 |
+
for name_utf in functions:
|
| 270 |
+
unreg_func(ctxt, name_utf, ns_utf)
|
| 271 |
+
|
| 272 |
+
cdef unregisterGlobalFunctions(self, void* ctxt,
|
| 273 |
+
_register_function unreg_func):
|
| 274 |
+
for ns_utf, functions in self._function_cache.items():
|
| 275 |
+
for name_utf in functions:
|
| 276 |
+
if self._extensions is None or \
|
| 277 |
+
(ns_utf, name_utf) not in self._extensions:
|
| 278 |
+
unreg_func(ctxt, name_utf, ns_utf)
|
| 279 |
+
|
| 280 |
+
@cython.final
|
| 281 |
+
cdef _find_cached_function(self, const_xmlChar* c_ns_uri, const_xmlChar* c_name):
|
| 282 |
+
"""Lookup an extension function in the cache and return it.
|
| 283 |
+
|
| 284 |
+
Parameters: c_ns_uri may be NULL, c_name must not be NULL
|
| 285 |
+
"""
|
| 286 |
+
cdef python.PyObject* c_dict
|
| 287 |
+
cdef python.PyObject* dict_result
|
| 288 |
+
c_dict = python.PyDict_GetItem(
|
| 289 |
+
self._function_cache, None if c_ns_uri is NULL else c_ns_uri)
|
| 290 |
+
if c_dict is not NULL:
|
| 291 |
+
dict_result = python.PyDict_GetItem(
|
| 292 |
+
<object>c_dict, <unsigned char*>c_name)
|
| 293 |
+
if dict_result is not NULL:
|
| 294 |
+
return <object>dict_result
|
| 295 |
+
return None
|
| 296 |
+
|
| 297 |
+
# Python access to the XPath context for extension functions
|
| 298 |
+
|
| 299 |
+
@property
|
| 300 |
+
def context_node(self):
|
| 301 |
+
cdef xmlNode* c_node
|
| 302 |
+
if self._xpathCtxt is NULL:
|
| 303 |
+
raise XPathError, \
|
| 304 |
+
"XPath context is only usable during the evaluation"
|
| 305 |
+
c_node = self._xpathCtxt.node
|
| 306 |
+
if c_node is NULL:
|
| 307 |
+
raise XPathError, "no context node"
|
| 308 |
+
if c_node.doc != self._xpathCtxt.doc:
|
| 309 |
+
raise XPathError, \
|
| 310 |
+
"document-external context nodes are not supported"
|
| 311 |
+
if self._doc is None:
|
| 312 |
+
raise XPathError, "document context is missing"
|
| 313 |
+
return _elementFactory(self._doc, c_node)
|
| 314 |
+
|
| 315 |
+
@property
|
| 316 |
+
def eval_context(self):
|
| 317 |
+
if self._eval_context_dict is None:
|
| 318 |
+
self._eval_context_dict = {}
|
| 319 |
+
return self._eval_context_dict
|
| 320 |
+
|
| 321 |
+
# Python reference keeping during XPath function evaluation
|
| 322 |
+
|
| 323 |
+
@cython.final
|
| 324 |
+
cdef _release_temp_refs(self):
|
| 325 |
+
"Free temporarily referenced objects from this context."
|
| 326 |
+
self._temp_refs.clear()
|
| 327 |
+
self._temp_documents.clear()
|
| 328 |
+
|
| 329 |
+
@cython.final
|
| 330 |
+
cdef _hold(self, obj):
|
| 331 |
+
"""A way to temporarily hold references to nodes in the evaluator.
|
| 332 |
+
|
| 333 |
+
This is needed because otherwise nodes created in XPath extension
|
| 334 |
+
functions would be reference counted too soon, during the XPath
|
| 335 |
+
evaluation. This is most important in the case of exceptions.
|
| 336 |
+
"""
|
| 337 |
+
cdef _Element element
|
| 338 |
+
if isinstance(obj, _Element):
|
| 339 |
+
self._temp_refs.add(obj)
|
| 340 |
+
self._temp_documents.add((<_Element>obj)._doc)
|
| 341 |
+
return
|
| 342 |
+
elif _isString(obj) or not python.PySequence_Check(obj):
|
| 343 |
+
return
|
| 344 |
+
for o in obj:
|
| 345 |
+
if isinstance(o, _Element):
|
| 346 |
+
#print "Holding element:", <int>element._c_node
|
| 347 |
+
self._temp_refs.add(o)
|
| 348 |
+
#print "Holding document:", <int>element._doc._c_doc
|
| 349 |
+
self._temp_documents.add((<_Element>o)._doc)
|
| 350 |
+
|
| 351 |
+
@cython.final
|
| 352 |
+
cdef _Document _findDocumentForNode(self, xmlNode* c_node):
|
| 353 |
+
"""If an XPath expression returns an element from a different
|
| 354 |
+
document than the current context document, we call this to
|
| 355 |
+
see if it was possibly created by an extension and is a known
|
| 356 |
+
document instance.
|
| 357 |
+
"""
|
| 358 |
+
cdef _Document doc
|
| 359 |
+
for doc in self._temp_documents:
|
| 360 |
+
if doc is not None and doc._c_doc is c_node.doc:
|
| 361 |
+
return doc
|
| 362 |
+
return None
|
| 363 |
+
|
| 364 |
+
|
| 365 |
+
# libxml2 keeps these error messages in a static array in its code
|
| 366 |
+
# and doesn't give us access to them ...
|
| 367 |
+
|
| 368 |
+
cdef tuple LIBXML2_XPATH_ERROR_MESSAGES = (
|
| 369 |
+
b"Ok",
|
| 370 |
+
b"Number encoding",
|
| 371 |
+
b"Unfinished literal",
|
| 372 |
+
b"Start of literal",
|
| 373 |
+
b"Expected $ for variable reference",
|
| 374 |
+
b"Undefined variable",
|
| 375 |
+
b"Invalid predicate",
|
| 376 |
+
b"Invalid expression",
|
| 377 |
+
b"Missing closing curly brace",
|
| 378 |
+
b"Unregistered function",
|
| 379 |
+
b"Invalid operand",
|
| 380 |
+
b"Invalid type",
|
| 381 |
+
b"Invalid number of arguments",
|
| 382 |
+
b"Invalid context size",
|
| 383 |
+
b"Invalid context position",
|
| 384 |
+
b"Memory allocation error",
|
| 385 |
+
b"Syntax error",
|
| 386 |
+
b"Resource error",
|
| 387 |
+
b"Sub resource error",
|
| 388 |
+
b"Undefined namespace prefix",
|
| 389 |
+
b"Encoding error",
|
| 390 |
+
b"Char out of XML range",
|
| 391 |
+
b"Invalid or incomplete context",
|
| 392 |
+
b"Stack usage error",
|
| 393 |
+
b"Forbidden variable\n",
|
| 394 |
+
b"?? Unknown error ??\n",
|
| 395 |
+
)
|
| 396 |
+
|
| 397 |
+
cdef void _forwardXPathError(void* c_ctxt, const xmlerror.xmlError* c_error) noexcept with gil:
|
| 398 |
+
cdef xmlerror.xmlError error
|
| 399 |
+
cdef int xpath_code
|
| 400 |
+
if c_error.message is not NULL:
|
| 401 |
+
error.message = c_error.message
|
| 402 |
+
else:
|
| 403 |
+
xpath_code = c_error.code - xmlerror.XML_XPATH_EXPRESSION_OK
|
| 404 |
+
if 0 <= xpath_code < len(LIBXML2_XPATH_ERROR_MESSAGES):
|
| 405 |
+
error.message = _cstr(LIBXML2_XPATH_ERROR_MESSAGES[xpath_code])
|
| 406 |
+
else:
|
| 407 |
+
error.message = b"unknown error"
|
| 408 |
+
error.domain = c_error.domain
|
| 409 |
+
error.code = c_error.code
|
| 410 |
+
error.level = c_error.level
|
| 411 |
+
error.line = c_error.line
|
| 412 |
+
error.int2 = c_error.int1 # column
|
| 413 |
+
error.file = c_error.file
|
| 414 |
+
error.node = NULL
|
| 415 |
+
|
| 416 |
+
(<_BaseContext>c_ctxt)._error_log._receive(&error)
|
| 417 |
+
|
| 418 |
+
cdef void _receiveXPathError(void* c_context, const xmlerror.xmlError* error) noexcept nogil:
|
| 419 |
+
if not __DEBUG:
|
| 420 |
+
return
|
| 421 |
+
if c_context is NULL:
|
| 422 |
+
_forwardError(NULL, error)
|
| 423 |
+
else:
|
| 424 |
+
_forwardXPathError(c_context, error)
|
| 425 |
+
|
| 426 |
+
|
| 427 |
+
def Extension(module, function_mapping=None, *, ns=None):
|
| 428 |
+
"""Extension(module, function_mapping=None, ns=None)
|
| 429 |
+
|
| 430 |
+
Build a dictionary of extension functions from the functions
|
| 431 |
+
defined in a module or the methods of an object.
|
| 432 |
+
|
| 433 |
+
As second argument, you can pass an additional mapping of
|
| 434 |
+
attribute names to XPath function names, or a list of function
|
| 435 |
+
names that should be taken.
|
| 436 |
+
|
| 437 |
+
The ``ns`` keyword argument accepts a namespace URI for the XPath
|
| 438 |
+
functions.
|
| 439 |
+
"""
|
| 440 |
+
cdef dict functions = {}
|
| 441 |
+
if isinstance(function_mapping, dict):
|
| 442 |
+
for function_name, xpath_name in function_mapping.items():
|
| 443 |
+
functions[(ns, xpath_name)] = getattr(module, function_name)
|
| 444 |
+
else:
|
| 445 |
+
if function_mapping is None:
|
| 446 |
+
function_mapping = [ name for name in dir(module)
|
| 447 |
+
if not name.startswith('_') ]
|
| 448 |
+
for function_name in function_mapping:
|
| 449 |
+
functions[(ns, function_name)] = getattr(module, function_name)
|
| 450 |
+
return functions
|
| 451 |
+
|
| 452 |
+
################################################################################
|
| 453 |
+
# EXSLT regexp implementation
|
| 454 |
+
|
| 455 |
+
@cython.final
|
| 456 |
+
@cython.internal
|
| 457 |
+
cdef class _ExsltRegExp:
|
| 458 |
+
cdef dict _compile_map
|
| 459 |
+
def __cinit__(self):
|
| 460 |
+
self._compile_map = {}
|
| 461 |
+
|
| 462 |
+
cdef _make_string(self, value):
|
| 463 |
+
if _isString(value):
|
| 464 |
+
return value
|
| 465 |
+
elif isinstance(value, list):
|
| 466 |
+
# node set: take recursive text concatenation of first element
|
| 467 |
+
if python.PyList_GET_SIZE(value) == 0:
|
| 468 |
+
return ''
|
| 469 |
+
firstnode = value[0]
|
| 470 |
+
if _isString(firstnode):
|
| 471 |
+
return firstnode
|
| 472 |
+
elif isinstance(firstnode, _Element):
|
| 473 |
+
c_text = tree.xmlNodeGetContent((<_Element>firstnode)._c_node)
|
| 474 |
+
if c_text is NULL:
|
| 475 |
+
raise MemoryError()
|
| 476 |
+
try:
|
| 477 |
+
return funicode(c_text)
|
| 478 |
+
finally:
|
| 479 |
+
tree.xmlFree(c_text)
|
| 480 |
+
else:
|
| 481 |
+
return unicode(firstnode)
|
| 482 |
+
else:
|
| 483 |
+
return unicode(value)
|
| 484 |
+
|
| 485 |
+
cdef _compile(self, rexp, ignore_case):
|
| 486 |
+
cdef python.PyObject* c_result
|
| 487 |
+
rexp = self._make_string(rexp)
|
| 488 |
+
key = (rexp, ignore_case)
|
| 489 |
+
c_result = python.PyDict_GetItem(self._compile_map, key)
|
| 490 |
+
if c_result is not NULL:
|
| 491 |
+
return <object>c_result
|
| 492 |
+
py_flags = re.UNICODE
|
| 493 |
+
if ignore_case:
|
| 494 |
+
py_flags = py_flags | re.IGNORECASE
|
| 495 |
+
rexp_compiled = re.compile(rexp, py_flags)
|
| 496 |
+
self._compile_map[key] = rexp_compiled
|
| 497 |
+
return rexp_compiled
|
| 498 |
+
|
| 499 |
+
def test(self, ctxt, s, rexp, flags=''):
|
| 500 |
+
flags = self._make_string(flags)
|
| 501 |
+
s = self._make_string(s)
|
| 502 |
+
rexpc = self._compile(rexp, 'i' in flags)
|
| 503 |
+
if rexpc.search(s) is None:
|
| 504 |
+
return False
|
| 505 |
+
else:
|
| 506 |
+
return True
|
| 507 |
+
|
| 508 |
+
def match(self, ctxt, s, rexp, flags=''):
|
| 509 |
+
cdef list result_list
|
| 510 |
+
flags = self._make_string(flags)
|
| 511 |
+
s = self._make_string(s)
|
| 512 |
+
rexpc = self._compile(rexp, 'i' in flags)
|
| 513 |
+
if 'g' in flags:
|
| 514 |
+
results = rexpc.findall(s)
|
| 515 |
+
if not results:
|
| 516 |
+
return ()
|
| 517 |
+
else:
|
| 518 |
+
result = rexpc.search(s)
|
| 519 |
+
if not result:
|
| 520 |
+
return ()
|
| 521 |
+
results = [ result.group() ]
|
| 522 |
+
results.extend( result.groups('') )
|
| 523 |
+
result_list = []
|
| 524 |
+
root = Element('matches')
|
| 525 |
+
for s_match in results:
|
| 526 |
+
if python.PyTuple_CheckExact(s_match):
|
| 527 |
+
s_match = ''.join(s_match)
|
| 528 |
+
elem = SubElement(root, 'match')
|
| 529 |
+
elem.text = s_match
|
| 530 |
+
result_list.append(elem)
|
| 531 |
+
return result_list
|
| 532 |
+
|
| 533 |
+
def replace(self, ctxt, s, rexp, flags, replacement):
|
| 534 |
+
replacement = self._make_string(replacement)
|
| 535 |
+
flags = self._make_string(flags)
|
| 536 |
+
s = self._make_string(s)
|
| 537 |
+
rexpc = self._compile(rexp, 'i' in flags)
|
| 538 |
+
count: object = 0 if 'g' in flags else 1
|
| 539 |
+
return rexpc.sub(replacement, s, count)
|
| 540 |
+
|
| 541 |
+
cdef _register_in_context(self, _BaseContext context):
|
| 542 |
+
ns = b"http://exslt.org/regular-expressions"
|
| 543 |
+
context._addLocalExtensionFunction(ns, b"test", self.test)
|
| 544 |
+
context._addLocalExtensionFunction(ns, b"match", self.match)
|
| 545 |
+
context._addLocalExtensionFunction(ns, b"replace", self.replace)
|
| 546 |
+
|
| 547 |
+
|
| 548 |
+
################################################################################
|
| 549 |
+
# helper functions
|
| 550 |
+
|
| 551 |
+
cdef xpath.xmlXPathObject* _wrapXPathObject(object obj, _Document doc,
|
| 552 |
+
_BaseContext context) except NULL:
|
| 553 |
+
cdef xpath.xmlNodeSet* resultSet
|
| 554 |
+
cdef _Element fake_node = None
|
| 555 |
+
cdef xmlNode* c_node
|
| 556 |
+
|
| 557 |
+
if isinstance(obj, unicode):
|
| 558 |
+
obj = _utf8(obj)
|
| 559 |
+
if isinstance(obj, bytes):
|
| 560 |
+
# libxml2 copies the string value
|
| 561 |
+
return xpath.xmlXPathNewCString(_cstr(obj))
|
| 562 |
+
if isinstance(obj, bool):
|
| 563 |
+
return xpath.xmlXPathNewBoolean(obj)
|
| 564 |
+
if python.PyNumber_Check(obj):
|
| 565 |
+
return xpath.xmlXPathNewFloat(obj)
|
| 566 |
+
if obj is None:
|
| 567 |
+
resultSet = xpath.xmlXPathNodeSetCreate(NULL)
|
| 568 |
+
elif isinstance(obj, _Element):
|
| 569 |
+
resultSet = xpath.xmlXPathNodeSetCreate((<_Element>obj)._c_node)
|
| 570 |
+
elif python.PySequence_Check(obj):
|
| 571 |
+
resultSet = xpath.xmlXPathNodeSetCreate(NULL)
|
| 572 |
+
try:
|
| 573 |
+
for value in obj:
|
| 574 |
+
if isinstance(value, _Element):
|
| 575 |
+
if context is not None:
|
| 576 |
+
context._hold(value)
|
| 577 |
+
xpath.xmlXPathNodeSetAdd(resultSet, (<_Element>value)._c_node)
|
| 578 |
+
else:
|
| 579 |
+
if context is None or doc is None:
|
| 580 |
+
raise XPathResultError, \
|
| 581 |
+
f"Non-Element values not supported at this point - got {value!r}"
|
| 582 |
+
# support strings by appending text nodes to an Element
|
| 583 |
+
if isinstance(value, unicode):
|
| 584 |
+
value = _utf8(value)
|
| 585 |
+
if isinstance(value, bytes):
|
| 586 |
+
if fake_node is None:
|
| 587 |
+
fake_node = _makeElement("text-root", NULL, doc, None,
|
| 588 |
+
None, None, None, None, None)
|
| 589 |
+
context._hold(fake_node)
|
| 590 |
+
else:
|
| 591 |
+
# append a comment node to keep the text nodes separate
|
| 592 |
+
c_node = tree.xmlNewDocComment(doc._c_doc, <unsigned char*>"")
|
| 593 |
+
if c_node is NULL:
|
| 594 |
+
raise MemoryError()
|
| 595 |
+
tree.xmlAddChild(fake_node._c_node, c_node)
|
| 596 |
+
context._hold(value)
|
| 597 |
+
c_node = tree.xmlNewDocText(doc._c_doc, _xcstr(value))
|
| 598 |
+
if c_node is NULL:
|
| 599 |
+
raise MemoryError()
|
| 600 |
+
tree.xmlAddChild(fake_node._c_node, c_node)
|
| 601 |
+
xpath.xmlXPathNodeSetAdd(resultSet, c_node)
|
| 602 |
+
else:
|
| 603 |
+
raise XPathResultError, \
|
| 604 |
+
f"This is not a supported node-set result: {value!r}"
|
| 605 |
+
except:
|
| 606 |
+
xpath.xmlXPathFreeNodeSet(resultSet)
|
| 607 |
+
raise
|
| 608 |
+
else:
|
| 609 |
+
raise XPathResultError, f"Unknown return type: {python._fqtypename(obj).decode('utf8')}"
|
| 610 |
+
return xpath.xmlXPathWrapNodeSet(resultSet)
|
| 611 |
+
|
| 612 |
+
cdef object _unwrapXPathObject(xpath.xmlXPathObject* xpathObj,
|
| 613 |
+
_Document doc, _BaseContext context):
|
| 614 |
+
if xpathObj.type == xpath.XPATH_UNDEFINED:
|
| 615 |
+
raise XPathResultError, "Undefined xpath result"
|
| 616 |
+
elif xpathObj.type == xpath.XPATH_NODESET:
|
| 617 |
+
return _createNodeSetResult(xpathObj, doc, context)
|
| 618 |
+
elif xpathObj.type == xpath.XPATH_BOOLEAN:
|
| 619 |
+
return xpathObj.boolval
|
| 620 |
+
elif xpathObj.type == xpath.XPATH_NUMBER:
|
| 621 |
+
return xpathObj.floatval
|
| 622 |
+
elif xpathObj.type == xpath.XPATH_STRING:
|
| 623 |
+
stringval = funicode(xpathObj.stringval)
|
| 624 |
+
if context._build_smart_strings:
|
| 625 |
+
stringval = _elementStringResultFactory(
|
| 626 |
+
stringval, None, None, False)
|
| 627 |
+
return stringval
|
| 628 |
+
elif xpathObj.type == xpath.XPATH_POINT:
|
| 629 |
+
raise NotImplementedError, "XPATH_POINT"
|
| 630 |
+
elif xpathObj.type == xpath.XPATH_RANGE:
|
| 631 |
+
raise NotImplementedError, "XPATH_RANGE"
|
| 632 |
+
elif xpathObj.type == xpath.XPATH_LOCATIONSET:
|
| 633 |
+
raise NotImplementedError, "XPATH_LOCATIONSET"
|
| 634 |
+
elif xpathObj.type == xpath.XPATH_USERS:
|
| 635 |
+
raise NotImplementedError, "XPATH_USERS"
|
| 636 |
+
elif xpathObj.type == xpath.XPATH_XSLT_TREE:
|
| 637 |
+
return _createNodeSetResult(xpathObj, doc, context)
|
| 638 |
+
else:
|
| 639 |
+
raise XPathResultError, f"Unknown xpath result {xpathObj.type}"
|
| 640 |
+
|
| 641 |
+
cdef object _createNodeSetResult(xpath.xmlXPathObject* xpathObj, _Document doc,
|
| 642 |
+
_BaseContext context):
|
| 643 |
+
cdef xmlNode* c_node
|
| 644 |
+
cdef int i
|
| 645 |
+
cdef list result
|
| 646 |
+
result = []
|
| 647 |
+
if xpathObj.nodesetval is NULL:
|
| 648 |
+
return result
|
| 649 |
+
for i in range(xpathObj.nodesetval.nodeNr):
|
| 650 |
+
c_node = xpathObj.nodesetval.nodeTab[i]
|
| 651 |
+
_unpackNodeSetEntry(result, c_node, doc, context,
|
| 652 |
+
xpathObj.type == xpath.XPATH_XSLT_TREE)
|
| 653 |
+
return result
|
| 654 |
+
|
| 655 |
+
cdef _unpackNodeSetEntry(list results, xmlNode* c_node, _Document doc,
|
| 656 |
+
_BaseContext context, bint is_fragment):
|
| 657 |
+
cdef xmlNode* c_child
|
| 658 |
+
if _isElement(c_node):
|
| 659 |
+
if c_node.doc != doc._c_doc and c_node.doc._private is NULL:
|
| 660 |
+
# XXX: works, but maybe not always the right thing to do?
|
| 661 |
+
# XPath: only runs when extensions create or copy trees
|
| 662 |
+
# -> we store Python refs to these, so that is OK
|
| 663 |
+
# XSLT: can it leak when merging trees from multiple sources?
|
| 664 |
+
c_node = tree.xmlDocCopyNode(c_node, doc._c_doc, 1)
|
| 665 |
+
# FIXME: call _instantiateElementFromXPath() instead?
|
| 666 |
+
results.append(
|
| 667 |
+
_fakeDocElementFactory(doc, c_node))
|
| 668 |
+
elif c_node.type == tree.XML_TEXT_NODE or \
|
| 669 |
+
c_node.type == tree.XML_CDATA_SECTION_NODE or \
|
| 670 |
+
c_node.type == tree.XML_ATTRIBUTE_NODE:
|
| 671 |
+
results.append(
|
| 672 |
+
_buildElementStringResult(doc, c_node, context))
|
| 673 |
+
elif c_node.type == tree.XML_NAMESPACE_DECL:
|
| 674 |
+
results.append( (funicodeOrNone((<xmlNs*>c_node).prefix),
|
| 675 |
+
funicodeOrNone((<xmlNs*>c_node).href)) )
|
| 676 |
+
elif c_node.type == tree.XML_DOCUMENT_NODE or \
|
| 677 |
+
c_node.type == tree.XML_HTML_DOCUMENT_NODE:
|
| 678 |
+
# ignored for everything but result tree fragments
|
| 679 |
+
if is_fragment:
|
| 680 |
+
c_child = c_node.children
|
| 681 |
+
while c_child is not NULL:
|
| 682 |
+
_unpackNodeSetEntry(results, c_child, doc, context, 0)
|
| 683 |
+
c_child = c_child.next
|
| 684 |
+
elif c_node.type == tree.XML_XINCLUDE_START or \
|
| 685 |
+
c_node.type == tree.XML_XINCLUDE_END:
|
| 686 |
+
pass
|
| 687 |
+
else:
|
| 688 |
+
raise NotImplementedError, \
|
| 689 |
+
f"Not yet implemented result node type: {c_node.type}"
|
| 690 |
+
|
| 691 |
+
cdef void _freeXPathObject(xpath.xmlXPathObject* xpathObj) noexcept:
|
| 692 |
+
"""Free the XPath object, but *never* free the *content* of node sets.
|
| 693 |
+
Python dealloc will do that for us.
|
| 694 |
+
"""
|
| 695 |
+
if xpathObj.nodesetval is not NULL:
|
| 696 |
+
xpath.xmlXPathFreeNodeSet(xpathObj.nodesetval)
|
| 697 |
+
xpathObj.nodesetval = NULL
|
| 698 |
+
xpath.xmlXPathFreeObject(xpathObj)
|
| 699 |
+
|
| 700 |
+
cdef _Element _instantiateElementFromXPath(xmlNode* c_node, _Document doc,
|
| 701 |
+
_BaseContext context):
|
| 702 |
+
# NOTE: this may copy the element - only call this when it can't leak
|
| 703 |
+
if c_node.doc != doc._c_doc and c_node.doc._private is NULL:
|
| 704 |
+
# not from the context document and not from a fake document
|
| 705 |
+
# either => may still be from a known document, e.g. one
|
| 706 |
+
# created by an extension function
|
| 707 |
+
node_doc = context._findDocumentForNode(c_node)
|
| 708 |
+
if node_doc is None:
|
| 709 |
+
# not from a known document at all! => can only make a
|
| 710 |
+
# safety copy here
|
| 711 |
+
c_node = tree.xmlDocCopyNode(c_node, doc._c_doc, 1)
|
| 712 |
+
else:
|
| 713 |
+
doc = node_doc
|
| 714 |
+
return _fakeDocElementFactory(doc, c_node)
|
| 715 |
+
|
| 716 |
+
################################################################################
|
| 717 |
+
# special str/unicode subclasses
|
| 718 |
+
|
| 719 |
+
@cython.final
|
| 720 |
+
cdef class _ElementUnicodeResult(unicode):
|
| 721 |
+
cdef _Element _parent
|
| 722 |
+
cdef readonly object attrname
|
| 723 |
+
cdef readonly bint is_tail
|
| 724 |
+
|
| 725 |
+
def getparent(self):
|
| 726 |
+
return self._parent
|
| 727 |
+
|
| 728 |
+
@property
|
| 729 |
+
def is_text(self):
|
| 730 |
+
return self._parent is not None and not (self.is_tail or self.attrname is not None)
|
| 731 |
+
|
| 732 |
+
@property
|
| 733 |
+
def is_attribute(self):
|
| 734 |
+
return self.attrname is not None
|
| 735 |
+
|
| 736 |
+
cdef object _elementStringResultFactory(string_value, _Element parent,
|
| 737 |
+
attrname, bint is_tail):
|
| 738 |
+
result = _ElementUnicodeResult(string_value)
|
| 739 |
+
result._parent = parent
|
| 740 |
+
result.is_tail = is_tail
|
| 741 |
+
result.attrname = attrname
|
| 742 |
+
return result
|
| 743 |
+
|
| 744 |
+
cdef object _buildElementStringResult(_Document doc, xmlNode* c_node,
|
| 745 |
+
_BaseContext context):
|
| 746 |
+
cdef _Element parent = None
|
| 747 |
+
cdef object attrname = None
|
| 748 |
+
cdef xmlNode* c_element
|
| 749 |
+
cdef bint is_tail
|
| 750 |
+
|
| 751 |
+
if c_node.type == tree.XML_ATTRIBUTE_NODE:
|
| 752 |
+
attrname = _namespacedName(c_node)
|
| 753 |
+
is_tail = 0
|
| 754 |
+
s = tree.xmlNodeGetContent(c_node)
|
| 755 |
+
try:
|
| 756 |
+
value = funicode(s)
|
| 757 |
+
finally:
|
| 758 |
+
tree.xmlFree(s)
|
| 759 |
+
c_element = NULL
|
| 760 |
+
else:
|
| 761 |
+
#assert c_node.type == tree.XML_TEXT_NODE or c_node.type == tree.XML_CDATA_SECTION_NODE, "invalid node type"
|
| 762 |
+
# may be tail text or normal text
|
| 763 |
+
value = funicode(c_node.content)
|
| 764 |
+
c_element = _previousElement(c_node)
|
| 765 |
+
is_tail = c_element is not NULL
|
| 766 |
+
|
| 767 |
+
if not context._build_smart_strings:
|
| 768 |
+
return value
|
| 769 |
+
|
| 770 |
+
if c_element is NULL:
|
| 771 |
+
# non-tail text or attribute text
|
| 772 |
+
c_element = c_node.parent
|
| 773 |
+
while c_element is not NULL and not _isElement(c_element):
|
| 774 |
+
c_element = c_element.parent
|
| 775 |
+
|
| 776 |
+
if c_element is not NULL:
|
| 777 |
+
parent = _instantiateElementFromXPath(c_element, doc, context)
|
| 778 |
+
|
| 779 |
+
return _elementStringResultFactory(
|
| 780 |
+
value, parent, attrname, is_tail)
|
| 781 |
+
|
| 782 |
+
################################################################################
|
| 783 |
+
# callbacks for XPath/XSLT extension functions
|
| 784 |
+
|
| 785 |
+
cdef void _extension_function_call(_BaseContext context, function,
|
| 786 |
+
xpath.xmlXPathParserContext* ctxt, int nargs) noexcept:
|
| 787 |
+
cdef _Document doc
|
| 788 |
+
cdef xpath.xmlXPathObject* obj
|
| 789 |
+
cdef list args
|
| 790 |
+
cdef int i
|
| 791 |
+
doc = context._doc
|
| 792 |
+
try:
|
| 793 |
+
args = []
|
| 794 |
+
for i in range(nargs):
|
| 795 |
+
obj = xpath.valuePop(ctxt)
|
| 796 |
+
o = _unwrapXPathObject(obj, doc, context)
|
| 797 |
+
_freeXPathObject(obj)
|
| 798 |
+
args.append(o)
|
| 799 |
+
args.reverse()
|
| 800 |
+
|
| 801 |
+
res = function(context, *args)
|
| 802 |
+
# wrap result for XPath consumption
|
| 803 |
+
obj = _wrapXPathObject(res, doc, context)
|
| 804 |
+
# prevent Python from deallocating elements handed to libxml2
|
| 805 |
+
context._hold(res)
|
| 806 |
+
xpath.valuePush(ctxt, obj)
|
| 807 |
+
except:
|
| 808 |
+
xpath.xmlXPathErr(ctxt, xpath.XPATH_EXPR_ERROR)
|
| 809 |
+
context._exc._store_raised()
|
| 810 |
+
finally:
|
| 811 |
+
return # swallow any further exceptions
|
| 812 |
+
|
| 813 |
+
# lookup the function by name and call it
|
| 814 |
+
|
| 815 |
+
cdef void _xpath_function_call(xpath.xmlXPathParserContext* ctxt,
|
| 816 |
+
int nargs) noexcept with gil:
|
| 817 |
+
cdef _BaseContext context
|
| 818 |
+
cdef xpath.xmlXPathContext* rctxt = ctxt.context
|
| 819 |
+
context = <_BaseContext> rctxt.userData
|
| 820 |
+
try:
|
| 821 |
+
function = context._find_cached_function(rctxt.functionURI, rctxt.function)
|
| 822 |
+
if function is not None:
|
| 823 |
+
_extension_function_call(context, function, ctxt, nargs)
|
| 824 |
+
else:
|
| 825 |
+
xpath.xmlXPathErr(ctxt, xpath.XPATH_UNKNOWN_FUNC_ERROR)
|
| 826 |
+
context._exc._store_exception(XPathFunctionError(
|
| 827 |
+
f"XPath function '{_namespacedNameFromNsName(rctxt.functionURI, rctxt.function)}' not found"))
|
| 828 |
+
except:
|
| 829 |
+
# may not be the right error, but we need to tell libxml2 *something*
|
| 830 |
+
xpath.xmlXPathErr(ctxt, xpath.XPATH_UNKNOWN_FUNC_ERROR)
|
| 831 |
+
context._exc._store_raised()
|
| 832 |
+
finally:
|
| 833 |
+
return # swallow any further exceptions
|
omnilmm/lib/python3.10/site-packages/lxml/includes/__init__.pxd
ADDED
|
File without changes
|
omnilmm/lib/python3.10/site-packages/lxml/includes/__init__.py
ADDED
|
File without changes
|
omnilmm/lib/python3.10/site-packages/lxml/includes/c14n.pxd
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from lxml.includes.tree cimport xmlDoc, xmlOutputBuffer, xmlChar
|
| 2 |
+
from lxml.includes.xpath cimport xmlNodeSet
|
| 3 |
+
|
| 4 |
+
cdef extern from "libxml/c14n.h" nogil:
|
| 5 |
+
cdef int xmlC14NDocDumpMemory(xmlDoc* doc,
|
| 6 |
+
xmlNodeSet* nodes,
|
| 7 |
+
int exclusive,
|
| 8 |
+
xmlChar** inclusive_ns_prefixes,
|
| 9 |
+
int with_comments,
|
| 10 |
+
xmlChar** doc_txt_ptr)
|
| 11 |
+
|
| 12 |
+
cdef int xmlC14NDocSave(xmlDoc* doc,
|
| 13 |
+
xmlNodeSet* nodes,
|
| 14 |
+
int exclusive,
|
| 15 |
+
xmlChar** inclusive_ns_prefixes,
|
| 16 |
+
int with_comments,
|
| 17 |
+
char* filename,
|
| 18 |
+
int compression)
|
| 19 |
+
|
| 20 |
+
cdef int xmlC14NDocSaveTo(xmlDoc* doc,
|
| 21 |
+
xmlNodeSet* nodes,
|
| 22 |
+
int exclusive,
|
| 23 |
+
xmlChar** inclusive_ns_prefixes,
|
| 24 |
+
int with_comments,
|
| 25 |
+
xmlOutputBuffer* buffer)
|
omnilmm/lib/python3.10/site-packages/lxml/includes/config.pxd
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
cdef extern from "etree_defs.h":
|
| 2 |
+
cdef bint ENABLE_THREADING
|
| 3 |
+
cdef bint ENABLE_SCHEMATRON
|
omnilmm/lib/python3.10/site-packages/lxml/includes/dtdvalid.pxd
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from lxml.includes cimport tree
|
| 2 |
+
from lxml.includes.tree cimport xmlDoc, xmlDtd
|
| 3 |
+
|
| 4 |
+
cdef extern from "libxml/valid.h" nogil:
|
| 5 |
+
ctypedef void (*xmlValidityErrorFunc)(void * ctx, const char * msg, ...) noexcept
|
| 6 |
+
ctypedef void (*xmlValidityWarningFunc)(void * ctx, const char * msg, ...) noexcept
|
| 7 |
+
|
| 8 |
+
ctypedef struct xmlValidCtxt:
|
| 9 |
+
void *userData
|
| 10 |
+
xmlValidityErrorFunc error
|
| 11 |
+
xmlValidityWarningFunc warning
|
| 12 |
+
|
| 13 |
+
cdef xmlValidCtxt* xmlNewValidCtxt()
|
| 14 |
+
cdef void xmlFreeValidCtxt(xmlValidCtxt* cur)
|
| 15 |
+
|
| 16 |
+
cdef int xmlValidateDtd(xmlValidCtxt* ctxt, xmlDoc* doc, xmlDtd* dtd)
|
| 17 |
+
cdef tree.xmlElement* xmlGetDtdElementDesc(
|
| 18 |
+
xmlDtd* dtd, tree.const_xmlChar* name)
|
omnilmm/lib/python3.10/site-packages/lxml/includes/etree_defs.h
ADDED
|
@@ -0,0 +1,379 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#ifndef HAS_ETREE_DEFS_H
|
| 2 |
+
#define HAS_ETREE_DEFS_H
|
| 3 |
+
|
| 4 |
+
/* quick check for Python/libxml2/libxslt devel setup */
|
| 5 |
+
#include "Python.h"
|
| 6 |
+
#ifndef PY_VERSION_HEX
|
| 7 |
+
# error the development package of Python (header files etc.) is not installed correctly
|
| 8 |
+
#elif PY_VERSION_HEX < 0x03060000
|
| 9 |
+
# error this version of lxml requires Python 3.6 or later
|
| 10 |
+
#endif
|
| 11 |
+
|
| 12 |
+
#include "libxml/xmlversion.h"
|
| 13 |
+
#ifndef LIBXML_VERSION
|
| 14 |
+
# error the development package of libxml2 (header files etc.) is not installed correctly
|
| 15 |
+
#elif LIBXML_VERSION < 20700
|
| 16 |
+
# error minimum required version of libxml2 is 2.7.0
|
| 17 |
+
#endif
|
| 18 |
+
|
| 19 |
+
#include "libxslt/xsltconfig.h"
|
| 20 |
+
#ifndef LIBXSLT_VERSION
|
| 21 |
+
# error the development package of libxslt (header files etc.) is not installed correctly
|
| 22 |
+
#elif LIBXSLT_VERSION < 10123
|
| 23 |
+
# error minimum required version of libxslt is 1.1.23
|
| 24 |
+
#endif
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
/* v_arg functions */
|
| 28 |
+
#define va_int(ap) va_arg(ap, int)
|
| 29 |
+
#define va_charptr(ap) va_arg(ap, char *)
|
| 30 |
+
|
| 31 |
+
#ifdef PYPY_VERSION
|
| 32 |
+
# define IS_PYPY 1
|
| 33 |
+
#else
|
| 34 |
+
# define IS_PYPY 0
|
| 35 |
+
#endif
|
| 36 |
+
|
| 37 |
+
/* unused */
|
| 38 |
+
#define IS_PYTHON2 0
|
| 39 |
+
#define IS_PYTHON3 1
|
| 40 |
+
#undef LXML_UNICODE_STRINGS
|
| 41 |
+
#define LXML_UNICODE_STRINGS 1
|
| 42 |
+
|
| 43 |
+
#if !IS_PYPY
|
| 44 |
+
# define PyWeakref_LockObject(obj) (NULL)
|
| 45 |
+
#endif
|
| 46 |
+
|
| 47 |
+
/* Threading is not currently supported by PyPy */
|
| 48 |
+
#if IS_PYPY
|
| 49 |
+
# ifndef WITHOUT_THREADING
|
| 50 |
+
# define WITHOUT_THREADING
|
| 51 |
+
# endif
|
| 52 |
+
#endif
|
| 53 |
+
|
| 54 |
+
#if IS_PYPY
|
| 55 |
+
# ifndef PyUnicode_FromFormat
|
| 56 |
+
# define PyUnicode_FromFormat PyString_FromFormat
|
| 57 |
+
# endif
|
| 58 |
+
# if !defined(PyBytes_FromFormat)
|
| 59 |
+
# ifdef PyString_FromFormat
|
| 60 |
+
# define PyBytes_FromFormat PyString_FromFormat
|
| 61 |
+
# else
|
| 62 |
+
#include <stdarg.h>
|
| 63 |
+
static PyObject* PyBytes_FromFormat(const char* format, ...) {
|
| 64 |
+
PyObject *string;
|
| 65 |
+
va_list vargs;
|
| 66 |
+
#ifdef HAVE_STDARG_PROTOTYPES
|
| 67 |
+
va_start(vargs, format);
|
| 68 |
+
#else
|
| 69 |
+
va_start(vargs);
|
| 70 |
+
#endif
|
| 71 |
+
string = PyUnicode_FromFormatV(format, vargs);
|
| 72 |
+
va_end(vargs);
|
| 73 |
+
if (string && PyUnicode_Check(string)) {
|
| 74 |
+
PyObject *bstring = PyUnicode_AsUTF8String(string);
|
| 75 |
+
Py_DECREF(string);
|
| 76 |
+
string = bstring;
|
| 77 |
+
}
|
| 78 |
+
if (string && !PyBytes_CheckExact(string)) {
|
| 79 |
+
Py_DECREF(string);
|
| 80 |
+
string = NULL;
|
| 81 |
+
PyErr_SetString(PyExc_TypeError, "String formatting and encoding failed to return bytes object");
|
| 82 |
+
}
|
| 83 |
+
return string;
|
| 84 |
+
}
|
| 85 |
+
# endif
|
| 86 |
+
# endif
|
| 87 |
+
#endif
|
| 88 |
+
|
| 89 |
+
#if PY_VERSION_HEX >= 0x030B00A1
|
| 90 |
+
/* Python 3.12 doesn't have wstr Unicode strings any more. */
|
| 91 |
+
#undef PyUnicode_GET_DATA_SIZE
|
| 92 |
+
#define PyUnicode_GET_DATA_SIZE(ustr) (0)
|
| 93 |
+
#undef PyUnicode_AS_DATA
|
| 94 |
+
#define PyUnicode_AS_DATA(ustr) (NULL)
|
| 95 |
+
#undef PyUnicode_IS_READY
|
| 96 |
+
#define PyUnicode_IS_READY(ustr) (1)
|
| 97 |
+
#endif
|
| 98 |
+
|
| 99 |
+
#ifdef WITHOUT_THREADING
|
| 100 |
+
# undef PyEval_SaveThread
|
| 101 |
+
# define PyEval_SaveThread() (NULL)
|
| 102 |
+
# undef PyEval_RestoreThread
|
| 103 |
+
# define PyEval_RestoreThread(state) if (state); else {}
|
| 104 |
+
# undef PyGILState_Ensure
|
| 105 |
+
# define PyGILState_Ensure() (PyGILState_UNLOCKED)
|
| 106 |
+
# undef PyGILState_Release
|
| 107 |
+
# define PyGILState_Release(state) if (state); else {}
|
| 108 |
+
# undef Py_UNBLOCK_THREADS
|
| 109 |
+
# define Py_UNBLOCK_THREADS _save = NULL;
|
| 110 |
+
# undef Py_BLOCK_THREADS
|
| 111 |
+
# define Py_BLOCK_THREADS if (_save); else {}
|
| 112 |
+
#endif
|
| 113 |
+
|
| 114 |
+
#ifdef WITHOUT_THREADING
|
| 115 |
+
# define ENABLE_THREADING 0
|
| 116 |
+
#else
|
| 117 |
+
# define ENABLE_THREADING 1
|
| 118 |
+
#endif
|
| 119 |
+
|
| 120 |
+
#if LIBXML_VERSION < 20704
|
| 121 |
+
/* FIXME: hack to make new error reporting compile in old libxml2 versions */
|
| 122 |
+
# define xmlStructuredErrorContext NULL
|
| 123 |
+
# define xmlXIncludeProcessTreeFlagsData(n,o,d) xmlXIncludeProcessTreeFlags(n,o)
|
| 124 |
+
#endif
|
| 125 |
+
|
| 126 |
+
/* schematron was added in libxml2 2.6.21 */
|
| 127 |
+
#ifdef LIBXML_SCHEMATRON_ENABLED
|
| 128 |
+
# define ENABLE_SCHEMATRON 1
|
| 129 |
+
#else
|
| 130 |
+
# define ENABLE_SCHEMATRON 0
|
| 131 |
+
# define XML_SCHEMATRON_OUT_QUIET 0
|
| 132 |
+
# define XML_SCHEMATRON_OUT_XML 0
|
| 133 |
+
# define XML_SCHEMATRON_OUT_ERROR 0
|
| 134 |
+
typedef void xmlSchematron;
|
| 135 |
+
typedef void xmlSchematronParserCtxt;
|
| 136 |
+
typedef void xmlSchematronValidCtxt;
|
| 137 |
+
# define xmlSchematronNewDocParserCtxt(doc) NULL
|
| 138 |
+
# define xmlSchematronNewParserCtxt(file) NULL
|
| 139 |
+
# define xmlSchematronParse(ctxt) NULL
|
| 140 |
+
# define xmlSchematronFreeParserCtxt(ctxt)
|
| 141 |
+
# define xmlSchematronFree(schema)
|
| 142 |
+
# define xmlSchematronNewValidCtxt(schema, options) NULL
|
| 143 |
+
# define xmlSchematronValidateDoc(ctxt, doc) 0
|
| 144 |
+
# define xmlSchematronFreeValidCtxt(ctxt)
|
| 145 |
+
# define xmlSchematronSetValidStructuredErrors(ctxt, errorfunc, data)
|
| 146 |
+
#endif
|
| 147 |
+
|
| 148 |
+
#if LIBXML_VERSION < 20708
|
| 149 |
+
# define HTML_PARSE_NODEFDTD 4
|
| 150 |
+
#endif
|
| 151 |
+
#if LIBXML_VERSION < 20900
|
| 152 |
+
# define XML_PARSE_BIG_LINES 4194304
|
| 153 |
+
#endif
|
| 154 |
+
|
| 155 |
+
#include "libxml/tree.h"
|
| 156 |
+
#ifndef LIBXML2_NEW_BUFFER
|
| 157 |
+
typedef xmlBuffer xmlBuf;
|
| 158 |
+
# define xmlBufContent(buf) xmlBufferContent(buf)
|
| 159 |
+
# define xmlBufUse(buf) xmlBufferLength(buf)
|
| 160 |
+
#endif
|
| 161 |
+
|
| 162 |
+
/* libexslt 1.1.25+ support EXSLT functions in XPath */
|
| 163 |
+
#if LIBXSLT_VERSION < 10125
|
| 164 |
+
#define exsltDateXpathCtxtRegister(ctxt, prefix)
|
| 165 |
+
#define exsltSetsXpathCtxtRegister(ctxt, prefix)
|
| 166 |
+
#define exsltMathXpathCtxtRegister(ctxt, prefix)
|
| 167 |
+
#define exsltStrXpathCtxtRegister(ctxt, prefix)
|
| 168 |
+
#endif
|
| 169 |
+
|
| 170 |
+
#define LXML_GET_XSLT_ENCODING(result_var, style) XSLT_GET_IMPORT_PTR(result_var, style, encoding)
|
| 171 |
+
|
| 172 |
+
/* work around MSDEV 6.0 */
|
| 173 |
+
#if (_MSC_VER == 1200) && (WINVER < 0x0500)
|
| 174 |
+
long _ftol( double ); //defined by VC6 C libs
|
| 175 |
+
long _ftol2( double dblSource ) { return _ftol( dblSource ); }
|
| 176 |
+
#endif
|
| 177 |
+
|
| 178 |
+
#ifdef __GNUC__
|
| 179 |
+
/* Test for GCC > 2.95 */
|
| 180 |
+
#if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))
|
| 181 |
+
#define unlikely_condition(x) __builtin_expect((x), 0)
|
| 182 |
+
#else /* __GNUC__ > 2 ... */
|
| 183 |
+
#define unlikely_condition(x) (x)
|
| 184 |
+
#endif /* __GNUC__ > 2 ... */
|
| 185 |
+
#else /* __GNUC__ */
|
| 186 |
+
#define unlikely_condition(x) (x)
|
| 187 |
+
#endif /* __GNUC__ */
|
| 188 |
+
|
| 189 |
+
#ifndef Py_TYPE
|
| 190 |
+
#define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
|
| 191 |
+
#endif
|
| 192 |
+
|
| 193 |
+
#define PY_NEW(T) \
|
| 194 |
+
(((PyTypeObject*)(T))->tp_new( \
|
| 195 |
+
(PyTypeObject*)(T), __pyx_empty_tuple, NULL))
|
| 196 |
+
|
| 197 |
+
#define _fqtypename(o) ((Py_TYPE(o))->tp_name)
|
| 198 |
+
|
| 199 |
+
#define lxml_malloc(count, item_size) \
|
| 200 |
+
(unlikely_condition((size_t)(count) > (size_t) (PY_SSIZE_T_MAX / item_size)) ? NULL : \
|
| 201 |
+
(PyMem_Malloc((count) * item_size)))
|
| 202 |
+
|
| 203 |
+
#define lxml_realloc(mem, count, item_size) \
|
| 204 |
+
(unlikely_condition((size_t)(count) > (size_t) (PY_SSIZE_T_MAX / item_size)) ? NULL : \
|
| 205 |
+
(PyMem_Realloc(mem, (count) * item_size)))
|
| 206 |
+
|
| 207 |
+
#define lxml_free(mem) PyMem_Free(mem)
|
| 208 |
+
|
| 209 |
+
#define _isString(obj) (PyUnicode_Check(obj) || PyBytes_Check(obj))
|
| 210 |
+
|
| 211 |
+
#define _isElement(c_node) \
|
| 212 |
+
(((c_node)->type == XML_ELEMENT_NODE) || \
|
| 213 |
+
((c_node)->type == XML_COMMENT_NODE) || \
|
| 214 |
+
((c_node)->type == XML_ENTITY_REF_NODE) || \
|
| 215 |
+
((c_node)->type == XML_PI_NODE))
|
| 216 |
+
|
| 217 |
+
#define _isElementOrXInclude(c_node) \
|
| 218 |
+
(_isElement(c_node) || \
|
| 219 |
+
((c_node)->type == XML_XINCLUDE_START) || \
|
| 220 |
+
((c_node)->type == XML_XINCLUDE_END))
|
| 221 |
+
|
| 222 |
+
#define _getNs(c_node) \
|
| 223 |
+
(((c_node)->ns == 0) ? 0 : ((c_node)->ns->href))
|
| 224 |
+
|
| 225 |
+
|
| 226 |
+
#include "string.h"
|
| 227 |
+
static void* lxml_unpack_xmldoc_capsule(PyObject* capsule, int* is_owned) {
|
| 228 |
+
xmlDoc *c_doc;
|
| 229 |
+
void *context;
|
| 230 |
+
*is_owned = 0;
|
| 231 |
+
if (unlikely_condition(!PyCapsule_IsValid(capsule, (const char*)"libxml2:xmlDoc"))) {
|
| 232 |
+
PyErr_SetString(
|
| 233 |
+
PyExc_TypeError,
|
| 234 |
+
"Not a valid capsule. The capsule argument must be a capsule object with name libxml2:xmlDoc");
|
| 235 |
+
return NULL;
|
| 236 |
+
}
|
| 237 |
+
c_doc = (xmlDoc*) PyCapsule_GetPointer(capsule, (const char*)"libxml2:xmlDoc");
|
| 238 |
+
if (unlikely_condition(!c_doc)) return NULL;
|
| 239 |
+
|
| 240 |
+
if (unlikely_condition(c_doc->type != XML_DOCUMENT_NODE && c_doc->type != XML_HTML_DOCUMENT_NODE)) {
|
| 241 |
+
PyErr_Format(
|
| 242 |
+
PyExc_ValueError,
|
| 243 |
+
"Illegal document provided: expected XML or HTML, found %d", (int)c_doc->type);
|
| 244 |
+
return NULL;
|
| 245 |
+
}
|
| 246 |
+
|
| 247 |
+
context = PyCapsule_GetContext(capsule);
|
| 248 |
+
if (unlikely_condition(!context && PyErr_Occurred())) return NULL;
|
| 249 |
+
if (context && strcmp((const char*) context, "destructor:xmlFreeDoc") == 0) {
|
| 250 |
+
/* take ownership by setting destructor to NULL */
|
| 251 |
+
if (PyCapsule_SetDestructor(capsule, NULL) == 0) {
|
| 252 |
+
/* ownership transferred => invalidate capsule by clearing its name */
|
| 253 |
+
if (unlikely_condition(PyCapsule_SetName(capsule, NULL))) {
|
| 254 |
+
/* this should never happen since everything above succeeded */
|
| 255 |
+
xmlFreeDoc(c_doc);
|
| 256 |
+
return NULL;
|
| 257 |
+
}
|
| 258 |
+
*is_owned = 1;
|
| 259 |
+
}
|
| 260 |
+
}
|
| 261 |
+
return c_doc;
|
| 262 |
+
}
|
| 263 |
+
|
| 264 |
+
/* Macro pair implementation of a depth first tree walker
|
| 265 |
+
*
|
| 266 |
+
* Calls the code block between the BEGIN and END macros for all elements
|
| 267 |
+
* below c_tree_top (exclusively), starting at c_node (inclusively iff
|
| 268 |
+
* 'inclusive' is 1). The _ELEMENT_ variants will only stop on nodes
|
| 269 |
+
* that match _isElement(), the normal variant will stop on every node
|
| 270 |
+
* except text nodes.
|
| 271 |
+
*
|
| 272 |
+
* To traverse the node and all of its children and siblings in Pyrex, call
|
| 273 |
+
* cdef xmlNode* some_node
|
| 274 |
+
* BEGIN_FOR_EACH_ELEMENT_FROM(some_node.parent, some_node, 1)
|
| 275 |
+
* # do something with some_node
|
| 276 |
+
* END_FOR_EACH_ELEMENT_FROM(some_node)
|
| 277 |
+
*
|
| 278 |
+
* To traverse only the children and siblings of a node, call
|
| 279 |
+
* cdef xmlNode* some_node
|
| 280 |
+
* BEGIN_FOR_EACH_ELEMENT_FROM(some_node.parent, some_node, 0)
|
| 281 |
+
* # do something with some_node
|
| 282 |
+
* END_FOR_EACH_ELEMENT_FROM(some_node)
|
| 283 |
+
*
|
| 284 |
+
* To traverse only the children, do:
|
| 285 |
+
* cdef xmlNode* some_node
|
| 286 |
+
* some_node = parent_node.children
|
| 287 |
+
* BEGIN_FOR_EACH_ELEMENT_FROM(parent_node, some_node, 1)
|
| 288 |
+
* # do something with some_node
|
| 289 |
+
* END_FOR_EACH_ELEMENT_FROM(some_node)
|
| 290 |
+
*
|
| 291 |
+
* NOTE: 'some_node' MUST be a plain 'xmlNode*' !
|
| 292 |
+
*
|
| 293 |
+
* NOTE: parent modification during the walk can divert the iterator, but
|
| 294 |
+
* should not segfault !
|
| 295 |
+
*/
|
| 296 |
+
|
| 297 |
+
#define _LX__ELEMENT_MATCH(c_node, only_elements) \
|
| 298 |
+
((only_elements) ? (_isElement(c_node)) : 1)
|
| 299 |
+
|
| 300 |
+
#define _LX__ADVANCE_TO_NEXT(c_node, only_elements) \
|
| 301 |
+
while ((c_node != 0) && (!_LX__ELEMENT_MATCH(c_node, only_elements))) \
|
| 302 |
+
c_node = c_node->next;
|
| 303 |
+
|
| 304 |
+
#define _LX__TRAVERSE_TO_NEXT(c_stop_node, c_node, only_elements) \
|
| 305 |
+
{ \
|
| 306 |
+
/* walk through children first */ \
|
| 307 |
+
xmlNode* _lx__next = c_node->children; \
|
| 308 |
+
if (_lx__next != 0) { \
|
| 309 |
+
if (c_node->type == XML_ENTITY_REF_NODE || c_node->type == XML_DTD_NODE) { \
|
| 310 |
+
_lx__next = 0; \
|
| 311 |
+
} else { \
|
| 312 |
+
_LX__ADVANCE_TO_NEXT(_lx__next, only_elements) \
|
| 313 |
+
} \
|
| 314 |
+
} \
|
| 315 |
+
if ((_lx__next == 0) && (c_node != c_stop_node)) { \
|
| 316 |
+
/* try siblings */ \
|
| 317 |
+
_lx__next = c_node->next; \
|
| 318 |
+
_LX__ADVANCE_TO_NEXT(_lx__next, only_elements) \
|
| 319 |
+
/* back off through parents */ \
|
| 320 |
+
while (_lx__next == 0) { \
|
| 321 |
+
c_node = c_node->parent; \
|
| 322 |
+
if (c_node == 0) \
|
| 323 |
+
break; \
|
| 324 |
+
if (c_node == c_stop_node) \
|
| 325 |
+
break; \
|
| 326 |
+
if ((only_elements) && !_isElement(c_node)) \
|
| 327 |
+
break; \
|
| 328 |
+
/* we already traversed the parents -> siblings */ \
|
| 329 |
+
_lx__next = c_node->next; \
|
| 330 |
+
_LX__ADVANCE_TO_NEXT(_lx__next, only_elements) \
|
| 331 |
+
} \
|
| 332 |
+
} \
|
| 333 |
+
c_node = _lx__next; \
|
| 334 |
+
}
|
| 335 |
+
|
| 336 |
+
#define _LX__BEGIN_FOR_EACH_FROM(c_tree_top, c_node, inclusive, only_elements) \
|
| 337 |
+
{ \
|
| 338 |
+
if (c_node != 0) { \
|
| 339 |
+
const xmlNode* _lx__tree_top = (c_tree_top); \
|
| 340 |
+
const int _lx__only_elements = (only_elements); \
|
| 341 |
+
/* make sure we start at an element */ \
|
| 342 |
+
if (!_LX__ELEMENT_MATCH(c_node, _lx__only_elements)) { \
|
| 343 |
+
/* we skip the node, so 'inclusive' is irrelevant */ \
|
| 344 |
+
if (c_node == _lx__tree_top) \
|
| 345 |
+
c_node = 0; /* nothing to traverse */ \
|
| 346 |
+
else { \
|
| 347 |
+
c_node = c_node->next; \
|
| 348 |
+
_LX__ADVANCE_TO_NEXT(c_node, _lx__only_elements) \
|
| 349 |
+
} \
|
| 350 |
+
} else if (! (inclusive)) { \
|
| 351 |
+
/* skip the first node */ \
|
| 352 |
+
_LX__TRAVERSE_TO_NEXT(_lx__tree_top, c_node, _lx__only_elements) \
|
| 353 |
+
} \
|
| 354 |
+
\
|
| 355 |
+
/* now run the user code on the elements we find */ \
|
| 356 |
+
while (c_node != 0) { \
|
| 357 |
+
/* here goes the code to be run for each element */
|
| 358 |
+
|
| 359 |
+
#define _LX__END_FOR_EACH_FROM(c_node) \
|
| 360 |
+
_LX__TRAVERSE_TO_NEXT(_lx__tree_top, c_node, _lx__only_elements) \
|
| 361 |
+
} \
|
| 362 |
+
} \
|
| 363 |
+
}
|
| 364 |
+
|
| 365 |
+
|
| 366 |
+
#define BEGIN_FOR_EACH_ELEMENT_FROM(c_tree_top, c_node, inclusive) \
|
| 367 |
+
_LX__BEGIN_FOR_EACH_FROM(c_tree_top, c_node, inclusive, 1)
|
| 368 |
+
|
| 369 |
+
#define END_FOR_EACH_ELEMENT_FROM(c_node) \
|
| 370 |
+
_LX__END_FOR_EACH_FROM(c_node)
|
| 371 |
+
|
| 372 |
+
#define BEGIN_FOR_EACH_FROM(c_tree_top, c_node, inclusive) \
|
| 373 |
+
_LX__BEGIN_FOR_EACH_FROM(c_tree_top, c_node, inclusive, 0)
|
| 374 |
+
|
| 375 |
+
#define END_FOR_EACH_FROM(c_node) \
|
| 376 |
+
_LX__END_FOR_EACH_FROM(c_node)
|
| 377 |
+
|
| 378 |
+
|
| 379 |
+
#endif /* HAS_ETREE_DEFS_H */
|
omnilmm/lib/python3.10/site-packages/lxml/includes/etreepublic.pxd
ADDED
|
@@ -0,0 +1,237 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# public Cython/C interface to lxml.etree
|
| 2 |
+
|
| 3 |
+
from lxml.includes cimport tree
|
| 4 |
+
from lxml.includes.tree cimport const_xmlChar
|
| 5 |
+
|
| 6 |
+
cdef extern from "lxml-version.h":
|
| 7 |
+
cdef char* LXML_VERSION_STRING
|
| 8 |
+
|
| 9 |
+
cdef extern from "etree_defs.h":
|
| 10 |
+
# test if c_node is considered an Element (i.e. Element, Comment, etc.)
|
| 11 |
+
cdef bint _isElement(tree.xmlNode* c_node) noexcept nogil
|
| 12 |
+
|
| 13 |
+
# return the namespace URI of the node or NULL
|
| 14 |
+
cdef const_xmlChar* _getNs(tree.xmlNode* node) noexcept nogil
|
| 15 |
+
|
| 16 |
+
# pair of macros for tree traversal
|
| 17 |
+
cdef void BEGIN_FOR_EACH_ELEMENT_FROM(tree.xmlNode* tree_top,
|
| 18 |
+
tree.xmlNode* start_node,
|
| 19 |
+
int start_node_inclusive) noexcept nogil
|
| 20 |
+
cdef void END_FOR_EACH_ELEMENT_FROM(tree.xmlNode* start_node) noexcept nogil
|
| 21 |
+
|
| 22 |
+
cdef extern from "etree_api.h":
|
| 23 |
+
|
| 24 |
+
# first function to call!
|
| 25 |
+
cdef int import_lxml__etree() except -1
|
| 26 |
+
|
| 27 |
+
##########################################################################
|
| 28 |
+
# public ElementTree API classes
|
| 29 |
+
|
| 30 |
+
cdef class lxml.etree._Document [ object LxmlDocument ]:
|
| 31 |
+
cdef tree.xmlDoc* _c_doc
|
| 32 |
+
|
| 33 |
+
cdef class lxml.etree._Element [ object LxmlElement ]:
|
| 34 |
+
cdef _Document _doc
|
| 35 |
+
cdef tree.xmlNode* _c_node
|
| 36 |
+
|
| 37 |
+
cdef class lxml.etree.ElementBase(_Element) [ object LxmlElementBase ]:
|
| 38 |
+
pass
|
| 39 |
+
|
| 40 |
+
cdef class lxml.etree._ElementTree [ object LxmlElementTree ]:
|
| 41 |
+
cdef _Document _doc
|
| 42 |
+
cdef _Element _context_node
|
| 43 |
+
|
| 44 |
+
cdef class lxml.etree.ElementClassLookup [ object LxmlElementClassLookup ]:
|
| 45 |
+
cdef object (*_lookup_function)(object, _Document, tree.xmlNode*)
|
| 46 |
+
|
| 47 |
+
cdef class lxml.etree.FallbackElementClassLookup(ElementClassLookup) \
|
| 48 |
+
[ object LxmlFallbackElementClassLookup ]:
|
| 49 |
+
cdef ElementClassLookup fallback
|
| 50 |
+
cdef object (*_fallback_function)(object, _Document, tree.xmlNode*)
|
| 51 |
+
|
| 52 |
+
##########################################################################
|
| 53 |
+
# creating Element objects
|
| 54 |
+
|
| 55 |
+
# create an Element for a C-node in the Document
|
| 56 |
+
cdef _Element elementFactory(_Document doc, tree.xmlNode* c_node)
|
| 57 |
+
|
| 58 |
+
# create an ElementTree for an Element
|
| 59 |
+
cdef _ElementTree elementTreeFactory(_Element context_node)
|
| 60 |
+
|
| 61 |
+
# create an ElementTree subclass for an Element
|
| 62 |
+
cdef _ElementTree newElementTree(_Element context_node, object subclass)
|
| 63 |
+
|
| 64 |
+
# create an ElementTree from an external document
|
| 65 |
+
cdef _ElementTree adoptExternalDocument(tree.xmlDoc* c_doc, parser, bint is_owned)
|
| 66 |
+
|
| 67 |
+
# create a new Element for an existing or new document (doc = None)
|
| 68 |
+
# builds Python object after setting text, tail, namespaces and attributes
|
| 69 |
+
cdef _Element makeElement(tag, _Document doc, parser,
|
| 70 |
+
text, tail, attrib, nsmap)
|
| 71 |
+
|
| 72 |
+
# create a new SubElement for an existing parent
|
| 73 |
+
# builds Python object after setting text, tail, namespaces and attributes
|
| 74 |
+
cdef _Element makeSubElement(_Element parent, tag, text, tail,
|
| 75 |
+
attrib, nsmap)
|
| 76 |
+
|
| 77 |
+
# deep copy a node to include it in the Document
|
| 78 |
+
cdef _Element deepcopyNodeToDocument(_Document doc, tree.xmlNode* c_root)
|
| 79 |
+
|
| 80 |
+
# set the internal lookup function for Element/Comment/PI classes
|
| 81 |
+
# use setElementClassLookupFunction(NULL, None) to reset it
|
| 82 |
+
# note that the lookup function *must always* return an _Element subclass!
|
| 83 |
+
cdef void setElementClassLookupFunction(
|
| 84 |
+
object (*function)(object, _Document, tree.xmlNode*), object state)
|
| 85 |
+
|
| 86 |
+
# lookup function that always returns the default Element class
|
| 87 |
+
# note that the first argument is expected to be None!
|
| 88 |
+
cdef object lookupDefaultElementClass(_1, _Document _2,
|
| 89 |
+
tree.xmlNode* c_node)
|
| 90 |
+
|
| 91 |
+
# lookup function for namespace/tag specific Element classes
|
| 92 |
+
# note that the first argument is expected to be None!
|
| 93 |
+
cdef object lookupNamespaceElementClass(_1, _Document _2,
|
| 94 |
+
tree.xmlNode* c_node)
|
| 95 |
+
|
| 96 |
+
# call the fallback lookup function of a FallbackElementClassLookup
|
| 97 |
+
cdef object callLookupFallback(FallbackElementClassLookup lookup,
|
| 98 |
+
_Document doc, tree.xmlNode* c_node)
|
| 99 |
+
|
| 100 |
+
##########################################################################
|
| 101 |
+
# XML attribute access
|
| 102 |
+
|
| 103 |
+
# return an attribute value for a C attribute on a C element node
|
| 104 |
+
cdef unicode attributeValue(tree.xmlNode* c_element,
|
| 105 |
+
tree.xmlAttr* c_attrib_node)
|
| 106 |
+
|
| 107 |
+
# return the value of the attribute with 'ns' and 'name' (or None)
|
| 108 |
+
cdef unicode attributeValueFromNsName(tree.xmlNode* c_element,
|
| 109 |
+
const_xmlChar* c_ns, const_xmlChar* c_name)
|
| 110 |
+
|
| 111 |
+
# return the value of attribute "{ns}name", or the default value
|
| 112 |
+
cdef object getAttributeValue(_Element element, key, default)
|
| 113 |
+
|
| 114 |
+
# return an iterator over attribute names (1), values (2) or items (3)
|
| 115 |
+
# attributes must not be removed during iteration!
|
| 116 |
+
cdef object iterattributes(_Element element, int keysvalues)
|
| 117 |
+
|
| 118 |
+
# return the list of all attribute names (1), values (2) or items (3)
|
| 119 |
+
cdef list collectAttributes(tree.xmlNode* c_element, int keysvalues)
|
| 120 |
+
|
| 121 |
+
# set an attribute value on an element
|
| 122 |
+
# on failure, sets an exception and returns -1
|
| 123 |
+
cdef int setAttributeValue(_Element element, key, value) except -1
|
| 124 |
+
|
| 125 |
+
# delete an attribute
|
| 126 |
+
# on failure, sets an exception and returns -1
|
| 127 |
+
cdef int delAttribute(_Element element, key) except -1
|
| 128 |
+
|
| 129 |
+
# delete an attribute based on name and namespace URI
|
| 130 |
+
# returns -1 if the attribute was not found (no exception)
|
| 131 |
+
cdef int delAttributeFromNsName(tree.xmlNode* c_element,
|
| 132 |
+
const_xmlChar* c_href, const_xmlChar* c_name) noexcept
|
| 133 |
+
|
| 134 |
+
##########################################################################
|
| 135 |
+
# XML node helper functions
|
| 136 |
+
|
| 137 |
+
# check if the element has at least one child
|
| 138 |
+
cdef bint hasChild(tree.xmlNode* c_node) noexcept nogil
|
| 139 |
+
|
| 140 |
+
# find child element number 'index' (supports negative indexes)
|
| 141 |
+
cdef tree.xmlNode* findChild(tree.xmlNode* c_node,
|
| 142 |
+
Py_ssize_t index) noexcept nogil
|
| 143 |
+
|
| 144 |
+
# find child element number 'index' starting at first one
|
| 145 |
+
cdef tree.xmlNode* findChildForwards(tree.xmlNode* c_node,
|
| 146 |
+
Py_ssize_t index) nogil
|
| 147 |
+
|
| 148 |
+
# find child element number 'index' starting at last one
|
| 149 |
+
cdef tree.xmlNode* findChildBackwards(tree.xmlNode* c_node,
|
| 150 |
+
Py_ssize_t index) nogil
|
| 151 |
+
|
| 152 |
+
# return next/previous sibling element of the node
|
| 153 |
+
cdef tree.xmlNode* nextElement(tree.xmlNode* c_node) nogil
|
| 154 |
+
cdef tree.xmlNode* previousElement(tree.xmlNode* c_node) nogil
|
| 155 |
+
|
| 156 |
+
##########################################################################
|
| 157 |
+
# iterators (DEPRECATED API, don't use in new code!)
|
| 158 |
+
|
| 159 |
+
cdef class lxml.etree._ElementTagMatcher [ object LxmlElementTagMatcher ]:
|
| 160 |
+
cdef char* _href
|
| 161 |
+
cdef char* _name
|
| 162 |
+
|
| 163 |
+
# store "{ns}tag" (or None) filter for this matcher or element iterator
|
| 164 |
+
# ** unless _href *and* _name are set up 'by hand', this function *must*
|
| 165 |
+
# ** be called when subclassing the iterator below!
|
| 166 |
+
cdef void initTagMatch(_ElementTagMatcher matcher, tag)
|
| 167 |
+
|
| 168 |
+
cdef class lxml.etree._ElementIterator(_ElementTagMatcher) [
|
| 169 |
+
object LxmlElementIterator ]:
|
| 170 |
+
cdef _Element _node
|
| 171 |
+
cdef tree.xmlNode* (*_next_element)(tree.xmlNode*)
|
| 172 |
+
|
| 173 |
+
# store the initial node of the iterator if it matches the required tag
|
| 174 |
+
# or its next matching sibling if not
|
| 175 |
+
cdef void iteratorStoreNext(_ElementIterator iterator, _Element node)
|
| 176 |
+
|
| 177 |
+
##########################################################################
|
| 178 |
+
# other helper functions
|
| 179 |
+
|
| 180 |
+
# check if a C node matches a tag name and namespace
|
| 181 |
+
# (NULL allowed for each => always matches)
|
| 182 |
+
cdef int tagMatches(tree.xmlNode* c_node, const_xmlChar* c_href, const_xmlChar* c_name)
|
| 183 |
+
|
| 184 |
+
# convert a UTF-8 char* to a Python unicode string
|
| 185 |
+
cdef unicode pyunicode(const_xmlChar* s)
|
| 186 |
+
|
| 187 |
+
# convert the string to UTF-8 using the normal lxml.etree semantics
|
| 188 |
+
cdef bytes utf8(object s)
|
| 189 |
+
|
| 190 |
+
# split a tag into a (URI, name) tuple, return None as URI for '{}tag'
|
| 191 |
+
cdef tuple getNsTag(object tag)
|
| 192 |
+
|
| 193 |
+
# split a tag into a (URI, name) tuple, return b'' as URI for '{}tag'
|
| 194 |
+
cdef tuple getNsTagWithEmptyNs(object tag)
|
| 195 |
+
|
| 196 |
+
# get the "{ns}tag" string for a C node
|
| 197 |
+
cdef unicode namespacedName(tree.xmlNode* c_node)
|
| 198 |
+
|
| 199 |
+
# get the "{ns}tag" string for a href/tagname pair (c_ns may be NULL)
|
| 200 |
+
cdef unicode namespacedNameFromNsName(const_xmlChar* c_ns, const_xmlChar* c_tag)
|
| 201 |
+
|
| 202 |
+
# check if the node has a text value (which may be '')
|
| 203 |
+
cdef bint hasText(tree.xmlNode* c_node) nogil
|
| 204 |
+
|
| 205 |
+
# check if the node has a tail value (which may be '')
|
| 206 |
+
cdef bint hasTail(tree.xmlNode* c_node) nogil
|
| 207 |
+
|
| 208 |
+
# get the text content of an element (or None)
|
| 209 |
+
cdef unicode textOf(tree.xmlNode* c_node)
|
| 210 |
+
|
| 211 |
+
# get the tail content of an element (or None)
|
| 212 |
+
cdef unicode tailOf(tree.xmlNode* c_node)
|
| 213 |
+
|
| 214 |
+
# set the text value of an element
|
| 215 |
+
cdef int setNodeText(tree.xmlNode* c_node, text) except -1
|
| 216 |
+
|
| 217 |
+
# set the tail text value of an element
|
| 218 |
+
cdef int setTailText(tree.xmlNode* c_node, text) except -1
|
| 219 |
+
|
| 220 |
+
# append an element to the children of a parent element
|
| 221 |
+
# deprecated: don't use, does not propagate exceptions!
|
| 222 |
+
# use appendChildToElement() instead
|
| 223 |
+
cdef void appendChild(_Element parent, _Element child)
|
| 224 |
+
|
| 225 |
+
# added in lxml 3.3 as a safe replacement for appendChild()
|
| 226 |
+
# return -1 for exception, 0 for ok
|
| 227 |
+
cdef int appendChildToElement(_Element parent, _Element child) except -1
|
| 228 |
+
|
| 229 |
+
# recursively lookup a namespace in element or ancestors, or create it
|
| 230 |
+
cdef tree.xmlNs* findOrBuildNodeNsPrefix(
|
| 231 |
+
_Document doc, tree.xmlNode* c_node, const_xmlChar* href, const_xmlChar* prefix)
|
| 232 |
+
|
| 233 |
+
# find the Document of an Element, ElementTree or Document (itself!)
|
| 234 |
+
cdef _Document documentOrRaise(object input)
|
| 235 |
+
|
| 236 |
+
# find the root Element of an Element (itself!), ElementTree or Document
|
| 237 |
+
cdef _Element rootNodeOrRaise(object input)
|
omnilmm/lib/python3.10/site-packages/lxml/includes/htmlparser.pxd
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from libc.string cimport const_char
|
| 2 |
+
|
| 3 |
+
from lxml.includes.tree cimport xmlDoc
|
| 4 |
+
from lxml.includes.tree cimport xmlInputReadCallback, xmlInputCloseCallback
|
| 5 |
+
from lxml.includes.xmlparser cimport xmlParserCtxt, xmlSAXHandler, xmlSAXHandlerV1
|
| 6 |
+
|
| 7 |
+
cdef extern from "libxml/HTMLparser.h" nogil:
|
| 8 |
+
ctypedef enum htmlParserOption:
|
| 9 |
+
HTML_PARSE_NOERROR # suppress error reports
|
| 10 |
+
HTML_PARSE_NOWARNING # suppress warning reports
|
| 11 |
+
HTML_PARSE_PEDANTIC # pedantic error reporting
|
| 12 |
+
HTML_PARSE_NOBLANKS # remove blank nodes
|
| 13 |
+
HTML_PARSE_NONET # Forbid network access
|
| 14 |
+
# libxml2 2.6.21+ only:
|
| 15 |
+
HTML_PARSE_RECOVER # Relaxed parsing
|
| 16 |
+
HTML_PARSE_COMPACT # compact small text nodes
|
| 17 |
+
# libxml2 2.7.7+ only:
|
| 18 |
+
HTML_PARSE_NOIMPLIED # Do not add implied html/body... elements
|
| 19 |
+
# libxml2 2.7.8+ only:
|
| 20 |
+
HTML_PARSE_NODEFDTD # do not default a doctype if not found
|
| 21 |
+
# libxml2 2.8.0+ only:
|
| 22 |
+
XML_PARSE_IGNORE_ENC # ignore internal document encoding hint
|
| 23 |
+
|
| 24 |
+
xmlSAXHandlerV1 htmlDefaultSAXHandler
|
| 25 |
+
|
| 26 |
+
cdef xmlParserCtxt* htmlCreateMemoryParserCtxt(
|
| 27 |
+
char* buffer, int size)
|
| 28 |
+
cdef xmlParserCtxt* htmlCreateFileParserCtxt(
|
| 29 |
+
char* filename, char* encoding)
|
| 30 |
+
cdef xmlParserCtxt* htmlCreatePushParserCtxt(xmlSAXHandler* sax,
|
| 31 |
+
void* user_data,
|
| 32 |
+
char* chunk, int size,
|
| 33 |
+
char* filename, int enc)
|
| 34 |
+
cdef void htmlFreeParserCtxt(xmlParserCtxt* ctxt)
|
| 35 |
+
cdef void htmlCtxtReset(xmlParserCtxt* ctxt)
|
| 36 |
+
cdef int htmlCtxtUseOptions(xmlParserCtxt* ctxt, int options)
|
| 37 |
+
cdef int htmlParseDocument(xmlParserCtxt* ctxt)
|
| 38 |
+
cdef int htmlParseChunk(xmlParserCtxt* ctxt,
|
| 39 |
+
char* chunk, int size, int terminate)
|
| 40 |
+
|
| 41 |
+
cdef xmlDoc* htmlCtxtReadFile(xmlParserCtxt* ctxt,
|
| 42 |
+
char* filename, const_char* encoding,
|
| 43 |
+
int options)
|
| 44 |
+
cdef xmlDoc* htmlCtxtReadDoc(xmlParserCtxt* ctxt,
|
| 45 |
+
char* buffer, char* URL, const_char* encoding,
|
| 46 |
+
int options)
|
| 47 |
+
cdef xmlDoc* htmlCtxtReadIO(xmlParserCtxt* ctxt,
|
| 48 |
+
xmlInputReadCallback ioread,
|
| 49 |
+
xmlInputCloseCallback ioclose,
|
| 50 |
+
void* ioctx,
|
| 51 |
+
char* URL, const_char* encoding,
|
| 52 |
+
int options)
|
| 53 |
+
cdef xmlDoc* htmlCtxtReadMemory(xmlParserCtxt* ctxt,
|
| 54 |
+
char* buffer, int size,
|
| 55 |
+
char* filename, const_char* encoding,
|
| 56 |
+
int options)
|
omnilmm/lib/python3.10/site-packages/lxml/includes/libxml/SAX2.h
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Summary: SAX2 parser interface used to build the DOM tree
|
| 3 |
+
* Description: those are the default SAX2 interfaces used by
|
| 4 |
+
* the library when building DOM tree.
|
| 5 |
+
*
|
| 6 |
+
* Copy: See Copyright for the status of this software.
|
| 7 |
+
*
|
| 8 |
+
* Author: Daniel Veillard
|
| 9 |
+
*/
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
#ifndef __XML_SAX2_H__
|
| 13 |
+
#define __XML_SAX2_H__
|
| 14 |
+
|
| 15 |
+
#include <libxml/xmlversion.h>
|
| 16 |
+
#include <libxml/parser.h>
|
| 17 |
+
|
| 18 |
+
#ifdef __cplusplus
|
| 19 |
+
extern "C" {
|
| 20 |
+
#endif
|
| 21 |
+
XMLPUBFUN const xmlChar *
|
| 22 |
+
xmlSAX2GetPublicId (void *ctx);
|
| 23 |
+
XMLPUBFUN const xmlChar *
|
| 24 |
+
xmlSAX2GetSystemId (void *ctx);
|
| 25 |
+
XMLPUBFUN void
|
| 26 |
+
xmlSAX2SetDocumentLocator (void *ctx,
|
| 27 |
+
xmlSAXLocatorPtr loc);
|
| 28 |
+
|
| 29 |
+
XMLPUBFUN int
|
| 30 |
+
xmlSAX2GetLineNumber (void *ctx);
|
| 31 |
+
XMLPUBFUN int
|
| 32 |
+
xmlSAX2GetColumnNumber (void *ctx);
|
| 33 |
+
|
| 34 |
+
XMLPUBFUN int
|
| 35 |
+
xmlSAX2IsStandalone (void *ctx);
|
| 36 |
+
XMLPUBFUN int
|
| 37 |
+
xmlSAX2HasInternalSubset (void *ctx);
|
| 38 |
+
XMLPUBFUN int
|
| 39 |
+
xmlSAX2HasExternalSubset (void *ctx);
|
| 40 |
+
|
| 41 |
+
XMLPUBFUN void
|
| 42 |
+
xmlSAX2InternalSubset (void *ctx,
|
| 43 |
+
const xmlChar *name,
|
| 44 |
+
const xmlChar *ExternalID,
|
| 45 |
+
const xmlChar *SystemID);
|
| 46 |
+
XMLPUBFUN void
|
| 47 |
+
xmlSAX2ExternalSubset (void *ctx,
|
| 48 |
+
const xmlChar *name,
|
| 49 |
+
const xmlChar *ExternalID,
|
| 50 |
+
const xmlChar *SystemID);
|
| 51 |
+
XMLPUBFUN xmlEntityPtr
|
| 52 |
+
xmlSAX2GetEntity (void *ctx,
|
| 53 |
+
const xmlChar *name);
|
| 54 |
+
XMLPUBFUN xmlEntityPtr
|
| 55 |
+
xmlSAX2GetParameterEntity (void *ctx,
|
| 56 |
+
const xmlChar *name);
|
| 57 |
+
XMLPUBFUN xmlParserInputPtr
|
| 58 |
+
xmlSAX2ResolveEntity (void *ctx,
|
| 59 |
+
const xmlChar *publicId,
|
| 60 |
+
const xmlChar *systemId);
|
| 61 |
+
|
| 62 |
+
XMLPUBFUN void
|
| 63 |
+
xmlSAX2EntityDecl (void *ctx,
|
| 64 |
+
const xmlChar *name,
|
| 65 |
+
int type,
|
| 66 |
+
const xmlChar *publicId,
|
| 67 |
+
const xmlChar *systemId,
|
| 68 |
+
xmlChar *content);
|
| 69 |
+
XMLPUBFUN void
|
| 70 |
+
xmlSAX2AttributeDecl (void *ctx,
|
| 71 |
+
const xmlChar *elem,
|
| 72 |
+
const xmlChar *fullname,
|
| 73 |
+
int type,
|
| 74 |
+
int def,
|
| 75 |
+
const xmlChar *defaultValue,
|
| 76 |
+
xmlEnumerationPtr tree);
|
| 77 |
+
XMLPUBFUN void
|
| 78 |
+
xmlSAX2ElementDecl (void *ctx,
|
| 79 |
+
const xmlChar *name,
|
| 80 |
+
int type,
|
| 81 |
+
xmlElementContentPtr content);
|
| 82 |
+
XMLPUBFUN void
|
| 83 |
+
xmlSAX2NotationDecl (void *ctx,
|
| 84 |
+
const xmlChar *name,
|
| 85 |
+
const xmlChar *publicId,
|
| 86 |
+
const xmlChar *systemId);
|
| 87 |
+
XMLPUBFUN void
|
| 88 |
+
xmlSAX2UnparsedEntityDecl (void *ctx,
|
| 89 |
+
const xmlChar *name,
|
| 90 |
+
const xmlChar *publicId,
|
| 91 |
+
const xmlChar *systemId,
|
| 92 |
+
const xmlChar *notationName);
|
| 93 |
+
|
| 94 |
+
XMLPUBFUN void
|
| 95 |
+
xmlSAX2StartDocument (void *ctx);
|
| 96 |
+
XMLPUBFUN void
|
| 97 |
+
xmlSAX2EndDocument (void *ctx);
|
| 98 |
+
#if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || \
|
| 99 |
+
defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_LEGACY_ENABLED)
|
| 100 |
+
XMLPUBFUN void
|
| 101 |
+
xmlSAX2StartElement (void *ctx,
|
| 102 |
+
const xmlChar *fullname,
|
| 103 |
+
const xmlChar **atts);
|
| 104 |
+
XMLPUBFUN void
|
| 105 |
+
xmlSAX2EndElement (void *ctx,
|
| 106 |
+
const xmlChar *name);
|
| 107 |
+
#endif /* LIBXML_SAX1_ENABLED or LIBXML_HTML_ENABLED or LIBXML_LEGACY_ENABLED */
|
| 108 |
+
XMLPUBFUN void
|
| 109 |
+
xmlSAX2StartElementNs (void *ctx,
|
| 110 |
+
const xmlChar *localname,
|
| 111 |
+
const xmlChar *prefix,
|
| 112 |
+
const xmlChar *URI,
|
| 113 |
+
int nb_namespaces,
|
| 114 |
+
const xmlChar **namespaces,
|
| 115 |
+
int nb_attributes,
|
| 116 |
+
int nb_defaulted,
|
| 117 |
+
const xmlChar **attributes);
|
| 118 |
+
XMLPUBFUN void
|
| 119 |
+
xmlSAX2EndElementNs (void *ctx,
|
| 120 |
+
const xmlChar *localname,
|
| 121 |
+
const xmlChar *prefix,
|
| 122 |
+
const xmlChar *URI);
|
| 123 |
+
XMLPUBFUN void
|
| 124 |
+
xmlSAX2Reference (void *ctx,
|
| 125 |
+
const xmlChar *name);
|
| 126 |
+
XMLPUBFUN void
|
| 127 |
+
xmlSAX2Characters (void *ctx,
|
| 128 |
+
const xmlChar *ch,
|
| 129 |
+
int len);
|
| 130 |
+
XMLPUBFUN void
|
| 131 |
+
xmlSAX2IgnorableWhitespace (void *ctx,
|
| 132 |
+
const xmlChar *ch,
|
| 133 |
+
int len);
|
| 134 |
+
XMLPUBFUN void
|
| 135 |
+
xmlSAX2ProcessingInstruction (void *ctx,
|
| 136 |
+
const xmlChar *target,
|
| 137 |
+
const xmlChar *data);
|
| 138 |
+
XMLPUBFUN void
|
| 139 |
+
xmlSAX2Comment (void *ctx,
|
| 140 |
+
const xmlChar *value);
|
| 141 |
+
XMLPUBFUN void
|
| 142 |
+
xmlSAX2CDataBlock (void *ctx,
|
| 143 |
+
const xmlChar *value,
|
| 144 |
+
int len);
|
| 145 |
+
|
| 146 |
+
#ifdef LIBXML_SAX1_ENABLED
|
| 147 |
+
XML_DEPRECATED
|
| 148 |
+
XMLPUBFUN int
|
| 149 |
+
xmlSAXDefaultVersion (int version);
|
| 150 |
+
#endif /* LIBXML_SAX1_ENABLED */
|
| 151 |
+
|
| 152 |
+
XMLPUBFUN int
|
| 153 |
+
xmlSAXVersion (xmlSAXHandler *hdlr,
|
| 154 |
+
int version);
|
| 155 |
+
XMLPUBFUN void
|
| 156 |
+
xmlSAX2InitDefaultSAXHandler (xmlSAXHandler *hdlr,
|
| 157 |
+
int warning);
|
| 158 |
+
#ifdef LIBXML_HTML_ENABLED
|
| 159 |
+
XMLPUBFUN void
|
| 160 |
+
xmlSAX2InitHtmlDefaultSAXHandler(xmlSAXHandler *hdlr);
|
| 161 |
+
XML_DEPRECATED
|
| 162 |
+
XMLPUBFUN void
|
| 163 |
+
htmlDefaultSAXHandlerInit (void);
|
| 164 |
+
#endif
|
| 165 |
+
XML_DEPRECATED
|
| 166 |
+
XMLPUBFUN void
|
| 167 |
+
xmlDefaultSAXHandlerInit (void);
|
| 168 |
+
#ifdef __cplusplus
|
| 169 |
+
}
|
| 170 |
+
#endif
|
| 171 |
+
#endif /* __XML_SAX2_H__ */
|
omnilmm/lib/python3.10/site-packages/lxml/includes/libxml/entities.h
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Summary: interface for the XML entities handling
|
| 3 |
+
* Description: this module provides some of the entity API needed
|
| 4 |
+
* for the parser and applications.
|
| 5 |
+
*
|
| 6 |
+
* Copy: See Copyright for the status of this software.
|
| 7 |
+
*
|
| 8 |
+
* Author: Daniel Veillard
|
| 9 |
+
*/
|
| 10 |
+
|
| 11 |
+
#ifndef __XML_ENTITIES_H__
|
| 12 |
+
#define __XML_ENTITIES_H__
|
| 13 |
+
|
| 14 |
+
#include <libxml/xmlversion.h>
|
| 15 |
+
#define XML_TREE_INTERNALS
|
| 16 |
+
#include <libxml/tree.h>
|
| 17 |
+
#undef XML_TREE_INTERNALS
|
| 18 |
+
|
| 19 |
+
#ifdef __cplusplus
|
| 20 |
+
extern "C" {
|
| 21 |
+
#endif
|
| 22 |
+
|
| 23 |
+
/*
|
| 24 |
+
* The different valid entity types.
|
| 25 |
+
*/
|
| 26 |
+
typedef enum {
|
| 27 |
+
XML_INTERNAL_GENERAL_ENTITY = 1,
|
| 28 |
+
XML_EXTERNAL_GENERAL_PARSED_ENTITY = 2,
|
| 29 |
+
XML_EXTERNAL_GENERAL_UNPARSED_ENTITY = 3,
|
| 30 |
+
XML_INTERNAL_PARAMETER_ENTITY = 4,
|
| 31 |
+
XML_EXTERNAL_PARAMETER_ENTITY = 5,
|
| 32 |
+
XML_INTERNAL_PREDEFINED_ENTITY = 6
|
| 33 |
+
} xmlEntityType;
|
| 34 |
+
|
| 35 |
+
/*
|
| 36 |
+
* An unit of storage for an entity, contains the string, the value
|
| 37 |
+
* and the linkind data needed for the linking in the hash table.
|
| 38 |
+
*/
|
| 39 |
+
|
| 40 |
+
struct _xmlEntity {
|
| 41 |
+
void *_private; /* application data */
|
| 42 |
+
xmlElementType type; /* XML_ENTITY_DECL, must be second ! */
|
| 43 |
+
const xmlChar *name; /* Entity name */
|
| 44 |
+
struct _xmlNode *children; /* First child link */
|
| 45 |
+
struct _xmlNode *last; /* Last child link */
|
| 46 |
+
struct _xmlDtd *parent; /* -> DTD */
|
| 47 |
+
struct _xmlNode *next; /* next sibling link */
|
| 48 |
+
struct _xmlNode *prev; /* previous sibling link */
|
| 49 |
+
struct _xmlDoc *doc; /* the containing document */
|
| 50 |
+
|
| 51 |
+
xmlChar *orig; /* content without ref substitution */
|
| 52 |
+
xmlChar *content; /* content or ndata if unparsed */
|
| 53 |
+
int length; /* the content length */
|
| 54 |
+
xmlEntityType etype; /* The entity type */
|
| 55 |
+
const xmlChar *ExternalID; /* External identifier for PUBLIC */
|
| 56 |
+
const xmlChar *SystemID; /* URI for a SYSTEM or PUBLIC Entity */
|
| 57 |
+
|
| 58 |
+
struct _xmlEntity *nexte; /* unused */
|
| 59 |
+
const xmlChar *URI; /* the full URI as computed */
|
| 60 |
+
int owner; /* does the entity own the childrens */
|
| 61 |
+
int flags; /* various flags */
|
| 62 |
+
unsigned long expandedSize; /* expanded size */
|
| 63 |
+
};
|
| 64 |
+
|
| 65 |
+
/*
|
| 66 |
+
* All entities are stored in an hash table.
|
| 67 |
+
* There is 2 separate hash tables for global and parameter entities.
|
| 68 |
+
*/
|
| 69 |
+
|
| 70 |
+
typedef struct _xmlHashTable xmlEntitiesTable;
|
| 71 |
+
typedef xmlEntitiesTable *xmlEntitiesTablePtr;
|
| 72 |
+
|
| 73 |
+
/*
|
| 74 |
+
* External functions:
|
| 75 |
+
*/
|
| 76 |
+
|
| 77 |
+
#ifdef LIBXML_LEGACY_ENABLED
|
| 78 |
+
XML_DEPRECATED
|
| 79 |
+
XMLPUBFUN void
|
| 80 |
+
xmlInitializePredefinedEntities (void);
|
| 81 |
+
#endif /* LIBXML_LEGACY_ENABLED */
|
| 82 |
+
|
| 83 |
+
XMLPUBFUN xmlEntityPtr
|
| 84 |
+
xmlNewEntity (xmlDocPtr doc,
|
| 85 |
+
const xmlChar *name,
|
| 86 |
+
int type,
|
| 87 |
+
const xmlChar *ExternalID,
|
| 88 |
+
const xmlChar *SystemID,
|
| 89 |
+
const xmlChar *content);
|
| 90 |
+
XMLPUBFUN void
|
| 91 |
+
xmlFreeEntity (xmlEntityPtr entity);
|
| 92 |
+
XMLPUBFUN xmlEntityPtr
|
| 93 |
+
xmlAddDocEntity (xmlDocPtr doc,
|
| 94 |
+
const xmlChar *name,
|
| 95 |
+
int type,
|
| 96 |
+
const xmlChar *ExternalID,
|
| 97 |
+
const xmlChar *SystemID,
|
| 98 |
+
const xmlChar *content);
|
| 99 |
+
XMLPUBFUN xmlEntityPtr
|
| 100 |
+
xmlAddDtdEntity (xmlDocPtr doc,
|
| 101 |
+
const xmlChar *name,
|
| 102 |
+
int type,
|
| 103 |
+
const xmlChar *ExternalID,
|
| 104 |
+
const xmlChar *SystemID,
|
| 105 |
+
const xmlChar *content);
|
| 106 |
+
XMLPUBFUN xmlEntityPtr
|
| 107 |
+
xmlGetPredefinedEntity (const xmlChar *name);
|
| 108 |
+
XMLPUBFUN xmlEntityPtr
|
| 109 |
+
xmlGetDocEntity (const xmlDoc *doc,
|
| 110 |
+
const xmlChar *name);
|
| 111 |
+
XMLPUBFUN xmlEntityPtr
|
| 112 |
+
xmlGetDtdEntity (xmlDocPtr doc,
|
| 113 |
+
const xmlChar *name);
|
| 114 |
+
XMLPUBFUN xmlEntityPtr
|
| 115 |
+
xmlGetParameterEntity (xmlDocPtr doc,
|
| 116 |
+
const xmlChar *name);
|
| 117 |
+
#ifdef LIBXML_LEGACY_ENABLED
|
| 118 |
+
XML_DEPRECATED
|
| 119 |
+
XMLPUBFUN const xmlChar *
|
| 120 |
+
xmlEncodeEntities (xmlDocPtr doc,
|
| 121 |
+
const xmlChar *input);
|
| 122 |
+
#endif /* LIBXML_LEGACY_ENABLED */
|
| 123 |
+
XMLPUBFUN xmlChar *
|
| 124 |
+
xmlEncodeEntitiesReentrant(xmlDocPtr doc,
|
| 125 |
+
const xmlChar *input);
|
| 126 |
+
XMLPUBFUN xmlChar *
|
| 127 |
+
xmlEncodeSpecialChars (const xmlDoc *doc,
|
| 128 |
+
const xmlChar *input);
|
| 129 |
+
XMLPUBFUN xmlEntitiesTablePtr
|
| 130 |
+
xmlCreateEntitiesTable (void);
|
| 131 |
+
#ifdef LIBXML_TREE_ENABLED
|
| 132 |
+
XMLPUBFUN xmlEntitiesTablePtr
|
| 133 |
+
xmlCopyEntitiesTable (xmlEntitiesTablePtr table);
|
| 134 |
+
#endif /* LIBXML_TREE_ENABLED */
|
| 135 |
+
XMLPUBFUN void
|
| 136 |
+
xmlFreeEntitiesTable (xmlEntitiesTablePtr table);
|
| 137 |
+
#ifdef LIBXML_OUTPUT_ENABLED
|
| 138 |
+
XMLPUBFUN void
|
| 139 |
+
xmlDumpEntitiesTable (xmlBufferPtr buf,
|
| 140 |
+
xmlEntitiesTablePtr table);
|
| 141 |
+
XMLPUBFUN void
|
| 142 |
+
xmlDumpEntityDecl (xmlBufferPtr buf,
|
| 143 |
+
xmlEntityPtr ent);
|
| 144 |
+
#endif /* LIBXML_OUTPUT_ENABLED */
|
| 145 |
+
#ifdef LIBXML_LEGACY_ENABLED
|
| 146 |
+
XMLPUBFUN void
|
| 147 |
+
xmlCleanupPredefinedEntities(void);
|
| 148 |
+
#endif /* LIBXML_LEGACY_ENABLED */
|
| 149 |
+
|
| 150 |
+
|
| 151 |
+
#ifdef __cplusplus
|
| 152 |
+
}
|
| 153 |
+
#endif
|
| 154 |
+
|
| 155 |
+
# endif /* __XML_ENTITIES_H__ */
|
omnilmm/lib/python3.10/site-packages/lxml/includes/libxml/parserInternals.h
ADDED
|
@@ -0,0 +1,663 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Summary: internals routines and limits exported by the parser.
|
| 3 |
+
* Description: this module exports a number of internal parsing routines
|
| 4 |
+
* they are not really all intended for applications but
|
| 5 |
+
* can prove useful doing low level processing.
|
| 6 |
+
*
|
| 7 |
+
* Copy: See Copyright for the status of this software.
|
| 8 |
+
*
|
| 9 |
+
* Author: Daniel Veillard
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
#ifndef __XML_PARSER_INTERNALS_H__
|
| 13 |
+
#define __XML_PARSER_INTERNALS_H__
|
| 14 |
+
|
| 15 |
+
#include <libxml/xmlversion.h>
|
| 16 |
+
#include <libxml/parser.h>
|
| 17 |
+
#include <libxml/HTMLparser.h>
|
| 18 |
+
#include <libxml/chvalid.h>
|
| 19 |
+
#include <libxml/SAX2.h>
|
| 20 |
+
|
| 21 |
+
#ifdef __cplusplus
|
| 22 |
+
extern "C" {
|
| 23 |
+
#endif
|
| 24 |
+
|
| 25 |
+
/**
|
| 26 |
+
* xmlParserMaxDepth:
|
| 27 |
+
*
|
| 28 |
+
* arbitrary depth limit for the XML documents that we allow to
|
| 29 |
+
* process. This is not a limitation of the parser but a safety
|
| 30 |
+
* boundary feature, use XML_PARSE_HUGE option to override it.
|
| 31 |
+
*/
|
| 32 |
+
XMLPUBVAR unsigned int xmlParserMaxDepth;
|
| 33 |
+
|
| 34 |
+
/**
|
| 35 |
+
* XML_MAX_TEXT_LENGTH:
|
| 36 |
+
*
|
| 37 |
+
* Maximum size allowed for a single text node when building a tree.
|
| 38 |
+
* This is not a limitation of the parser but a safety boundary feature,
|
| 39 |
+
* use XML_PARSE_HUGE option to override it.
|
| 40 |
+
* Introduced in 2.9.0
|
| 41 |
+
*/
|
| 42 |
+
#define XML_MAX_TEXT_LENGTH 10000000
|
| 43 |
+
|
| 44 |
+
/**
|
| 45 |
+
* XML_MAX_HUGE_LENGTH:
|
| 46 |
+
*
|
| 47 |
+
* Maximum size allowed when XML_PARSE_HUGE is set.
|
| 48 |
+
*/
|
| 49 |
+
#define XML_MAX_HUGE_LENGTH 1000000000
|
| 50 |
+
|
| 51 |
+
/**
|
| 52 |
+
* XML_MAX_NAME_LENGTH:
|
| 53 |
+
*
|
| 54 |
+
* Maximum size allowed for a markup identifier.
|
| 55 |
+
* This is not a limitation of the parser but a safety boundary feature,
|
| 56 |
+
* use XML_PARSE_HUGE option to override it.
|
| 57 |
+
* Note that with the use of parsing dictionaries overriding the limit
|
| 58 |
+
* may result in more runtime memory usage in face of "unfriendly' content
|
| 59 |
+
* Introduced in 2.9.0
|
| 60 |
+
*/
|
| 61 |
+
#define XML_MAX_NAME_LENGTH 50000
|
| 62 |
+
|
| 63 |
+
/**
|
| 64 |
+
* XML_MAX_DICTIONARY_LIMIT:
|
| 65 |
+
*
|
| 66 |
+
* Maximum size allowed by the parser for a dictionary by default
|
| 67 |
+
* This is not a limitation of the parser but a safety boundary feature,
|
| 68 |
+
* use XML_PARSE_HUGE option to override it.
|
| 69 |
+
* Introduced in 2.9.0
|
| 70 |
+
*/
|
| 71 |
+
#define XML_MAX_DICTIONARY_LIMIT 10000000
|
| 72 |
+
|
| 73 |
+
/**
|
| 74 |
+
* XML_MAX_LOOKUP_LIMIT:
|
| 75 |
+
*
|
| 76 |
+
* Maximum size allowed by the parser for ahead lookup
|
| 77 |
+
* This is an upper boundary enforced by the parser to avoid bad
|
| 78 |
+
* behaviour on "unfriendly' content
|
| 79 |
+
* Introduced in 2.9.0
|
| 80 |
+
*/
|
| 81 |
+
#define XML_MAX_LOOKUP_LIMIT 10000000
|
| 82 |
+
|
| 83 |
+
/**
|
| 84 |
+
* XML_MAX_NAMELEN:
|
| 85 |
+
*
|
| 86 |
+
* Identifiers can be longer, but this will be more costly
|
| 87 |
+
* at runtime.
|
| 88 |
+
*/
|
| 89 |
+
#define XML_MAX_NAMELEN 100
|
| 90 |
+
|
| 91 |
+
/**
|
| 92 |
+
* INPUT_CHUNK:
|
| 93 |
+
*
|
| 94 |
+
* The parser tries to always have that amount of input ready.
|
| 95 |
+
* One of the point is providing context when reporting errors.
|
| 96 |
+
*/
|
| 97 |
+
#define INPUT_CHUNK 250
|
| 98 |
+
|
| 99 |
+
/************************************************************************
|
| 100 |
+
* *
|
| 101 |
+
* UNICODE version of the macros. *
|
| 102 |
+
* *
|
| 103 |
+
************************************************************************/
|
| 104 |
+
/**
|
| 105 |
+
* IS_BYTE_CHAR:
|
| 106 |
+
* @c: an byte value (int)
|
| 107 |
+
*
|
| 108 |
+
* Macro to check the following production in the XML spec:
|
| 109 |
+
*
|
| 110 |
+
* [2] Char ::= #x9 | #xA | #xD | [#x20...]
|
| 111 |
+
* any byte character in the accepted range
|
| 112 |
+
*/
|
| 113 |
+
#define IS_BYTE_CHAR(c) xmlIsChar_ch(c)
|
| 114 |
+
|
| 115 |
+
/**
|
| 116 |
+
* IS_CHAR:
|
| 117 |
+
* @c: an UNICODE value (int)
|
| 118 |
+
*
|
| 119 |
+
* Macro to check the following production in the XML spec:
|
| 120 |
+
*
|
| 121 |
+
* [2] Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD]
|
| 122 |
+
* | [#x10000-#x10FFFF]
|
| 123 |
+
* any Unicode character, excluding the surrogate blocks, FFFE, and FFFF.
|
| 124 |
+
*/
|
| 125 |
+
#define IS_CHAR(c) xmlIsCharQ(c)
|
| 126 |
+
|
| 127 |
+
/**
|
| 128 |
+
* IS_CHAR_CH:
|
| 129 |
+
* @c: an xmlChar (usually an unsigned char)
|
| 130 |
+
*
|
| 131 |
+
* Behaves like IS_CHAR on single-byte value
|
| 132 |
+
*/
|
| 133 |
+
#define IS_CHAR_CH(c) xmlIsChar_ch(c)
|
| 134 |
+
|
| 135 |
+
/**
|
| 136 |
+
* IS_BLANK:
|
| 137 |
+
* @c: an UNICODE value (int)
|
| 138 |
+
*
|
| 139 |
+
* Macro to check the following production in the XML spec:
|
| 140 |
+
*
|
| 141 |
+
* [3] S ::= (#x20 | #x9 | #xD | #xA)+
|
| 142 |
+
*/
|
| 143 |
+
#define IS_BLANK(c) xmlIsBlankQ(c)
|
| 144 |
+
|
| 145 |
+
/**
|
| 146 |
+
* IS_BLANK_CH:
|
| 147 |
+
* @c: an xmlChar value (normally unsigned char)
|
| 148 |
+
*
|
| 149 |
+
* Behaviour same as IS_BLANK
|
| 150 |
+
*/
|
| 151 |
+
#define IS_BLANK_CH(c) xmlIsBlank_ch(c)
|
| 152 |
+
|
| 153 |
+
/**
|
| 154 |
+
* IS_BASECHAR:
|
| 155 |
+
* @c: an UNICODE value (int)
|
| 156 |
+
*
|
| 157 |
+
* Macro to check the following production in the XML spec:
|
| 158 |
+
*
|
| 159 |
+
* [85] BaseChar ::= ... long list see REC ...
|
| 160 |
+
*/
|
| 161 |
+
#define IS_BASECHAR(c) xmlIsBaseCharQ(c)
|
| 162 |
+
|
| 163 |
+
/**
|
| 164 |
+
* IS_DIGIT:
|
| 165 |
+
* @c: an UNICODE value (int)
|
| 166 |
+
*
|
| 167 |
+
* Macro to check the following production in the XML spec:
|
| 168 |
+
*
|
| 169 |
+
* [88] Digit ::= ... long list see REC ...
|
| 170 |
+
*/
|
| 171 |
+
#define IS_DIGIT(c) xmlIsDigitQ(c)
|
| 172 |
+
|
| 173 |
+
/**
|
| 174 |
+
* IS_DIGIT_CH:
|
| 175 |
+
* @c: an xmlChar value (usually an unsigned char)
|
| 176 |
+
*
|
| 177 |
+
* Behaves like IS_DIGIT but with a single byte argument
|
| 178 |
+
*/
|
| 179 |
+
#define IS_DIGIT_CH(c) xmlIsDigit_ch(c)
|
| 180 |
+
|
| 181 |
+
/**
|
| 182 |
+
* IS_COMBINING:
|
| 183 |
+
* @c: an UNICODE value (int)
|
| 184 |
+
*
|
| 185 |
+
* Macro to check the following production in the XML spec:
|
| 186 |
+
*
|
| 187 |
+
* [87] CombiningChar ::= ... long list see REC ...
|
| 188 |
+
*/
|
| 189 |
+
#define IS_COMBINING(c) xmlIsCombiningQ(c)
|
| 190 |
+
|
| 191 |
+
/**
|
| 192 |
+
* IS_COMBINING_CH:
|
| 193 |
+
* @c: an xmlChar (usually an unsigned char)
|
| 194 |
+
*
|
| 195 |
+
* Always false (all combining chars > 0xff)
|
| 196 |
+
*/
|
| 197 |
+
#define IS_COMBINING_CH(c) 0
|
| 198 |
+
|
| 199 |
+
/**
|
| 200 |
+
* IS_EXTENDER:
|
| 201 |
+
* @c: an UNICODE value (int)
|
| 202 |
+
*
|
| 203 |
+
* Macro to check the following production in the XML spec:
|
| 204 |
+
*
|
| 205 |
+
*
|
| 206 |
+
* [89] Extender ::= #x00B7 | #x02D0 | #x02D1 | #x0387 | #x0640 |
|
| 207 |
+
* #x0E46 | #x0EC6 | #x3005 | [#x3031-#x3035] |
|
| 208 |
+
* [#x309D-#x309E] | [#x30FC-#x30FE]
|
| 209 |
+
*/
|
| 210 |
+
#define IS_EXTENDER(c) xmlIsExtenderQ(c)
|
| 211 |
+
|
| 212 |
+
/**
|
| 213 |
+
* IS_EXTENDER_CH:
|
| 214 |
+
* @c: an xmlChar value (usually an unsigned char)
|
| 215 |
+
*
|
| 216 |
+
* Behaves like IS_EXTENDER but with a single-byte argument
|
| 217 |
+
*/
|
| 218 |
+
#define IS_EXTENDER_CH(c) xmlIsExtender_ch(c)
|
| 219 |
+
|
| 220 |
+
/**
|
| 221 |
+
* IS_IDEOGRAPHIC:
|
| 222 |
+
* @c: an UNICODE value (int)
|
| 223 |
+
*
|
| 224 |
+
* Macro to check the following production in the XML spec:
|
| 225 |
+
*
|
| 226 |
+
*
|
| 227 |
+
* [86] Ideographic ::= [#x4E00-#x9FA5] | #x3007 | [#x3021-#x3029]
|
| 228 |
+
*/
|
| 229 |
+
#define IS_IDEOGRAPHIC(c) xmlIsIdeographicQ(c)
|
| 230 |
+
|
| 231 |
+
/**
|
| 232 |
+
* IS_LETTER:
|
| 233 |
+
* @c: an UNICODE value (int)
|
| 234 |
+
*
|
| 235 |
+
* Macro to check the following production in the XML spec:
|
| 236 |
+
*
|
| 237 |
+
*
|
| 238 |
+
* [84] Letter ::= BaseChar | Ideographic
|
| 239 |
+
*/
|
| 240 |
+
#define IS_LETTER(c) (IS_BASECHAR(c) || IS_IDEOGRAPHIC(c))
|
| 241 |
+
|
| 242 |
+
/**
|
| 243 |
+
* IS_LETTER_CH:
|
| 244 |
+
* @c: an xmlChar value (normally unsigned char)
|
| 245 |
+
*
|
| 246 |
+
* Macro behaves like IS_LETTER, but only check base chars
|
| 247 |
+
*
|
| 248 |
+
*/
|
| 249 |
+
#define IS_LETTER_CH(c) xmlIsBaseChar_ch(c)
|
| 250 |
+
|
| 251 |
+
/**
|
| 252 |
+
* IS_ASCII_LETTER:
|
| 253 |
+
* @c: an xmlChar value
|
| 254 |
+
*
|
| 255 |
+
* Macro to check [a-zA-Z]
|
| 256 |
+
*
|
| 257 |
+
*/
|
| 258 |
+
#define IS_ASCII_LETTER(c) (((0x41 <= (c)) && ((c) <= 0x5a)) || \
|
| 259 |
+
((0x61 <= (c)) && ((c) <= 0x7a)))
|
| 260 |
+
|
| 261 |
+
/**
|
| 262 |
+
* IS_ASCII_DIGIT:
|
| 263 |
+
* @c: an xmlChar value
|
| 264 |
+
*
|
| 265 |
+
* Macro to check [0-9]
|
| 266 |
+
*
|
| 267 |
+
*/
|
| 268 |
+
#define IS_ASCII_DIGIT(c) ((0x30 <= (c)) && ((c) <= 0x39))
|
| 269 |
+
|
| 270 |
+
/**
|
| 271 |
+
* IS_PUBIDCHAR:
|
| 272 |
+
* @c: an UNICODE value (int)
|
| 273 |
+
*
|
| 274 |
+
* Macro to check the following production in the XML spec:
|
| 275 |
+
*
|
| 276 |
+
*
|
| 277 |
+
* [13] PubidChar ::= #x20 | #xD | #xA | [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%]
|
| 278 |
+
*/
|
| 279 |
+
#define IS_PUBIDCHAR(c) xmlIsPubidCharQ(c)
|
| 280 |
+
|
| 281 |
+
/**
|
| 282 |
+
* IS_PUBIDCHAR_CH:
|
| 283 |
+
* @c: an xmlChar value (normally unsigned char)
|
| 284 |
+
*
|
| 285 |
+
* Same as IS_PUBIDCHAR but for single-byte value
|
| 286 |
+
*/
|
| 287 |
+
#define IS_PUBIDCHAR_CH(c) xmlIsPubidChar_ch(c)
|
| 288 |
+
|
| 289 |
+
/**
|
| 290 |
+
* Global variables used for predefined strings.
|
| 291 |
+
*/
|
| 292 |
+
XMLPUBVAR const xmlChar xmlStringText[];
|
| 293 |
+
XMLPUBVAR const xmlChar xmlStringTextNoenc[];
|
| 294 |
+
XMLPUBVAR const xmlChar xmlStringComment[];
|
| 295 |
+
|
| 296 |
+
/*
|
| 297 |
+
* Function to finish the work of the macros where needed.
|
| 298 |
+
*/
|
| 299 |
+
XMLPUBFUN int xmlIsLetter (int c);
|
| 300 |
+
|
| 301 |
+
/**
|
| 302 |
+
* Parser context.
|
| 303 |
+
*/
|
| 304 |
+
XMLPUBFUN xmlParserCtxtPtr
|
| 305 |
+
xmlCreateFileParserCtxt (const char *filename);
|
| 306 |
+
XMLPUBFUN xmlParserCtxtPtr
|
| 307 |
+
xmlCreateURLParserCtxt (const char *filename,
|
| 308 |
+
int options);
|
| 309 |
+
XMLPUBFUN xmlParserCtxtPtr
|
| 310 |
+
xmlCreateMemoryParserCtxt(const char *buffer,
|
| 311 |
+
int size);
|
| 312 |
+
XMLPUBFUN xmlParserCtxtPtr
|
| 313 |
+
xmlCreateEntityParserCtxt(const xmlChar *URL,
|
| 314 |
+
const xmlChar *ID,
|
| 315 |
+
const xmlChar *base);
|
| 316 |
+
XMLPUBFUN int
|
| 317 |
+
xmlSwitchEncoding (xmlParserCtxtPtr ctxt,
|
| 318 |
+
xmlCharEncoding enc);
|
| 319 |
+
XMLPUBFUN int
|
| 320 |
+
xmlSwitchToEncoding (xmlParserCtxtPtr ctxt,
|
| 321 |
+
xmlCharEncodingHandlerPtr handler);
|
| 322 |
+
XML_DEPRECATED
|
| 323 |
+
XMLPUBFUN int
|
| 324 |
+
xmlSwitchInputEncoding (xmlParserCtxtPtr ctxt,
|
| 325 |
+
xmlParserInputPtr input,
|
| 326 |
+
xmlCharEncodingHandlerPtr handler);
|
| 327 |
+
|
| 328 |
+
/**
|
| 329 |
+
* Input Streams.
|
| 330 |
+
*/
|
| 331 |
+
XMLPUBFUN xmlParserInputPtr
|
| 332 |
+
xmlNewStringInputStream (xmlParserCtxtPtr ctxt,
|
| 333 |
+
const xmlChar *buffer);
|
| 334 |
+
XML_DEPRECATED
|
| 335 |
+
XMLPUBFUN xmlParserInputPtr
|
| 336 |
+
xmlNewEntityInputStream (xmlParserCtxtPtr ctxt,
|
| 337 |
+
xmlEntityPtr entity);
|
| 338 |
+
XMLPUBFUN int
|
| 339 |
+
xmlPushInput (xmlParserCtxtPtr ctxt,
|
| 340 |
+
xmlParserInputPtr input);
|
| 341 |
+
XMLPUBFUN xmlChar
|
| 342 |
+
xmlPopInput (xmlParserCtxtPtr ctxt);
|
| 343 |
+
XMLPUBFUN void
|
| 344 |
+
xmlFreeInputStream (xmlParserInputPtr input);
|
| 345 |
+
XMLPUBFUN xmlParserInputPtr
|
| 346 |
+
xmlNewInputFromFile (xmlParserCtxtPtr ctxt,
|
| 347 |
+
const char *filename);
|
| 348 |
+
XMLPUBFUN xmlParserInputPtr
|
| 349 |
+
xmlNewInputStream (xmlParserCtxtPtr ctxt);
|
| 350 |
+
|
| 351 |
+
/**
|
| 352 |
+
* Namespaces.
|
| 353 |
+
*/
|
| 354 |
+
XMLPUBFUN xmlChar *
|
| 355 |
+
xmlSplitQName (xmlParserCtxtPtr ctxt,
|
| 356 |
+
const xmlChar *name,
|
| 357 |
+
xmlChar **prefix);
|
| 358 |
+
|
| 359 |
+
/**
|
| 360 |
+
* Generic production rules.
|
| 361 |
+
*/
|
| 362 |
+
XML_DEPRECATED
|
| 363 |
+
XMLPUBFUN const xmlChar *
|
| 364 |
+
xmlParseName (xmlParserCtxtPtr ctxt);
|
| 365 |
+
XML_DEPRECATED
|
| 366 |
+
XMLPUBFUN xmlChar *
|
| 367 |
+
xmlParseNmtoken (xmlParserCtxtPtr ctxt);
|
| 368 |
+
XML_DEPRECATED
|
| 369 |
+
XMLPUBFUN xmlChar *
|
| 370 |
+
xmlParseEntityValue (xmlParserCtxtPtr ctxt,
|
| 371 |
+
xmlChar **orig);
|
| 372 |
+
XML_DEPRECATED
|
| 373 |
+
XMLPUBFUN xmlChar *
|
| 374 |
+
xmlParseAttValue (xmlParserCtxtPtr ctxt);
|
| 375 |
+
XML_DEPRECATED
|
| 376 |
+
XMLPUBFUN xmlChar *
|
| 377 |
+
xmlParseSystemLiteral (xmlParserCtxtPtr ctxt);
|
| 378 |
+
XML_DEPRECATED
|
| 379 |
+
XMLPUBFUN xmlChar *
|
| 380 |
+
xmlParsePubidLiteral (xmlParserCtxtPtr ctxt);
|
| 381 |
+
XML_DEPRECATED
|
| 382 |
+
XMLPUBFUN void
|
| 383 |
+
xmlParseCharData (xmlParserCtxtPtr ctxt,
|
| 384 |
+
int cdata);
|
| 385 |
+
XML_DEPRECATED
|
| 386 |
+
XMLPUBFUN xmlChar *
|
| 387 |
+
xmlParseExternalID (xmlParserCtxtPtr ctxt,
|
| 388 |
+
xmlChar **publicID,
|
| 389 |
+
int strict);
|
| 390 |
+
XML_DEPRECATED
|
| 391 |
+
XMLPUBFUN void
|
| 392 |
+
xmlParseComment (xmlParserCtxtPtr ctxt);
|
| 393 |
+
XML_DEPRECATED
|
| 394 |
+
XMLPUBFUN const xmlChar *
|
| 395 |
+
xmlParsePITarget (xmlParserCtxtPtr ctxt);
|
| 396 |
+
XML_DEPRECATED
|
| 397 |
+
XMLPUBFUN void
|
| 398 |
+
xmlParsePI (xmlParserCtxtPtr ctxt);
|
| 399 |
+
XML_DEPRECATED
|
| 400 |
+
XMLPUBFUN void
|
| 401 |
+
xmlParseNotationDecl (xmlParserCtxtPtr ctxt);
|
| 402 |
+
XML_DEPRECATED
|
| 403 |
+
XMLPUBFUN void
|
| 404 |
+
xmlParseEntityDecl (xmlParserCtxtPtr ctxt);
|
| 405 |
+
XML_DEPRECATED
|
| 406 |
+
XMLPUBFUN int
|
| 407 |
+
xmlParseDefaultDecl (xmlParserCtxtPtr ctxt,
|
| 408 |
+
xmlChar **value);
|
| 409 |
+
XML_DEPRECATED
|
| 410 |
+
XMLPUBFUN xmlEnumerationPtr
|
| 411 |
+
xmlParseNotationType (xmlParserCtxtPtr ctxt);
|
| 412 |
+
XML_DEPRECATED
|
| 413 |
+
XMLPUBFUN xmlEnumerationPtr
|
| 414 |
+
xmlParseEnumerationType (xmlParserCtxtPtr ctxt);
|
| 415 |
+
XML_DEPRECATED
|
| 416 |
+
XMLPUBFUN int
|
| 417 |
+
xmlParseEnumeratedType (xmlParserCtxtPtr ctxt,
|
| 418 |
+
xmlEnumerationPtr *tree);
|
| 419 |
+
XML_DEPRECATED
|
| 420 |
+
XMLPUBFUN int
|
| 421 |
+
xmlParseAttributeType (xmlParserCtxtPtr ctxt,
|
| 422 |
+
xmlEnumerationPtr *tree);
|
| 423 |
+
XML_DEPRECATED
|
| 424 |
+
XMLPUBFUN void
|
| 425 |
+
xmlParseAttributeListDecl(xmlParserCtxtPtr ctxt);
|
| 426 |
+
XML_DEPRECATED
|
| 427 |
+
XMLPUBFUN xmlElementContentPtr
|
| 428 |
+
xmlParseElementMixedContentDecl
|
| 429 |
+
(xmlParserCtxtPtr ctxt,
|
| 430 |
+
int inputchk);
|
| 431 |
+
XML_DEPRECATED
|
| 432 |
+
XMLPUBFUN xmlElementContentPtr
|
| 433 |
+
xmlParseElementChildrenContentDecl
|
| 434 |
+
(xmlParserCtxtPtr ctxt,
|
| 435 |
+
int inputchk);
|
| 436 |
+
XML_DEPRECATED
|
| 437 |
+
XMLPUBFUN int
|
| 438 |
+
xmlParseElementContentDecl(xmlParserCtxtPtr ctxt,
|
| 439 |
+
const xmlChar *name,
|
| 440 |
+
xmlElementContentPtr *result);
|
| 441 |
+
XML_DEPRECATED
|
| 442 |
+
XMLPUBFUN int
|
| 443 |
+
xmlParseElementDecl (xmlParserCtxtPtr ctxt);
|
| 444 |
+
XML_DEPRECATED
|
| 445 |
+
XMLPUBFUN void
|
| 446 |
+
xmlParseMarkupDecl (xmlParserCtxtPtr ctxt);
|
| 447 |
+
XML_DEPRECATED
|
| 448 |
+
XMLPUBFUN int
|
| 449 |
+
xmlParseCharRef (xmlParserCtxtPtr ctxt);
|
| 450 |
+
XML_DEPRECATED
|
| 451 |
+
XMLPUBFUN xmlEntityPtr
|
| 452 |
+
xmlParseEntityRef (xmlParserCtxtPtr ctxt);
|
| 453 |
+
XML_DEPRECATED
|
| 454 |
+
XMLPUBFUN void
|
| 455 |
+
xmlParseReference (xmlParserCtxtPtr ctxt);
|
| 456 |
+
XML_DEPRECATED
|
| 457 |
+
XMLPUBFUN void
|
| 458 |
+
xmlParsePEReference (xmlParserCtxtPtr ctxt);
|
| 459 |
+
XML_DEPRECATED
|
| 460 |
+
XMLPUBFUN void
|
| 461 |
+
xmlParseDocTypeDecl (xmlParserCtxtPtr ctxt);
|
| 462 |
+
#ifdef LIBXML_SAX1_ENABLED
|
| 463 |
+
XML_DEPRECATED
|
| 464 |
+
XMLPUBFUN const xmlChar *
|
| 465 |
+
xmlParseAttribute (xmlParserCtxtPtr ctxt,
|
| 466 |
+
xmlChar **value);
|
| 467 |
+
XML_DEPRECATED
|
| 468 |
+
XMLPUBFUN const xmlChar *
|
| 469 |
+
xmlParseStartTag (xmlParserCtxtPtr ctxt);
|
| 470 |
+
XML_DEPRECATED
|
| 471 |
+
XMLPUBFUN void
|
| 472 |
+
xmlParseEndTag (xmlParserCtxtPtr ctxt);
|
| 473 |
+
#endif /* LIBXML_SAX1_ENABLED */
|
| 474 |
+
XML_DEPRECATED
|
| 475 |
+
XMLPUBFUN void
|
| 476 |
+
xmlParseCDSect (xmlParserCtxtPtr ctxt);
|
| 477 |
+
XMLPUBFUN void
|
| 478 |
+
xmlParseContent (xmlParserCtxtPtr ctxt);
|
| 479 |
+
XML_DEPRECATED
|
| 480 |
+
XMLPUBFUN void
|
| 481 |
+
xmlParseElement (xmlParserCtxtPtr ctxt);
|
| 482 |
+
XML_DEPRECATED
|
| 483 |
+
XMLPUBFUN xmlChar *
|
| 484 |
+
xmlParseVersionNum (xmlParserCtxtPtr ctxt);
|
| 485 |
+
XML_DEPRECATED
|
| 486 |
+
XMLPUBFUN xmlChar *
|
| 487 |
+
xmlParseVersionInfo (xmlParserCtxtPtr ctxt);
|
| 488 |
+
XML_DEPRECATED
|
| 489 |
+
XMLPUBFUN xmlChar *
|
| 490 |
+
xmlParseEncName (xmlParserCtxtPtr ctxt);
|
| 491 |
+
XML_DEPRECATED
|
| 492 |
+
XMLPUBFUN const xmlChar *
|
| 493 |
+
xmlParseEncodingDecl (xmlParserCtxtPtr ctxt);
|
| 494 |
+
XML_DEPRECATED
|
| 495 |
+
XMLPUBFUN int
|
| 496 |
+
xmlParseSDDecl (xmlParserCtxtPtr ctxt);
|
| 497 |
+
XML_DEPRECATED
|
| 498 |
+
XMLPUBFUN void
|
| 499 |
+
xmlParseXMLDecl (xmlParserCtxtPtr ctxt);
|
| 500 |
+
XML_DEPRECATED
|
| 501 |
+
XMLPUBFUN void
|
| 502 |
+
xmlParseTextDecl (xmlParserCtxtPtr ctxt);
|
| 503 |
+
XML_DEPRECATED
|
| 504 |
+
XMLPUBFUN void
|
| 505 |
+
xmlParseMisc (xmlParserCtxtPtr ctxt);
|
| 506 |
+
XMLPUBFUN void
|
| 507 |
+
xmlParseExternalSubset (xmlParserCtxtPtr ctxt,
|
| 508 |
+
const xmlChar *ExternalID,
|
| 509 |
+
const xmlChar *SystemID);
|
| 510 |
+
/**
|
| 511 |
+
* XML_SUBSTITUTE_NONE:
|
| 512 |
+
*
|
| 513 |
+
* If no entities need to be substituted.
|
| 514 |
+
*/
|
| 515 |
+
#define XML_SUBSTITUTE_NONE 0
|
| 516 |
+
/**
|
| 517 |
+
* XML_SUBSTITUTE_REF:
|
| 518 |
+
*
|
| 519 |
+
* Whether general entities need to be substituted.
|
| 520 |
+
*/
|
| 521 |
+
#define XML_SUBSTITUTE_REF 1
|
| 522 |
+
/**
|
| 523 |
+
* XML_SUBSTITUTE_PEREF:
|
| 524 |
+
*
|
| 525 |
+
* Whether parameter entities need to be substituted.
|
| 526 |
+
*/
|
| 527 |
+
#define XML_SUBSTITUTE_PEREF 2
|
| 528 |
+
/**
|
| 529 |
+
* XML_SUBSTITUTE_BOTH:
|
| 530 |
+
*
|
| 531 |
+
* Both general and parameter entities need to be substituted.
|
| 532 |
+
*/
|
| 533 |
+
#define XML_SUBSTITUTE_BOTH 3
|
| 534 |
+
|
| 535 |
+
XML_DEPRECATED
|
| 536 |
+
XMLPUBFUN xmlChar *
|
| 537 |
+
xmlStringDecodeEntities (xmlParserCtxtPtr ctxt,
|
| 538 |
+
const xmlChar *str,
|
| 539 |
+
int what,
|
| 540 |
+
xmlChar end,
|
| 541 |
+
xmlChar end2,
|
| 542 |
+
xmlChar end3);
|
| 543 |
+
XML_DEPRECATED
|
| 544 |
+
XMLPUBFUN xmlChar *
|
| 545 |
+
xmlStringLenDecodeEntities (xmlParserCtxtPtr ctxt,
|
| 546 |
+
const xmlChar *str,
|
| 547 |
+
int len,
|
| 548 |
+
int what,
|
| 549 |
+
xmlChar end,
|
| 550 |
+
xmlChar end2,
|
| 551 |
+
xmlChar end3);
|
| 552 |
+
|
| 553 |
+
/*
|
| 554 |
+
* Generated by MACROS on top of parser.c c.f. PUSH_AND_POP.
|
| 555 |
+
*/
|
| 556 |
+
XML_DEPRECATED
|
| 557 |
+
XMLPUBFUN int nodePush (xmlParserCtxtPtr ctxt,
|
| 558 |
+
xmlNodePtr value);
|
| 559 |
+
XML_DEPRECATED
|
| 560 |
+
XMLPUBFUN xmlNodePtr nodePop (xmlParserCtxtPtr ctxt);
|
| 561 |
+
XMLPUBFUN int inputPush (xmlParserCtxtPtr ctxt,
|
| 562 |
+
xmlParserInputPtr value);
|
| 563 |
+
XMLPUBFUN xmlParserInputPtr inputPop (xmlParserCtxtPtr ctxt);
|
| 564 |
+
XML_DEPRECATED
|
| 565 |
+
XMLPUBFUN const xmlChar * namePop (xmlParserCtxtPtr ctxt);
|
| 566 |
+
XML_DEPRECATED
|
| 567 |
+
XMLPUBFUN int namePush (xmlParserCtxtPtr ctxt,
|
| 568 |
+
const xmlChar *value);
|
| 569 |
+
|
| 570 |
+
/*
|
| 571 |
+
* other commodities shared between parser.c and parserInternals.
|
| 572 |
+
*/
|
| 573 |
+
XML_DEPRECATED
|
| 574 |
+
XMLPUBFUN int xmlSkipBlankChars (xmlParserCtxtPtr ctxt);
|
| 575 |
+
XML_DEPRECATED
|
| 576 |
+
XMLPUBFUN int xmlStringCurrentChar (xmlParserCtxtPtr ctxt,
|
| 577 |
+
const xmlChar *cur,
|
| 578 |
+
int *len);
|
| 579 |
+
XML_DEPRECATED
|
| 580 |
+
XMLPUBFUN void xmlParserHandlePEReference(xmlParserCtxtPtr ctxt);
|
| 581 |
+
XML_DEPRECATED
|
| 582 |
+
XMLPUBFUN int xmlCheckLanguageID (const xmlChar *lang);
|
| 583 |
+
|
| 584 |
+
/*
|
| 585 |
+
* Really core function shared with HTML parser.
|
| 586 |
+
*/
|
| 587 |
+
XML_DEPRECATED
|
| 588 |
+
XMLPUBFUN int xmlCurrentChar (xmlParserCtxtPtr ctxt,
|
| 589 |
+
int *len);
|
| 590 |
+
XMLPUBFUN int xmlCopyCharMultiByte (xmlChar *out,
|
| 591 |
+
int val);
|
| 592 |
+
XMLPUBFUN int xmlCopyChar (int len,
|
| 593 |
+
xmlChar *out,
|
| 594 |
+
int val);
|
| 595 |
+
XML_DEPRECATED
|
| 596 |
+
XMLPUBFUN void xmlNextChar (xmlParserCtxtPtr ctxt);
|
| 597 |
+
XML_DEPRECATED
|
| 598 |
+
XMLPUBFUN void xmlParserInputShrink (xmlParserInputPtr in);
|
| 599 |
+
|
| 600 |
+
/*
|
| 601 |
+
* Specific function to keep track of entities references
|
| 602 |
+
* and used by the XSLT debugger.
|
| 603 |
+
*/
|
| 604 |
+
#ifdef LIBXML_LEGACY_ENABLED
|
| 605 |
+
/**
|
| 606 |
+
* xmlEntityReferenceFunc:
|
| 607 |
+
* @ent: the entity
|
| 608 |
+
* @firstNode: the fist node in the chunk
|
| 609 |
+
* @lastNode: the last nod in the chunk
|
| 610 |
+
*
|
| 611 |
+
* Callback function used when one needs to be able to track back the
|
| 612 |
+
* provenance of a chunk of nodes inherited from an entity replacement.
|
| 613 |
+
*/
|
| 614 |
+
typedef void (*xmlEntityReferenceFunc) (xmlEntityPtr ent,
|
| 615 |
+
xmlNodePtr firstNode,
|
| 616 |
+
xmlNodePtr lastNode);
|
| 617 |
+
|
| 618 |
+
XML_DEPRECATED
|
| 619 |
+
XMLPUBFUN void xmlSetEntityReferenceFunc (xmlEntityReferenceFunc func);
|
| 620 |
+
|
| 621 |
+
XML_DEPRECATED
|
| 622 |
+
XMLPUBFUN xmlChar *
|
| 623 |
+
xmlParseQuotedString (xmlParserCtxtPtr ctxt);
|
| 624 |
+
XML_DEPRECATED
|
| 625 |
+
XMLPUBFUN void
|
| 626 |
+
xmlParseNamespace (xmlParserCtxtPtr ctxt);
|
| 627 |
+
XML_DEPRECATED
|
| 628 |
+
XMLPUBFUN xmlChar *
|
| 629 |
+
xmlNamespaceParseNSDef (xmlParserCtxtPtr ctxt);
|
| 630 |
+
XML_DEPRECATED
|
| 631 |
+
XMLPUBFUN xmlChar *
|
| 632 |
+
xmlScanName (xmlParserCtxtPtr ctxt);
|
| 633 |
+
XML_DEPRECATED
|
| 634 |
+
XMLPUBFUN xmlChar *
|
| 635 |
+
xmlNamespaceParseNCName (xmlParserCtxtPtr ctxt);
|
| 636 |
+
XML_DEPRECATED
|
| 637 |
+
XMLPUBFUN void xmlParserHandleReference(xmlParserCtxtPtr ctxt);
|
| 638 |
+
XML_DEPRECATED
|
| 639 |
+
XMLPUBFUN xmlChar *
|
| 640 |
+
xmlNamespaceParseQName (xmlParserCtxtPtr ctxt,
|
| 641 |
+
xmlChar **prefix);
|
| 642 |
+
/**
|
| 643 |
+
* Entities
|
| 644 |
+
*/
|
| 645 |
+
XML_DEPRECATED
|
| 646 |
+
XMLPUBFUN xmlChar *
|
| 647 |
+
xmlDecodeEntities (xmlParserCtxtPtr ctxt,
|
| 648 |
+
int len,
|
| 649 |
+
int what,
|
| 650 |
+
xmlChar end,
|
| 651 |
+
xmlChar end2,
|
| 652 |
+
xmlChar end3);
|
| 653 |
+
XML_DEPRECATED
|
| 654 |
+
XMLPUBFUN void
|
| 655 |
+
xmlHandleEntity (xmlParserCtxtPtr ctxt,
|
| 656 |
+
xmlEntityPtr entity);
|
| 657 |
+
|
| 658 |
+
#endif /* LIBXML_LEGACY_ENABLED */
|
| 659 |
+
|
| 660 |
+
#ifdef __cplusplus
|
| 661 |
+
}
|
| 662 |
+
#endif
|
| 663 |
+
#endif /* __XML_PARSER_INTERNALS_H__ */
|
omnilmm/lib/python3.10/site-packages/lxml/includes/libxml/schemasInternals.h
ADDED
|
@@ -0,0 +1,959 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Summary: internal interfaces for XML Schemas
|
| 3 |
+
* Description: internal interfaces for the XML Schemas handling
|
| 4 |
+
* and schema validity checking
|
| 5 |
+
* The Schemas development is a Work In Progress.
|
| 6 |
+
* Some of those interfaces are not guaranteed to be API or ABI stable !
|
| 7 |
+
*
|
| 8 |
+
* Copy: See Copyright for the status of this software.
|
| 9 |
+
*
|
| 10 |
+
* Author: Daniel Veillard
|
| 11 |
+
*/
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
#ifndef __XML_SCHEMA_INTERNALS_H__
|
| 15 |
+
#define __XML_SCHEMA_INTERNALS_H__
|
| 16 |
+
|
| 17 |
+
#include <libxml/xmlversion.h>
|
| 18 |
+
|
| 19 |
+
#ifdef LIBXML_SCHEMAS_ENABLED
|
| 20 |
+
|
| 21 |
+
#include <libxml/xmlregexp.h>
|
| 22 |
+
#include <libxml/hash.h>
|
| 23 |
+
#include <libxml/dict.h>
|
| 24 |
+
#include <libxml/tree.h>
|
| 25 |
+
|
| 26 |
+
#ifdef __cplusplus
|
| 27 |
+
extern "C" {
|
| 28 |
+
#endif
|
| 29 |
+
|
| 30 |
+
typedef enum {
|
| 31 |
+
XML_SCHEMAS_UNKNOWN = 0,
|
| 32 |
+
XML_SCHEMAS_STRING = 1,
|
| 33 |
+
XML_SCHEMAS_NORMSTRING = 2,
|
| 34 |
+
XML_SCHEMAS_DECIMAL = 3,
|
| 35 |
+
XML_SCHEMAS_TIME = 4,
|
| 36 |
+
XML_SCHEMAS_GDAY = 5,
|
| 37 |
+
XML_SCHEMAS_GMONTH = 6,
|
| 38 |
+
XML_SCHEMAS_GMONTHDAY = 7,
|
| 39 |
+
XML_SCHEMAS_GYEAR = 8,
|
| 40 |
+
XML_SCHEMAS_GYEARMONTH = 9,
|
| 41 |
+
XML_SCHEMAS_DATE = 10,
|
| 42 |
+
XML_SCHEMAS_DATETIME = 11,
|
| 43 |
+
XML_SCHEMAS_DURATION = 12,
|
| 44 |
+
XML_SCHEMAS_FLOAT = 13,
|
| 45 |
+
XML_SCHEMAS_DOUBLE = 14,
|
| 46 |
+
XML_SCHEMAS_BOOLEAN = 15,
|
| 47 |
+
XML_SCHEMAS_TOKEN = 16,
|
| 48 |
+
XML_SCHEMAS_LANGUAGE = 17,
|
| 49 |
+
XML_SCHEMAS_NMTOKEN = 18,
|
| 50 |
+
XML_SCHEMAS_NMTOKENS = 19,
|
| 51 |
+
XML_SCHEMAS_NAME = 20,
|
| 52 |
+
XML_SCHEMAS_QNAME = 21,
|
| 53 |
+
XML_SCHEMAS_NCNAME = 22,
|
| 54 |
+
XML_SCHEMAS_ID = 23,
|
| 55 |
+
XML_SCHEMAS_IDREF = 24,
|
| 56 |
+
XML_SCHEMAS_IDREFS = 25,
|
| 57 |
+
XML_SCHEMAS_ENTITY = 26,
|
| 58 |
+
XML_SCHEMAS_ENTITIES = 27,
|
| 59 |
+
XML_SCHEMAS_NOTATION = 28,
|
| 60 |
+
XML_SCHEMAS_ANYURI = 29,
|
| 61 |
+
XML_SCHEMAS_INTEGER = 30,
|
| 62 |
+
XML_SCHEMAS_NPINTEGER = 31,
|
| 63 |
+
XML_SCHEMAS_NINTEGER = 32,
|
| 64 |
+
XML_SCHEMAS_NNINTEGER = 33,
|
| 65 |
+
XML_SCHEMAS_PINTEGER = 34,
|
| 66 |
+
XML_SCHEMAS_INT = 35,
|
| 67 |
+
XML_SCHEMAS_UINT = 36,
|
| 68 |
+
XML_SCHEMAS_LONG = 37,
|
| 69 |
+
XML_SCHEMAS_ULONG = 38,
|
| 70 |
+
XML_SCHEMAS_SHORT = 39,
|
| 71 |
+
XML_SCHEMAS_USHORT = 40,
|
| 72 |
+
XML_SCHEMAS_BYTE = 41,
|
| 73 |
+
XML_SCHEMAS_UBYTE = 42,
|
| 74 |
+
XML_SCHEMAS_HEXBINARY = 43,
|
| 75 |
+
XML_SCHEMAS_BASE64BINARY = 44,
|
| 76 |
+
XML_SCHEMAS_ANYTYPE = 45,
|
| 77 |
+
XML_SCHEMAS_ANYSIMPLETYPE = 46
|
| 78 |
+
} xmlSchemaValType;
|
| 79 |
+
|
| 80 |
+
/*
|
| 81 |
+
* XML Schemas defines multiple type of types.
|
| 82 |
+
*/
|
| 83 |
+
typedef enum {
|
| 84 |
+
XML_SCHEMA_TYPE_BASIC = 1, /* A built-in datatype */
|
| 85 |
+
XML_SCHEMA_TYPE_ANY,
|
| 86 |
+
XML_SCHEMA_TYPE_FACET,
|
| 87 |
+
XML_SCHEMA_TYPE_SIMPLE,
|
| 88 |
+
XML_SCHEMA_TYPE_COMPLEX,
|
| 89 |
+
XML_SCHEMA_TYPE_SEQUENCE = 6,
|
| 90 |
+
XML_SCHEMA_TYPE_CHOICE,
|
| 91 |
+
XML_SCHEMA_TYPE_ALL,
|
| 92 |
+
XML_SCHEMA_TYPE_SIMPLE_CONTENT,
|
| 93 |
+
XML_SCHEMA_TYPE_COMPLEX_CONTENT,
|
| 94 |
+
XML_SCHEMA_TYPE_UR,
|
| 95 |
+
XML_SCHEMA_TYPE_RESTRICTION,
|
| 96 |
+
XML_SCHEMA_TYPE_EXTENSION,
|
| 97 |
+
XML_SCHEMA_TYPE_ELEMENT,
|
| 98 |
+
XML_SCHEMA_TYPE_ATTRIBUTE,
|
| 99 |
+
XML_SCHEMA_TYPE_ATTRIBUTEGROUP,
|
| 100 |
+
XML_SCHEMA_TYPE_GROUP,
|
| 101 |
+
XML_SCHEMA_TYPE_NOTATION,
|
| 102 |
+
XML_SCHEMA_TYPE_LIST,
|
| 103 |
+
XML_SCHEMA_TYPE_UNION,
|
| 104 |
+
XML_SCHEMA_TYPE_ANY_ATTRIBUTE,
|
| 105 |
+
XML_SCHEMA_TYPE_IDC_UNIQUE,
|
| 106 |
+
XML_SCHEMA_TYPE_IDC_KEY,
|
| 107 |
+
XML_SCHEMA_TYPE_IDC_KEYREF,
|
| 108 |
+
XML_SCHEMA_TYPE_PARTICLE = 25,
|
| 109 |
+
XML_SCHEMA_TYPE_ATTRIBUTE_USE,
|
| 110 |
+
XML_SCHEMA_FACET_MININCLUSIVE = 1000,
|
| 111 |
+
XML_SCHEMA_FACET_MINEXCLUSIVE,
|
| 112 |
+
XML_SCHEMA_FACET_MAXINCLUSIVE,
|
| 113 |
+
XML_SCHEMA_FACET_MAXEXCLUSIVE,
|
| 114 |
+
XML_SCHEMA_FACET_TOTALDIGITS,
|
| 115 |
+
XML_SCHEMA_FACET_FRACTIONDIGITS,
|
| 116 |
+
XML_SCHEMA_FACET_PATTERN,
|
| 117 |
+
XML_SCHEMA_FACET_ENUMERATION,
|
| 118 |
+
XML_SCHEMA_FACET_WHITESPACE,
|
| 119 |
+
XML_SCHEMA_FACET_LENGTH,
|
| 120 |
+
XML_SCHEMA_FACET_MAXLENGTH,
|
| 121 |
+
XML_SCHEMA_FACET_MINLENGTH,
|
| 122 |
+
XML_SCHEMA_EXTRA_QNAMEREF = 2000,
|
| 123 |
+
XML_SCHEMA_EXTRA_ATTR_USE_PROHIB
|
| 124 |
+
} xmlSchemaTypeType;
|
| 125 |
+
|
| 126 |
+
typedef enum {
|
| 127 |
+
XML_SCHEMA_CONTENT_UNKNOWN = 0,
|
| 128 |
+
XML_SCHEMA_CONTENT_EMPTY = 1,
|
| 129 |
+
XML_SCHEMA_CONTENT_ELEMENTS,
|
| 130 |
+
XML_SCHEMA_CONTENT_MIXED,
|
| 131 |
+
XML_SCHEMA_CONTENT_SIMPLE,
|
| 132 |
+
XML_SCHEMA_CONTENT_MIXED_OR_ELEMENTS, /* Obsolete */
|
| 133 |
+
XML_SCHEMA_CONTENT_BASIC,
|
| 134 |
+
XML_SCHEMA_CONTENT_ANY
|
| 135 |
+
} xmlSchemaContentType;
|
| 136 |
+
|
| 137 |
+
typedef struct _xmlSchemaVal xmlSchemaVal;
|
| 138 |
+
typedef xmlSchemaVal *xmlSchemaValPtr;
|
| 139 |
+
|
| 140 |
+
typedef struct _xmlSchemaType xmlSchemaType;
|
| 141 |
+
typedef xmlSchemaType *xmlSchemaTypePtr;
|
| 142 |
+
|
| 143 |
+
typedef struct _xmlSchemaFacet xmlSchemaFacet;
|
| 144 |
+
typedef xmlSchemaFacet *xmlSchemaFacetPtr;
|
| 145 |
+
|
| 146 |
+
/**
|
| 147 |
+
* Annotation
|
| 148 |
+
*/
|
| 149 |
+
typedef struct _xmlSchemaAnnot xmlSchemaAnnot;
|
| 150 |
+
typedef xmlSchemaAnnot *xmlSchemaAnnotPtr;
|
| 151 |
+
struct _xmlSchemaAnnot {
|
| 152 |
+
struct _xmlSchemaAnnot *next;
|
| 153 |
+
xmlNodePtr content; /* the annotation */
|
| 154 |
+
};
|
| 155 |
+
|
| 156 |
+
/**
|
| 157 |
+
* XML_SCHEMAS_ANYATTR_SKIP:
|
| 158 |
+
*
|
| 159 |
+
* Skip unknown attribute from validation
|
| 160 |
+
* Obsolete, not used anymore.
|
| 161 |
+
*/
|
| 162 |
+
#define XML_SCHEMAS_ANYATTR_SKIP 1
|
| 163 |
+
/**
|
| 164 |
+
* XML_SCHEMAS_ANYATTR_LAX:
|
| 165 |
+
*
|
| 166 |
+
* Ignore validation non definition on attributes
|
| 167 |
+
* Obsolete, not used anymore.
|
| 168 |
+
*/
|
| 169 |
+
#define XML_SCHEMAS_ANYATTR_LAX 2
|
| 170 |
+
/**
|
| 171 |
+
* XML_SCHEMAS_ANYATTR_STRICT:
|
| 172 |
+
*
|
| 173 |
+
* Apply strict validation rules on attributes
|
| 174 |
+
* Obsolete, not used anymore.
|
| 175 |
+
*/
|
| 176 |
+
#define XML_SCHEMAS_ANYATTR_STRICT 3
|
| 177 |
+
/**
|
| 178 |
+
* XML_SCHEMAS_ANY_SKIP:
|
| 179 |
+
*
|
| 180 |
+
* Skip unknown attribute from validation
|
| 181 |
+
*/
|
| 182 |
+
#define XML_SCHEMAS_ANY_SKIP 1
|
| 183 |
+
/**
|
| 184 |
+
* XML_SCHEMAS_ANY_LAX:
|
| 185 |
+
*
|
| 186 |
+
* Used by wildcards.
|
| 187 |
+
* Validate if type found, don't worry if not found
|
| 188 |
+
*/
|
| 189 |
+
#define XML_SCHEMAS_ANY_LAX 2
|
| 190 |
+
/**
|
| 191 |
+
* XML_SCHEMAS_ANY_STRICT:
|
| 192 |
+
*
|
| 193 |
+
* Used by wildcards.
|
| 194 |
+
* Apply strict validation rules
|
| 195 |
+
*/
|
| 196 |
+
#define XML_SCHEMAS_ANY_STRICT 3
|
| 197 |
+
/**
|
| 198 |
+
* XML_SCHEMAS_ATTR_USE_PROHIBITED:
|
| 199 |
+
*
|
| 200 |
+
* Used by wildcards.
|
| 201 |
+
* The attribute is prohibited.
|
| 202 |
+
*/
|
| 203 |
+
#define XML_SCHEMAS_ATTR_USE_PROHIBITED 0
|
| 204 |
+
/**
|
| 205 |
+
* XML_SCHEMAS_ATTR_USE_REQUIRED:
|
| 206 |
+
*
|
| 207 |
+
* The attribute is required.
|
| 208 |
+
*/
|
| 209 |
+
#define XML_SCHEMAS_ATTR_USE_REQUIRED 1
|
| 210 |
+
/**
|
| 211 |
+
* XML_SCHEMAS_ATTR_USE_OPTIONAL:
|
| 212 |
+
*
|
| 213 |
+
* The attribute is optional.
|
| 214 |
+
*/
|
| 215 |
+
#define XML_SCHEMAS_ATTR_USE_OPTIONAL 2
|
| 216 |
+
/**
|
| 217 |
+
* XML_SCHEMAS_ATTR_GLOBAL:
|
| 218 |
+
*
|
| 219 |
+
* allow elements in no namespace
|
| 220 |
+
*/
|
| 221 |
+
#define XML_SCHEMAS_ATTR_GLOBAL 1 << 0
|
| 222 |
+
/**
|
| 223 |
+
* XML_SCHEMAS_ATTR_NSDEFAULT:
|
| 224 |
+
*
|
| 225 |
+
* allow elements in no namespace
|
| 226 |
+
*/
|
| 227 |
+
#define XML_SCHEMAS_ATTR_NSDEFAULT 1 << 7
|
| 228 |
+
/**
|
| 229 |
+
* XML_SCHEMAS_ATTR_INTERNAL_RESOLVED:
|
| 230 |
+
*
|
| 231 |
+
* this is set when the "type" and "ref" references
|
| 232 |
+
* have been resolved.
|
| 233 |
+
*/
|
| 234 |
+
#define XML_SCHEMAS_ATTR_INTERNAL_RESOLVED 1 << 8
|
| 235 |
+
/**
|
| 236 |
+
* XML_SCHEMAS_ATTR_FIXED:
|
| 237 |
+
*
|
| 238 |
+
* the attribute has a fixed value
|
| 239 |
+
*/
|
| 240 |
+
#define XML_SCHEMAS_ATTR_FIXED 1 << 9
|
| 241 |
+
|
| 242 |
+
/**
|
| 243 |
+
* xmlSchemaAttribute:
|
| 244 |
+
* An attribute definition.
|
| 245 |
+
*/
|
| 246 |
+
|
| 247 |
+
typedef struct _xmlSchemaAttribute xmlSchemaAttribute;
|
| 248 |
+
typedef xmlSchemaAttribute *xmlSchemaAttributePtr;
|
| 249 |
+
struct _xmlSchemaAttribute {
|
| 250 |
+
xmlSchemaTypeType type;
|
| 251 |
+
struct _xmlSchemaAttribute *next; /* the next attribute (not used?) */
|
| 252 |
+
const xmlChar *name; /* the name of the declaration */
|
| 253 |
+
const xmlChar *id; /* Deprecated; not used */
|
| 254 |
+
const xmlChar *ref; /* Deprecated; not used */
|
| 255 |
+
const xmlChar *refNs; /* Deprecated; not used */
|
| 256 |
+
const xmlChar *typeName; /* the local name of the type definition */
|
| 257 |
+
const xmlChar *typeNs; /* the ns URI of the type definition */
|
| 258 |
+
xmlSchemaAnnotPtr annot;
|
| 259 |
+
|
| 260 |
+
xmlSchemaTypePtr base; /* Deprecated; not used */
|
| 261 |
+
int occurs; /* Deprecated; not used */
|
| 262 |
+
const xmlChar *defValue; /* The initial value of the value constraint */
|
| 263 |
+
xmlSchemaTypePtr subtypes; /* the type definition */
|
| 264 |
+
xmlNodePtr node;
|
| 265 |
+
const xmlChar *targetNamespace;
|
| 266 |
+
int flags;
|
| 267 |
+
const xmlChar *refPrefix; /* Deprecated; not used */
|
| 268 |
+
xmlSchemaValPtr defVal; /* The compiled value constraint */
|
| 269 |
+
xmlSchemaAttributePtr refDecl; /* Deprecated; not used */
|
| 270 |
+
};
|
| 271 |
+
|
| 272 |
+
/**
|
| 273 |
+
* xmlSchemaAttributeLink:
|
| 274 |
+
* Used to build a list of attribute uses on complexType definitions.
|
| 275 |
+
* WARNING: Deprecated; not used.
|
| 276 |
+
*/
|
| 277 |
+
typedef struct _xmlSchemaAttributeLink xmlSchemaAttributeLink;
|
| 278 |
+
typedef xmlSchemaAttributeLink *xmlSchemaAttributeLinkPtr;
|
| 279 |
+
struct _xmlSchemaAttributeLink {
|
| 280 |
+
struct _xmlSchemaAttributeLink *next;/* the next attribute link ... */
|
| 281 |
+
struct _xmlSchemaAttribute *attr;/* the linked attribute */
|
| 282 |
+
};
|
| 283 |
+
|
| 284 |
+
/**
|
| 285 |
+
* XML_SCHEMAS_WILDCARD_COMPLETE:
|
| 286 |
+
*
|
| 287 |
+
* If the wildcard is complete.
|
| 288 |
+
*/
|
| 289 |
+
#define XML_SCHEMAS_WILDCARD_COMPLETE 1 << 0
|
| 290 |
+
|
| 291 |
+
/**
|
| 292 |
+
* xmlSchemaCharValueLink:
|
| 293 |
+
* Used to build a list of namespaces on wildcards.
|
| 294 |
+
*/
|
| 295 |
+
typedef struct _xmlSchemaWildcardNs xmlSchemaWildcardNs;
|
| 296 |
+
typedef xmlSchemaWildcardNs *xmlSchemaWildcardNsPtr;
|
| 297 |
+
struct _xmlSchemaWildcardNs {
|
| 298 |
+
struct _xmlSchemaWildcardNs *next;/* the next constraint link ... */
|
| 299 |
+
const xmlChar *value;/* the value */
|
| 300 |
+
};
|
| 301 |
+
|
| 302 |
+
/**
|
| 303 |
+
* xmlSchemaWildcard.
|
| 304 |
+
* A wildcard.
|
| 305 |
+
*/
|
| 306 |
+
typedef struct _xmlSchemaWildcard xmlSchemaWildcard;
|
| 307 |
+
typedef xmlSchemaWildcard *xmlSchemaWildcardPtr;
|
| 308 |
+
struct _xmlSchemaWildcard {
|
| 309 |
+
xmlSchemaTypeType type; /* The kind of type */
|
| 310 |
+
const xmlChar *id; /* Deprecated; not used */
|
| 311 |
+
xmlSchemaAnnotPtr annot;
|
| 312 |
+
xmlNodePtr node;
|
| 313 |
+
int minOccurs; /* Deprecated; not used */
|
| 314 |
+
int maxOccurs; /* Deprecated; not used */
|
| 315 |
+
int processContents;
|
| 316 |
+
int any; /* Indicates if the ns constraint is of ##any */
|
| 317 |
+
xmlSchemaWildcardNsPtr nsSet; /* The list of allowed namespaces */
|
| 318 |
+
xmlSchemaWildcardNsPtr negNsSet; /* The negated namespace */
|
| 319 |
+
int flags;
|
| 320 |
+
};
|
| 321 |
+
|
| 322 |
+
/**
|
| 323 |
+
* XML_SCHEMAS_ATTRGROUP_WILDCARD_BUILDED:
|
| 324 |
+
*
|
| 325 |
+
* The attribute wildcard has been built.
|
| 326 |
+
*/
|
| 327 |
+
#define XML_SCHEMAS_ATTRGROUP_WILDCARD_BUILDED 1 << 0
|
| 328 |
+
/**
|
| 329 |
+
* XML_SCHEMAS_ATTRGROUP_GLOBAL:
|
| 330 |
+
*
|
| 331 |
+
* The attribute group has been defined.
|
| 332 |
+
*/
|
| 333 |
+
#define XML_SCHEMAS_ATTRGROUP_GLOBAL 1 << 1
|
| 334 |
+
/**
|
| 335 |
+
* XML_SCHEMAS_ATTRGROUP_MARKED:
|
| 336 |
+
*
|
| 337 |
+
* Marks the attr group as marked; used for circular checks.
|
| 338 |
+
*/
|
| 339 |
+
#define XML_SCHEMAS_ATTRGROUP_MARKED 1 << 2
|
| 340 |
+
|
| 341 |
+
/**
|
| 342 |
+
* XML_SCHEMAS_ATTRGROUP_REDEFINED:
|
| 343 |
+
*
|
| 344 |
+
* The attr group was redefined.
|
| 345 |
+
*/
|
| 346 |
+
#define XML_SCHEMAS_ATTRGROUP_REDEFINED 1 << 3
|
| 347 |
+
/**
|
| 348 |
+
* XML_SCHEMAS_ATTRGROUP_HAS_REFS:
|
| 349 |
+
*
|
| 350 |
+
* Whether this attr. group contains attr. group references.
|
| 351 |
+
*/
|
| 352 |
+
#define XML_SCHEMAS_ATTRGROUP_HAS_REFS 1 << 4
|
| 353 |
+
|
| 354 |
+
/**
|
| 355 |
+
* An attribute group definition.
|
| 356 |
+
*
|
| 357 |
+
* xmlSchemaAttribute and xmlSchemaAttributeGroup start of structures
|
| 358 |
+
* must be kept similar
|
| 359 |
+
*/
|
| 360 |
+
typedef struct _xmlSchemaAttributeGroup xmlSchemaAttributeGroup;
|
| 361 |
+
typedef xmlSchemaAttributeGroup *xmlSchemaAttributeGroupPtr;
|
| 362 |
+
struct _xmlSchemaAttributeGroup {
|
| 363 |
+
xmlSchemaTypeType type; /* The kind of type */
|
| 364 |
+
struct _xmlSchemaAttribute *next;/* the next attribute if in a group ... */
|
| 365 |
+
const xmlChar *name;
|
| 366 |
+
const xmlChar *id;
|
| 367 |
+
const xmlChar *ref; /* Deprecated; not used */
|
| 368 |
+
const xmlChar *refNs; /* Deprecated; not used */
|
| 369 |
+
xmlSchemaAnnotPtr annot;
|
| 370 |
+
|
| 371 |
+
xmlSchemaAttributePtr attributes; /* Deprecated; not used */
|
| 372 |
+
xmlNodePtr node;
|
| 373 |
+
int flags;
|
| 374 |
+
xmlSchemaWildcardPtr attributeWildcard;
|
| 375 |
+
const xmlChar *refPrefix; /* Deprecated; not used */
|
| 376 |
+
xmlSchemaAttributeGroupPtr refItem; /* Deprecated; not used */
|
| 377 |
+
const xmlChar *targetNamespace;
|
| 378 |
+
void *attrUses;
|
| 379 |
+
};
|
| 380 |
+
|
| 381 |
+
/**
|
| 382 |
+
* xmlSchemaTypeLink:
|
| 383 |
+
* Used to build a list of types (e.g. member types of
|
| 384 |
+
* simpleType with variety "union").
|
| 385 |
+
*/
|
| 386 |
+
typedef struct _xmlSchemaTypeLink xmlSchemaTypeLink;
|
| 387 |
+
typedef xmlSchemaTypeLink *xmlSchemaTypeLinkPtr;
|
| 388 |
+
struct _xmlSchemaTypeLink {
|
| 389 |
+
struct _xmlSchemaTypeLink *next;/* the next type link ... */
|
| 390 |
+
xmlSchemaTypePtr type;/* the linked type */
|
| 391 |
+
};
|
| 392 |
+
|
| 393 |
+
/**
|
| 394 |
+
* xmlSchemaFacetLink:
|
| 395 |
+
* Used to build a list of facets.
|
| 396 |
+
*/
|
| 397 |
+
typedef struct _xmlSchemaFacetLink xmlSchemaFacetLink;
|
| 398 |
+
typedef xmlSchemaFacetLink *xmlSchemaFacetLinkPtr;
|
| 399 |
+
struct _xmlSchemaFacetLink {
|
| 400 |
+
struct _xmlSchemaFacetLink *next;/* the next facet link ... */
|
| 401 |
+
xmlSchemaFacetPtr facet;/* the linked facet */
|
| 402 |
+
};
|
| 403 |
+
|
| 404 |
+
/**
|
| 405 |
+
* XML_SCHEMAS_TYPE_MIXED:
|
| 406 |
+
*
|
| 407 |
+
* the element content type is mixed
|
| 408 |
+
*/
|
| 409 |
+
#define XML_SCHEMAS_TYPE_MIXED 1 << 0
|
| 410 |
+
/**
|
| 411 |
+
* XML_SCHEMAS_TYPE_DERIVATION_METHOD_EXTENSION:
|
| 412 |
+
*
|
| 413 |
+
* the simple or complex type has a derivation method of "extension".
|
| 414 |
+
*/
|
| 415 |
+
#define XML_SCHEMAS_TYPE_DERIVATION_METHOD_EXTENSION 1 << 1
|
| 416 |
+
/**
|
| 417 |
+
* XML_SCHEMAS_TYPE_DERIVATION_METHOD_RESTRICTION:
|
| 418 |
+
*
|
| 419 |
+
* the simple or complex type has a derivation method of "restriction".
|
| 420 |
+
*/
|
| 421 |
+
#define XML_SCHEMAS_TYPE_DERIVATION_METHOD_RESTRICTION 1 << 2
|
| 422 |
+
/**
|
| 423 |
+
* XML_SCHEMAS_TYPE_GLOBAL:
|
| 424 |
+
*
|
| 425 |
+
* the type is global
|
| 426 |
+
*/
|
| 427 |
+
#define XML_SCHEMAS_TYPE_GLOBAL 1 << 3
|
| 428 |
+
/**
|
| 429 |
+
* XML_SCHEMAS_TYPE_OWNED_ATTR_WILDCARD:
|
| 430 |
+
*
|
| 431 |
+
* the complexType owns an attribute wildcard, i.e.
|
| 432 |
+
* it can be freed by the complexType
|
| 433 |
+
*/
|
| 434 |
+
#define XML_SCHEMAS_TYPE_OWNED_ATTR_WILDCARD 1 << 4 /* Obsolete. */
|
| 435 |
+
/**
|
| 436 |
+
* XML_SCHEMAS_TYPE_VARIETY_ABSENT:
|
| 437 |
+
*
|
| 438 |
+
* the simpleType has a variety of "absent".
|
| 439 |
+
* TODO: Actually not necessary :-/, since if
|
| 440 |
+
* none of the variety flags occur then it's
|
| 441 |
+
* automatically absent.
|
| 442 |
+
*/
|
| 443 |
+
#define XML_SCHEMAS_TYPE_VARIETY_ABSENT 1 << 5
|
| 444 |
+
/**
|
| 445 |
+
* XML_SCHEMAS_TYPE_VARIETY_LIST:
|
| 446 |
+
*
|
| 447 |
+
* the simpleType has a variety of "list".
|
| 448 |
+
*/
|
| 449 |
+
#define XML_SCHEMAS_TYPE_VARIETY_LIST 1 << 6
|
| 450 |
+
/**
|
| 451 |
+
* XML_SCHEMAS_TYPE_VARIETY_UNION:
|
| 452 |
+
*
|
| 453 |
+
* the simpleType has a variety of "union".
|
| 454 |
+
*/
|
| 455 |
+
#define XML_SCHEMAS_TYPE_VARIETY_UNION 1 << 7
|
| 456 |
+
/**
|
| 457 |
+
* XML_SCHEMAS_TYPE_VARIETY_ATOMIC:
|
| 458 |
+
*
|
| 459 |
+
* the simpleType has a variety of "union".
|
| 460 |
+
*/
|
| 461 |
+
#define XML_SCHEMAS_TYPE_VARIETY_ATOMIC 1 << 8
|
| 462 |
+
/**
|
| 463 |
+
* XML_SCHEMAS_TYPE_FINAL_EXTENSION:
|
| 464 |
+
*
|
| 465 |
+
* the complexType has a final of "extension".
|
| 466 |
+
*/
|
| 467 |
+
#define XML_SCHEMAS_TYPE_FINAL_EXTENSION 1 << 9
|
| 468 |
+
/**
|
| 469 |
+
* XML_SCHEMAS_TYPE_FINAL_RESTRICTION:
|
| 470 |
+
*
|
| 471 |
+
* the simpleType/complexType has a final of "restriction".
|
| 472 |
+
*/
|
| 473 |
+
#define XML_SCHEMAS_TYPE_FINAL_RESTRICTION 1 << 10
|
| 474 |
+
/**
|
| 475 |
+
* XML_SCHEMAS_TYPE_FINAL_LIST:
|
| 476 |
+
*
|
| 477 |
+
* the simpleType has a final of "list".
|
| 478 |
+
*/
|
| 479 |
+
#define XML_SCHEMAS_TYPE_FINAL_LIST 1 << 11
|
| 480 |
+
/**
|
| 481 |
+
* XML_SCHEMAS_TYPE_FINAL_UNION:
|
| 482 |
+
*
|
| 483 |
+
* the simpleType has a final of "union".
|
| 484 |
+
*/
|
| 485 |
+
#define XML_SCHEMAS_TYPE_FINAL_UNION 1 << 12
|
| 486 |
+
/**
|
| 487 |
+
* XML_SCHEMAS_TYPE_FINAL_DEFAULT:
|
| 488 |
+
*
|
| 489 |
+
* the simpleType has a final of "default".
|
| 490 |
+
*/
|
| 491 |
+
#define XML_SCHEMAS_TYPE_FINAL_DEFAULT 1 << 13
|
| 492 |
+
/**
|
| 493 |
+
* XML_SCHEMAS_TYPE_BUILTIN_PRIMITIVE:
|
| 494 |
+
*
|
| 495 |
+
* Marks the item as a builtin primitive.
|
| 496 |
+
*/
|
| 497 |
+
#define XML_SCHEMAS_TYPE_BUILTIN_PRIMITIVE 1 << 14
|
| 498 |
+
/**
|
| 499 |
+
* XML_SCHEMAS_TYPE_MARKED:
|
| 500 |
+
*
|
| 501 |
+
* Marks the item as marked; used for circular checks.
|
| 502 |
+
*/
|
| 503 |
+
#define XML_SCHEMAS_TYPE_MARKED 1 << 16
|
| 504 |
+
/**
|
| 505 |
+
* XML_SCHEMAS_TYPE_BLOCK_DEFAULT:
|
| 506 |
+
*
|
| 507 |
+
* the complexType did not specify 'block' so use the default of the
|
| 508 |
+
* <schema> item.
|
| 509 |
+
*/
|
| 510 |
+
#define XML_SCHEMAS_TYPE_BLOCK_DEFAULT 1 << 17
|
| 511 |
+
/**
|
| 512 |
+
* XML_SCHEMAS_TYPE_BLOCK_EXTENSION:
|
| 513 |
+
*
|
| 514 |
+
* the complexType has a 'block' of "extension".
|
| 515 |
+
*/
|
| 516 |
+
#define XML_SCHEMAS_TYPE_BLOCK_EXTENSION 1 << 18
|
| 517 |
+
/**
|
| 518 |
+
* XML_SCHEMAS_TYPE_BLOCK_RESTRICTION:
|
| 519 |
+
*
|
| 520 |
+
* the complexType has a 'block' of "restriction".
|
| 521 |
+
*/
|
| 522 |
+
#define XML_SCHEMAS_TYPE_BLOCK_RESTRICTION 1 << 19
|
| 523 |
+
/**
|
| 524 |
+
* XML_SCHEMAS_TYPE_ABSTRACT:
|
| 525 |
+
*
|
| 526 |
+
* the simple/complexType is abstract.
|
| 527 |
+
*/
|
| 528 |
+
#define XML_SCHEMAS_TYPE_ABSTRACT 1 << 20
|
| 529 |
+
/**
|
| 530 |
+
* XML_SCHEMAS_TYPE_FACETSNEEDVALUE:
|
| 531 |
+
*
|
| 532 |
+
* indicates if the facets need a computed value
|
| 533 |
+
*/
|
| 534 |
+
#define XML_SCHEMAS_TYPE_FACETSNEEDVALUE 1 << 21
|
| 535 |
+
/**
|
| 536 |
+
* XML_SCHEMAS_TYPE_INTERNAL_RESOLVED:
|
| 537 |
+
*
|
| 538 |
+
* indicates that the type was typefixed
|
| 539 |
+
*/
|
| 540 |
+
#define XML_SCHEMAS_TYPE_INTERNAL_RESOLVED 1 << 22
|
| 541 |
+
/**
|
| 542 |
+
* XML_SCHEMAS_TYPE_INTERNAL_INVALID:
|
| 543 |
+
*
|
| 544 |
+
* indicates that the type is invalid
|
| 545 |
+
*/
|
| 546 |
+
#define XML_SCHEMAS_TYPE_INTERNAL_INVALID 1 << 23
|
| 547 |
+
/**
|
| 548 |
+
* XML_SCHEMAS_TYPE_WHITESPACE_PRESERVE:
|
| 549 |
+
*
|
| 550 |
+
* a whitespace-facet value of "preserve"
|
| 551 |
+
*/
|
| 552 |
+
#define XML_SCHEMAS_TYPE_WHITESPACE_PRESERVE 1 << 24
|
| 553 |
+
/**
|
| 554 |
+
* XML_SCHEMAS_TYPE_WHITESPACE_REPLACE:
|
| 555 |
+
*
|
| 556 |
+
* a whitespace-facet value of "replace"
|
| 557 |
+
*/
|
| 558 |
+
#define XML_SCHEMAS_TYPE_WHITESPACE_REPLACE 1 << 25
|
| 559 |
+
/**
|
| 560 |
+
* XML_SCHEMAS_TYPE_WHITESPACE_COLLAPSE:
|
| 561 |
+
*
|
| 562 |
+
* a whitespace-facet value of "collapse"
|
| 563 |
+
*/
|
| 564 |
+
#define XML_SCHEMAS_TYPE_WHITESPACE_COLLAPSE 1 << 26
|
| 565 |
+
/**
|
| 566 |
+
* XML_SCHEMAS_TYPE_HAS_FACETS:
|
| 567 |
+
*
|
| 568 |
+
* has facets
|
| 569 |
+
*/
|
| 570 |
+
#define XML_SCHEMAS_TYPE_HAS_FACETS 1 << 27
|
| 571 |
+
/**
|
| 572 |
+
* XML_SCHEMAS_TYPE_NORMVALUENEEDED:
|
| 573 |
+
*
|
| 574 |
+
* indicates if the facets (pattern) need a normalized value
|
| 575 |
+
*/
|
| 576 |
+
#define XML_SCHEMAS_TYPE_NORMVALUENEEDED 1 << 28
|
| 577 |
+
|
| 578 |
+
/**
|
| 579 |
+
* XML_SCHEMAS_TYPE_FIXUP_1:
|
| 580 |
+
*
|
| 581 |
+
* First stage of fixup was done.
|
| 582 |
+
*/
|
| 583 |
+
#define XML_SCHEMAS_TYPE_FIXUP_1 1 << 29
|
| 584 |
+
|
| 585 |
+
/**
|
| 586 |
+
* XML_SCHEMAS_TYPE_REDEFINED:
|
| 587 |
+
*
|
| 588 |
+
* The type was redefined.
|
| 589 |
+
*/
|
| 590 |
+
#define XML_SCHEMAS_TYPE_REDEFINED 1 << 30
|
| 591 |
+
/**
|
| 592 |
+
* XML_SCHEMAS_TYPE_REDEFINING:
|
| 593 |
+
*
|
| 594 |
+
* The type redefines an other type.
|
| 595 |
+
*/
|
| 596 |
+
/* #define XML_SCHEMAS_TYPE_REDEFINING 1 << 31 */
|
| 597 |
+
|
| 598 |
+
/**
|
| 599 |
+
* _xmlSchemaType:
|
| 600 |
+
*
|
| 601 |
+
* Schemas type definition.
|
| 602 |
+
*/
|
| 603 |
+
struct _xmlSchemaType {
|
| 604 |
+
xmlSchemaTypeType type; /* The kind of type */
|
| 605 |
+
struct _xmlSchemaType *next; /* the next type if in a sequence ... */
|
| 606 |
+
const xmlChar *name;
|
| 607 |
+
const xmlChar *id ; /* Deprecated; not used */
|
| 608 |
+
const xmlChar *ref; /* Deprecated; not used */
|
| 609 |
+
const xmlChar *refNs; /* Deprecated; not used */
|
| 610 |
+
xmlSchemaAnnotPtr annot;
|
| 611 |
+
xmlSchemaTypePtr subtypes;
|
| 612 |
+
xmlSchemaAttributePtr attributes; /* Deprecated; not used */
|
| 613 |
+
xmlNodePtr node;
|
| 614 |
+
int minOccurs; /* Deprecated; not used */
|
| 615 |
+
int maxOccurs; /* Deprecated; not used */
|
| 616 |
+
|
| 617 |
+
int flags;
|
| 618 |
+
xmlSchemaContentType contentType;
|
| 619 |
+
const xmlChar *base; /* Base type's local name */
|
| 620 |
+
const xmlChar *baseNs; /* Base type's target namespace */
|
| 621 |
+
xmlSchemaTypePtr baseType; /* The base type component */
|
| 622 |
+
xmlSchemaFacetPtr facets; /* Local facets */
|
| 623 |
+
struct _xmlSchemaType *redef; /* Deprecated; not used */
|
| 624 |
+
int recurse; /* Obsolete */
|
| 625 |
+
xmlSchemaAttributeLinkPtr *attributeUses; /* Deprecated; not used */
|
| 626 |
+
xmlSchemaWildcardPtr attributeWildcard;
|
| 627 |
+
int builtInType; /* Type of built-in types. */
|
| 628 |
+
xmlSchemaTypeLinkPtr memberTypes; /* member-types if a union type. */
|
| 629 |
+
xmlSchemaFacetLinkPtr facetSet; /* All facets (incl. inherited) */
|
| 630 |
+
const xmlChar *refPrefix; /* Deprecated; not used */
|
| 631 |
+
xmlSchemaTypePtr contentTypeDef; /* Used for the simple content of complex types.
|
| 632 |
+
Could we use @subtypes for this? */
|
| 633 |
+
xmlRegexpPtr contModel; /* Holds the automaton of the content model */
|
| 634 |
+
const xmlChar *targetNamespace;
|
| 635 |
+
void *attrUses;
|
| 636 |
+
};
|
| 637 |
+
|
| 638 |
+
/*
|
| 639 |
+
* xmlSchemaElement:
|
| 640 |
+
* An element definition.
|
| 641 |
+
*
|
| 642 |
+
* xmlSchemaType, xmlSchemaFacet and xmlSchemaElement start of
|
| 643 |
+
* structures must be kept similar
|
| 644 |
+
*/
|
| 645 |
+
/**
|
| 646 |
+
* XML_SCHEMAS_ELEM_NILLABLE:
|
| 647 |
+
*
|
| 648 |
+
* the element is nillable
|
| 649 |
+
*/
|
| 650 |
+
#define XML_SCHEMAS_ELEM_NILLABLE 1 << 0
|
| 651 |
+
/**
|
| 652 |
+
* XML_SCHEMAS_ELEM_GLOBAL:
|
| 653 |
+
*
|
| 654 |
+
* the element is global
|
| 655 |
+
*/
|
| 656 |
+
#define XML_SCHEMAS_ELEM_GLOBAL 1 << 1
|
| 657 |
+
/**
|
| 658 |
+
* XML_SCHEMAS_ELEM_DEFAULT:
|
| 659 |
+
*
|
| 660 |
+
* the element has a default value
|
| 661 |
+
*/
|
| 662 |
+
#define XML_SCHEMAS_ELEM_DEFAULT 1 << 2
|
| 663 |
+
/**
|
| 664 |
+
* XML_SCHEMAS_ELEM_FIXED:
|
| 665 |
+
*
|
| 666 |
+
* the element has a fixed value
|
| 667 |
+
*/
|
| 668 |
+
#define XML_SCHEMAS_ELEM_FIXED 1 << 3
|
| 669 |
+
/**
|
| 670 |
+
* XML_SCHEMAS_ELEM_ABSTRACT:
|
| 671 |
+
*
|
| 672 |
+
* the element is abstract
|
| 673 |
+
*/
|
| 674 |
+
#define XML_SCHEMAS_ELEM_ABSTRACT 1 << 4
|
| 675 |
+
/**
|
| 676 |
+
* XML_SCHEMAS_ELEM_TOPLEVEL:
|
| 677 |
+
*
|
| 678 |
+
* the element is top level
|
| 679 |
+
* obsolete: use XML_SCHEMAS_ELEM_GLOBAL instead
|
| 680 |
+
*/
|
| 681 |
+
#define XML_SCHEMAS_ELEM_TOPLEVEL 1 << 5
|
| 682 |
+
/**
|
| 683 |
+
* XML_SCHEMAS_ELEM_REF:
|
| 684 |
+
*
|
| 685 |
+
* the element is a reference to a type
|
| 686 |
+
*/
|
| 687 |
+
#define XML_SCHEMAS_ELEM_REF 1 << 6
|
| 688 |
+
/**
|
| 689 |
+
* XML_SCHEMAS_ELEM_NSDEFAULT:
|
| 690 |
+
*
|
| 691 |
+
* allow elements in no namespace
|
| 692 |
+
* Obsolete, not used anymore.
|
| 693 |
+
*/
|
| 694 |
+
#define XML_SCHEMAS_ELEM_NSDEFAULT 1 << 7
|
| 695 |
+
/**
|
| 696 |
+
* XML_SCHEMAS_ELEM_INTERNAL_RESOLVED:
|
| 697 |
+
*
|
| 698 |
+
* this is set when "type", "ref", "substitutionGroup"
|
| 699 |
+
* references have been resolved.
|
| 700 |
+
*/
|
| 701 |
+
#define XML_SCHEMAS_ELEM_INTERNAL_RESOLVED 1 << 8
|
| 702 |
+
/**
|
| 703 |
+
* XML_SCHEMAS_ELEM_CIRCULAR:
|
| 704 |
+
*
|
| 705 |
+
* a helper flag for the search of circular references.
|
| 706 |
+
*/
|
| 707 |
+
#define XML_SCHEMAS_ELEM_CIRCULAR 1 << 9
|
| 708 |
+
/**
|
| 709 |
+
* XML_SCHEMAS_ELEM_BLOCK_ABSENT:
|
| 710 |
+
*
|
| 711 |
+
* the "block" attribute is absent
|
| 712 |
+
*/
|
| 713 |
+
#define XML_SCHEMAS_ELEM_BLOCK_ABSENT 1 << 10
|
| 714 |
+
/**
|
| 715 |
+
* XML_SCHEMAS_ELEM_BLOCK_EXTENSION:
|
| 716 |
+
*
|
| 717 |
+
* disallowed substitutions are absent
|
| 718 |
+
*/
|
| 719 |
+
#define XML_SCHEMAS_ELEM_BLOCK_EXTENSION 1 << 11
|
| 720 |
+
/**
|
| 721 |
+
* XML_SCHEMAS_ELEM_BLOCK_RESTRICTION:
|
| 722 |
+
*
|
| 723 |
+
* disallowed substitutions: "restriction"
|
| 724 |
+
*/
|
| 725 |
+
#define XML_SCHEMAS_ELEM_BLOCK_RESTRICTION 1 << 12
|
| 726 |
+
/**
|
| 727 |
+
* XML_SCHEMAS_ELEM_BLOCK_SUBSTITUTION:
|
| 728 |
+
*
|
| 729 |
+
* disallowed substitutions: "substitution"
|
| 730 |
+
*/
|
| 731 |
+
#define XML_SCHEMAS_ELEM_BLOCK_SUBSTITUTION 1 << 13
|
| 732 |
+
/**
|
| 733 |
+
* XML_SCHEMAS_ELEM_FINAL_ABSENT:
|
| 734 |
+
*
|
| 735 |
+
* substitution group exclusions are absent
|
| 736 |
+
*/
|
| 737 |
+
#define XML_SCHEMAS_ELEM_FINAL_ABSENT 1 << 14
|
| 738 |
+
/**
|
| 739 |
+
* XML_SCHEMAS_ELEM_FINAL_EXTENSION:
|
| 740 |
+
*
|
| 741 |
+
* substitution group exclusions: "extension"
|
| 742 |
+
*/
|
| 743 |
+
#define XML_SCHEMAS_ELEM_FINAL_EXTENSION 1 << 15
|
| 744 |
+
/**
|
| 745 |
+
* XML_SCHEMAS_ELEM_FINAL_RESTRICTION:
|
| 746 |
+
*
|
| 747 |
+
* substitution group exclusions: "restriction"
|
| 748 |
+
*/
|
| 749 |
+
#define XML_SCHEMAS_ELEM_FINAL_RESTRICTION 1 << 16
|
| 750 |
+
/**
|
| 751 |
+
* XML_SCHEMAS_ELEM_SUBST_GROUP_HEAD:
|
| 752 |
+
*
|
| 753 |
+
* the declaration is a substitution group head
|
| 754 |
+
*/
|
| 755 |
+
#define XML_SCHEMAS_ELEM_SUBST_GROUP_HEAD 1 << 17
|
| 756 |
+
/**
|
| 757 |
+
* XML_SCHEMAS_ELEM_INTERNAL_CHECKED:
|
| 758 |
+
*
|
| 759 |
+
* this is set when the elem decl has been checked against
|
| 760 |
+
* all constraints
|
| 761 |
+
*/
|
| 762 |
+
#define XML_SCHEMAS_ELEM_INTERNAL_CHECKED 1 << 18
|
| 763 |
+
|
| 764 |
+
typedef struct _xmlSchemaElement xmlSchemaElement;
|
| 765 |
+
typedef xmlSchemaElement *xmlSchemaElementPtr;
|
| 766 |
+
struct _xmlSchemaElement {
|
| 767 |
+
xmlSchemaTypeType type; /* The kind of type */
|
| 768 |
+
struct _xmlSchemaType *next; /* Not used? */
|
| 769 |
+
const xmlChar *name;
|
| 770 |
+
const xmlChar *id; /* Deprecated; not used */
|
| 771 |
+
const xmlChar *ref; /* Deprecated; not used */
|
| 772 |
+
const xmlChar *refNs; /* Deprecated; not used */
|
| 773 |
+
xmlSchemaAnnotPtr annot;
|
| 774 |
+
xmlSchemaTypePtr subtypes; /* the type definition */
|
| 775 |
+
xmlSchemaAttributePtr attributes;
|
| 776 |
+
xmlNodePtr node;
|
| 777 |
+
int minOccurs; /* Deprecated; not used */
|
| 778 |
+
int maxOccurs; /* Deprecated; not used */
|
| 779 |
+
|
| 780 |
+
int flags;
|
| 781 |
+
const xmlChar *targetNamespace;
|
| 782 |
+
const xmlChar *namedType;
|
| 783 |
+
const xmlChar *namedTypeNs;
|
| 784 |
+
const xmlChar *substGroup;
|
| 785 |
+
const xmlChar *substGroupNs;
|
| 786 |
+
const xmlChar *scope;
|
| 787 |
+
const xmlChar *value; /* The original value of the value constraint. */
|
| 788 |
+
struct _xmlSchemaElement *refDecl; /* This will now be used for the
|
| 789 |
+
substitution group affiliation */
|
| 790 |
+
xmlRegexpPtr contModel; /* Obsolete for WXS, maybe used for RelaxNG */
|
| 791 |
+
xmlSchemaContentType contentType;
|
| 792 |
+
const xmlChar *refPrefix; /* Deprecated; not used */
|
| 793 |
+
xmlSchemaValPtr defVal; /* The compiled value constraint. */
|
| 794 |
+
void *idcs; /* The identity-constraint defs */
|
| 795 |
+
};
|
| 796 |
+
|
| 797 |
+
/*
|
| 798 |
+
* XML_SCHEMAS_FACET_UNKNOWN:
|
| 799 |
+
*
|
| 800 |
+
* unknown facet handling
|
| 801 |
+
*/
|
| 802 |
+
#define XML_SCHEMAS_FACET_UNKNOWN 0
|
| 803 |
+
/*
|
| 804 |
+
* XML_SCHEMAS_FACET_PRESERVE:
|
| 805 |
+
*
|
| 806 |
+
* preserve the type of the facet
|
| 807 |
+
*/
|
| 808 |
+
#define XML_SCHEMAS_FACET_PRESERVE 1
|
| 809 |
+
/*
|
| 810 |
+
* XML_SCHEMAS_FACET_REPLACE:
|
| 811 |
+
*
|
| 812 |
+
* replace the type of the facet
|
| 813 |
+
*/
|
| 814 |
+
#define XML_SCHEMAS_FACET_REPLACE 2
|
| 815 |
+
/*
|
| 816 |
+
* XML_SCHEMAS_FACET_COLLAPSE:
|
| 817 |
+
*
|
| 818 |
+
* collapse the types of the facet
|
| 819 |
+
*/
|
| 820 |
+
#define XML_SCHEMAS_FACET_COLLAPSE 3
|
| 821 |
+
/**
|
| 822 |
+
* A facet definition.
|
| 823 |
+
*/
|
| 824 |
+
struct _xmlSchemaFacet {
|
| 825 |
+
xmlSchemaTypeType type; /* The kind of type */
|
| 826 |
+
struct _xmlSchemaFacet *next;/* the next type if in a sequence ... */
|
| 827 |
+
const xmlChar *value; /* The original value */
|
| 828 |
+
const xmlChar *id; /* Obsolete */
|
| 829 |
+
xmlSchemaAnnotPtr annot;
|
| 830 |
+
xmlNodePtr node;
|
| 831 |
+
int fixed; /* XML_SCHEMAS_FACET_PRESERVE, etc. */
|
| 832 |
+
int whitespace;
|
| 833 |
+
xmlSchemaValPtr val; /* The compiled value */
|
| 834 |
+
xmlRegexpPtr regexp; /* The regex for patterns */
|
| 835 |
+
};
|
| 836 |
+
|
| 837 |
+
/**
|
| 838 |
+
* A notation definition.
|
| 839 |
+
*/
|
| 840 |
+
typedef struct _xmlSchemaNotation xmlSchemaNotation;
|
| 841 |
+
typedef xmlSchemaNotation *xmlSchemaNotationPtr;
|
| 842 |
+
struct _xmlSchemaNotation {
|
| 843 |
+
xmlSchemaTypeType type; /* The kind of type */
|
| 844 |
+
const xmlChar *name;
|
| 845 |
+
xmlSchemaAnnotPtr annot;
|
| 846 |
+
const xmlChar *identifier;
|
| 847 |
+
const xmlChar *targetNamespace;
|
| 848 |
+
};
|
| 849 |
+
|
| 850 |
+
/*
|
| 851 |
+
* TODO: Actually all those flags used for the schema should sit
|
| 852 |
+
* on the schema parser context, since they are used only
|
| 853 |
+
* during parsing an XML schema document, and not available
|
| 854 |
+
* on the component level as per spec.
|
| 855 |
+
*/
|
| 856 |
+
/**
|
| 857 |
+
* XML_SCHEMAS_QUALIF_ELEM:
|
| 858 |
+
*
|
| 859 |
+
* Reflects elementFormDefault == qualified in
|
| 860 |
+
* an XML schema document.
|
| 861 |
+
*/
|
| 862 |
+
#define XML_SCHEMAS_QUALIF_ELEM 1 << 0
|
| 863 |
+
/**
|
| 864 |
+
* XML_SCHEMAS_QUALIF_ATTR:
|
| 865 |
+
*
|
| 866 |
+
* Reflects attributeFormDefault == qualified in
|
| 867 |
+
* an XML schema document.
|
| 868 |
+
*/
|
| 869 |
+
#define XML_SCHEMAS_QUALIF_ATTR 1 << 1
|
| 870 |
+
/**
|
| 871 |
+
* XML_SCHEMAS_FINAL_DEFAULT_EXTENSION:
|
| 872 |
+
*
|
| 873 |
+
* the schema has "extension" in the set of finalDefault.
|
| 874 |
+
*/
|
| 875 |
+
#define XML_SCHEMAS_FINAL_DEFAULT_EXTENSION 1 << 2
|
| 876 |
+
/**
|
| 877 |
+
* XML_SCHEMAS_FINAL_DEFAULT_RESTRICTION:
|
| 878 |
+
*
|
| 879 |
+
* the schema has "restriction" in the set of finalDefault.
|
| 880 |
+
*/
|
| 881 |
+
#define XML_SCHEMAS_FINAL_DEFAULT_RESTRICTION 1 << 3
|
| 882 |
+
/**
|
| 883 |
+
* XML_SCHEMAS_FINAL_DEFAULT_LIST:
|
| 884 |
+
*
|
| 885 |
+
* the schema has "list" in the set of finalDefault.
|
| 886 |
+
*/
|
| 887 |
+
#define XML_SCHEMAS_FINAL_DEFAULT_LIST 1 << 4
|
| 888 |
+
/**
|
| 889 |
+
* XML_SCHEMAS_FINAL_DEFAULT_UNION:
|
| 890 |
+
*
|
| 891 |
+
* the schema has "union" in the set of finalDefault.
|
| 892 |
+
*/
|
| 893 |
+
#define XML_SCHEMAS_FINAL_DEFAULT_UNION 1 << 5
|
| 894 |
+
/**
|
| 895 |
+
* XML_SCHEMAS_BLOCK_DEFAULT_EXTENSION:
|
| 896 |
+
*
|
| 897 |
+
* the schema has "extension" in the set of blockDefault.
|
| 898 |
+
*/
|
| 899 |
+
#define XML_SCHEMAS_BLOCK_DEFAULT_EXTENSION 1 << 6
|
| 900 |
+
/**
|
| 901 |
+
* XML_SCHEMAS_BLOCK_DEFAULT_RESTRICTION:
|
| 902 |
+
*
|
| 903 |
+
* the schema has "restriction" in the set of blockDefault.
|
| 904 |
+
*/
|
| 905 |
+
#define XML_SCHEMAS_BLOCK_DEFAULT_RESTRICTION 1 << 7
|
| 906 |
+
/**
|
| 907 |
+
* XML_SCHEMAS_BLOCK_DEFAULT_SUBSTITUTION:
|
| 908 |
+
*
|
| 909 |
+
* the schema has "substitution" in the set of blockDefault.
|
| 910 |
+
*/
|
| 911 |
+
#define XML_SCHEMAS_BLOCK_DEFAULT_SUBSTITUTION 1 << 8
|
| 912 |
+
/**
|
| 913 |
+
* XML_SCHEMAS_INCLUDING_CONVERT_NS:
|
| 914 |
+
*
|
| 915 |
+
* the schema is currently including an other schema with
|
| 916 |
+
* no target namespace.
|
| 917 |
+
*/
|
| 918 |
+
#define XML_SCHEMAS_INCLUDING_CONVERT_NS 1 << 9
|
| 919 |
+
/**
|
| 920 |
+
* _xmlSchema:
|
| 921 |
+
*
|
| 922 |
+
* A Schemas definition
|
| 923 |
+
*/
|
| 924 |
+
struct _xmlSchema {
|
| 925 |
+
const xmlChar *name; /* schema name */
|
| 926 |
+
const xmlChar *targetNamespace; /* the target namespace */
|
| 927 |
+
const xmlChar *version;
|
| 928 |
+
const xmlChar *id; /* Obsolete */
|
| 929 |
+
xmlDocPtr doc;
|
| 930 |
+
xmlSchemaAnnotPtr annot;
|
| 931 |
+
int flags;
|
| 932 |
+
|
| 933 |
+
xmlHashTablePtr typeDecl;
|
| 934 |
+
xmlHashTablePtr attrDecl;
|
| 935 |
+
xmlHashTablePtr attrgrpDecl;
|
| 936 |
+
xmlHashTablePtr elemDecl;
|
| 937 |
+
xmlHashTablePtr notaDecl;
|
| 938 |
+
|
| 939 |
+
xmlHashTablePtr schemasImports;
|
| 940 |
+
|
| 941 |
+
void *_private; /* unused by the library for users or bindings */
|
| 942 |
+
xmlHashTablePtr groupDecl;
|
| 943 |
+
xmlDictPtr dict;
|
| 944 |
+
void *includes; /* the includes, this is opaque for now */
|
| 945 |
+
int preserve; /* whether to free the document */
|
| 946 |
+
int counter; /* used to give anonymous components unique names */
|
| 947 |
+
xmlHashTablePtr idcDef; /* All identity-constraint defs. */
|
| 948 |
+
void *volatiles; /* Obsolete */
|
| 949 |
+
};
|
| 950 |
+
|
| 951 |
+
XMLPUBFUN void xmlSchemaFreeType (xmlSchemaTypePtr type);
|
| 952 |
+
XMLPUBFUN void xmlSchemaFreeWildcard(xmlSchemaWildcardPtr wildcard);
|
| 953 |
+
|
| 954 |
+
#ifdef __cplusplus
|
| 955 |
+
}
|
| 956 |
+
#endif
|
| 957 |
+
|
| 958 |
+
#endif /* LIBXML_SCHEMAS_ENABLED */
|
| 959 |
+
#endif /* __XML_SCHEMA_INTERNALS_H__ */
|
omnilmm/lib/python3.10/site-packages/lxml/includes/libxml/xlink.h
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Summary: unfinished XLink detection module
|
| 3 |
+
* Description: unfinished XLink detection module
|
| 4 |
+
*
|
| 5 |
+
* Copy: See Copyright for the status of this software.
|
| 6 |
+
*
|
| 7 |
+
* Author: Daniel Veillard
|
| 8 |
+
*/
|
| 9 |
+
|
| 10 |
+
#ifndef __XML_XLINK_H__
|
| 11 |
+
#define __XML_XLINK_H__
|
| 12 |
+
|
| 13 |
+
#include <libxml/xmlversion.h>
|
| 14 |
+
#include <libxml/tree.h>
|
| 15 |
+
|
| 16 |
+
#ifdef LIBXML_XPTR_ENABLED
|
| 17 |
+
|
| 18 |
+
#ifdef __cplusplus
|
| 19 |
+
extern "C" {
|
| 20 |
+
#endif
|
| 21 |
+
|
| 22 |
+
/**
|
| 23 |
+
* Various defines for the various Link properties.
|
| 24 |
+
*
|
| 25 |
+
* NOTE: the link detection layer will try to resolve QName expansion
|
| 26 |
+
* of namespaces. If "foo" is the prefix for "http://foo.com/"
|
| 27 |
+
* then the link detection layer will expand role="foo:myrole"
|
| 28 |
+
* to "http://foo.com/:myrole".
|
| 29 |
+
* NOTE: the link detection layer will expand URI-References found on
|
| 30 |
+
* href attributes by using the base mechanism if found.
|
| 31 |
+
*/
|
| 32 |
+
typedef xmlChar *xlinkHRef;
|
| 33 |
+
typedef xmlChar *xlinkRole;
|
| 34 |
+
typedef xmlChar *xlinkTitle;
|
| 35 |
+
|
| 36 |
+
typedef enum {
|
| 37 |
+
XLINK_TYPE_NONE = 0,
|
| 38 |
+
XLINK_TYPE_SIMPLE,
|
| 39 |
+
XLINK_TYPE_EXTENDED,
|
| 40 |
+
XLINK_TYPE_EXTENDED_SET
|
| 41 |
+
} xlinkType;
|
| 42 |
+
|
| 43 |
+
typedef enum {
|
| 44 |
+
XLINK_SHOW_NONE = 0,
|
| 45 |
+
XLINK_SHOW_NEW,
|
| 46 |
+
XLINK_SHOW_EMBED,
|
| 47 |
+
XLINK_SHOW_REPLACE
|
| 48 |
+
} xlinkShow;
|
| 49 |
+
|
| 50 |
+
typedef enum {
|
| 51 |
+
XLINK_ACTUATE_NONE = 0,
|
| 52 |
+
XLINK_ACTUATE_AUTO,
|
| 53 |
+
XLINK_ACTUATE_ONREQUEST
|
| 54 |
+
} xlinkActuate;
|
| 55 |
+
|
| 56 |
+
/**
|
| 57 |
+
* xlinkNodeDetectFunc:
|
| 58 |
+
* @ctx: user data pointer
|
| 59 |
+
* @node: the node to check
|
| 60 |
+
*
|
| 61 |
+
* This is the prototype for the link detection routine.
|
| 62 |
+
* It calls the default link detection callbacks upon link detection.
|
| 63 |
+
*/
|
| 64 |
+
typedef void (*xlinkNodeDetectFunc) (void *ctx, xmlNodePtr node);
|
| 65 |
+
|
| 66 |
+
/*
|
| 67 |
+
* The link detection module interact with the upper layers using
|
| 68 |
+
* a set of callback registered at parsing time.
|
| 69 |
+
*/
|
| 70 |
+
|
| 71 |
+
/**
|
| 72 |
+
* xlinkSimpleLinkFunk:
|
| 73 |
+
* @ctx: user data pointer
|
| 74 |
+
* @node: the node carrying the link
|
| 75 |
+
* @href: the target of the link
|
| 76 |
+
* @role: the role string
|
| 77 |
+
* @title: the link title
|
| 78 |
+
*
|
| 79 |
+
* This is the prototype for a simple link detection callback.
|
| 80 |
+
*/
|
| 81 |
+
typedef void
|
| 82 |
+
(*xlinkSimpleLinkFunk) (void *ctx,
|
| 83 |
+
xmlNodePtr node,
|
| 84 |
+
const xlinkHRef href,
|
| 85 |
+
const xlinkRole role,
|
| 86 |
+
const xlinkTitle title);
|
| 87 |
+
|
| 88 |
+
/**
|
| 89 |
+
* xlinkExtendedLinkFunk:
|
| 90 |
+
* @ctx: user data pointer
|
| 91 |
+
* @node: the node carrying the link
|
| 92 |
+
* @nbLocators: the number of locators detected on the link
|
| 93 |
+
* @hrefs: pointer to the array of locator hrefs
|
| 94 |
+
* @roles: pointer to the array of locator roles
|
| 95 |
+
* @nbArcs: the number of arcs detected on the link
|
| 96 |
+
* @from: pointer to the array of source roles found on the arcs
|
| 97 |
+
* @to: pointer to the array of target roles found on the arcs
|
| 98 |
+
* @show: array of values for the show attributes found on the arcs
|
| 99 |
+
* @actuate: array of values for the actuate attributes found on the arcs
|
| 100 |
+
* @nbTitles: the number of titles detected on the link
|
| 101 |
+
* @title: array of titles detected on the link
|
| 102 |
+
* @langs: array of xml:lang values for the titles
|
| 103 |
+
*
|
| 104 |
+
* This is the prototype for a extended link detection callback.
|
| 105 |
+
*/
|
| 106 |
+
typedef void
|
| 107 |
+
(*xlinkExtendedLinkFunk)(void *ctx,
|
| 108 |
+
xmlNodePtr node,
|
| 109 |
+
int nbLocators,
|
| 110 |
+
const xlinkHRef *hrefs,
|
| 111 |
+
const xlinkRole *roles,
|
| 112 |
+
int nbArcs,
|
| 113 |
+
const xlinkRole *from,
|
| 114 |
+
const xlinkRole *to,
|
| 115 |
+
xlinkShow *show,
|
| 116 |
+
xlinkActuate *actuate,
|
| 117 |
+
int nbTitles,
|
| 118 |
+
const xlinkTitle *titles,
|
| 119 |
+
const xmlChar **langs);
|
| 120 |
+
|
| 121 |
+
/**
|
| 122 |
+
* xlinkExtendedLinkSetFunk:
|
| 123 |
+
* @ctx: user data pointer
|
| 124 |
+
* @node: the node carrying the link
|
| 125 |
+
* @nbLocators: the number of locators detected on the link
|
| 126 |
+
* @hrefs: pointer to the array of locator hrefs
|
| 127 |
+
* @roles: pointer to the array of locator roles
|
| 128 |
+
* @nbTitles: the number of titles detected on the link
|
| 129 |
+
* @title: array of titles detected on the link
|
| 130 |
+
* @langs: array of xml:lang values for the titles
|
| 131 |
+
*
|
| 132 |
+
* This is the prototype for a extended link set detection callback.
|
| 133 |
+
*/
|
| 134 |
+
typedef void
|
| 135 |
+
(*xlinkExtendedLinkSetFunk) (void *ctx,
|
| 136 |
+
xmlNodePtr node,
|
| 137 |
+
int nbLocators,
|
| 138 |
+
const xlinkHRef *hrefs,
|
| 139 |
+
const xlinkRole *roles,
|
| 140 |
+
int nbTitles,
|
| 141 |
+
const xlinkTitle *titles,
|
| 142 |
+
const xmlChar **langs);
|
| 143 |
+
|
| 144 |
+
/**
|
| 145 |
+
* This is the structure containing a set of Links detection callbacks.
|
| 146 |
+
*
|
| 147 |
+
* There is no default xlink callbacks, if one want to get link
|
| 148 |
+
* recognition activated, those call backs must be provided before parsing.
|
| 149 |
+
*/
|
| 150 |
+
typedef struct _xlinkHandler xlinkHandler;
|
| 151 |
+
typedef xlinkHandler *xlinkHandlerPtr;
|
| 152 |
+
struct _xlinkHandler {
|
| 153 |
+
xlinkSimpleLinkFunk simple;
|
| 154 |
+
xlinkExtendedLinkFunk extended;
|
| 155 |
+
xlinkExtendedLinkSetFunk set;
|
| 156 |
+
};
|
| 157 |
+
|
| 158 |
+
/*
|
| 159 |
+
* The default detection routine, can be overridden, they call the default
|
| 160 |
+
* detection callbacks.
|
| 161 |
+
*/
|
| 162 |
+
|
| 163 |
+
XMLPUBFUN xlinkNodeDetectFunc
|
| 164 |
+
xlinkGetDefaultDetect (void);
|
| 165 |
+
XMLPUBFUN void
|
| 166 |
+
xlinkSetDefaultDetect (xlinkNodeDetectFunc func);
|
| 167 |
+
|
| 168 |
+
/*
|
| 169 |
+
* Routines to set/get the default handlers.
|
| 170 |
+
*/
|
| 171 |
+
XMLPUBFUN xlinkHandlerPtr
|
| 172 |
+
xlinkGetDefaultHandler (void);
|
| 173 |
+
XMLPUBFUN void
|
| 174 |
+
xlinkSetDefaultHandler (xlinkHandlerPtr handler);
|
| 175 |
+
|
| 176 |
+
/*
|
| 177 |
+
* Link detection module itself.
|
| 178 |
+
*/
|
| 179 |
+
XMLPUBFUN xlinkType
|
| 180 |
+
xlinkIsLink (xmlDocPtr doc,
|
| 181 |
+
xmlNodePtr node);
|
| 182 |
+
|
| 183 |
+
#ifdef __cplusplus
|
| 184 |
+
}
|
| 185 |
+
#endif
|
| 186 |
+
|
| 187 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Summary: compile-time version information
|
| 3 |
+
* Description: compile-time version information for the XML library
|
| 4 |
+
*
|
| 5 |
+
* Copy: See Copyright for the status of this software.
|
| 6 |
+
*
|
| 7 |
+
* Author: Daniel Veillard
|
| 8 |
+
*/
|
| 9 |
+
|
| 10 |
+
#ifndef __XML_VERSION_H__
|
| 11 |
+
#define __XML_VERSION_H__
|
| 12 |
+
|
| 13 |
+
#include <libxml/xmlexports.h>
|
| 14 |
+
|
| 15 |
+
#ifdef __cplusplus
|
| 16 |
+
extern "C" {
|
| 17 |
+
#endif
|
| 18 |
+
|
| 19 |
+
/*
|
| 20 |
+
* use those to be sure nothing nasty will happen if
|
| 21 |
+
* your library and includes mismatch
|
| 22 |
+
*/
|
| 23 |
+
#ifndef LIBXML2_COMPILING_MSCCDEF
|
| 24 |
+
XMLPUBFUN void xmlCheckVersion(int version);
|
| 25 |
+
#endif /* LIBXML2_COMPILING_MSCCDEF */
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* LIBXML_DOTTED_VERSION:
|
| 29 |
+
*
|
| 30 |
+
* the version string like "1.2.3"
|
| 31 |
+
*/
|
| 32 |
+
#define LIBXML_DOTTED_VERSION "2.12.9"
|
| 33 |
+
|
| 34 |
+
/**
|
| 35 |
+
* LIBXML_VERSION:
|
| 36 |
+
*
|
| 37 |
+
* the version number: 1.2.3 value is 10203
|
| 38 |
+
*/
|
| 39 |
+
#define LIBXML_VERSION 21209
|
| 40 |
+
|
| 41 |
+
/**
|
| 42 |
+
* LIBXML_VERSION_STRING:
|
| 43 |
+
*
|
| 44 |
+
* the version number string, 1.2.3 value is "10203"
|
| 45 |
+
*/
|
| 46 |
+
#define LIBXML_VERSION_STRING "21209"
|
| 47 |
+
|
| 48 |
+
/**
|
| 49 |
+
* LIBXML_VERSION_EXTRA:
|
| 50 |
+
*
|
| 51 |
+
* extra version information, used to show a git commit description
|
| 52 |
+
*/
|
| 53 |
+
#define LIBXML_VERSION_EXTRA ""
|
| 54 |
+
|
| 55 |
+
/**
|
| 56 |
+
* LIBXML_TEST_VERSION:
|
| 57 |
+
*
|
| 58 |
+
* Macro to check that the libxml version in use is compatible with
|
| 59 |
+
* the version the software has been compiled against
|
| 60 |
+
*/
|
| 61 |
+
#define LIBXML_TEST_VERSION xmlCheckVersion(21209);
|
| 62 |
+
|
| 63 |
+
#ifndef VMS
|
| 64 |
+
#if 0
|
| 65 |
+
/**
|
| 66 |
+
* WITH_TRIO:
|
| 67 |
+
*
|
| 68 |
+
* defined if the trio support need to be configured in
|
| 69 |
+
*/
|
| 70 |
+
#define WITH_TRIO
|
| 71 |
+
#else
|
| 72 |
+
/**
|
| 73 |
+
* WITHOUT_TRIO:
|
| 74 |
+
*
|
| 75 |
+
* defined if the trio support should not be configured in
|
| 76 |
+
*/
|
| 77 |
+
#define WITHOUT_TRIO
|
| 78 |
+
#endif
|
| 79 |
+
#else /* VMS */
|
| 80 |
+
/**
|
| 81 |
+
* WITH_TRIO:
|
| 82 |
+
*
|
| 83 |
+
* defined if the trio support need to be configured in
|
| 84 |
+
*/
|
| 85 |
+
#define WITH_TRIO 1
|
| 86 |
+
#endif /* VMS */
|
| 87 |
+
|
| 88 |
+
/**
|
| 89 |
+
* LIBXML_THREAD_ENABLED:
|
| 90 |
+
*
|
| 91 |
+
* Whether the thread support is configured in
|
| 92 |
+
*/
|
| 93 |
+
#if 1
|
| 94 |
+
#define LIBXML_THREAD_ENABLED
|
| 95 |
+
#endif
|
| 96 |
+
|
| 97 |
+
/**
|
| 98 |
+
* LIBXML_THREAD_ALLOC_ENABLED:
|
| 99 |
+
*
|
| 100 |
+
* Whether the allocation hooks are per-thread
|
| 101 |
+
*/
|
| 102 |
+
#if 0
|
| 103 |
+
#define LIBXML_THREAD_ALLOC_ENABLED
|
| 104 |
+
#endif
|
| 105 |
+
|
| 106 |
+
/**
|
| 107 |
+
* LIBXML_TREE_ENABLED:
|
| 108 |
+
*
|
| 109 |
+
* Whether the DOM like tree manipulation API support is configured in
|
| 110 |
+
*/
|
| 111 |
+
#if 1
|
| 112 |
+
#define LIBXML_TREE_ENABLED
|
| 113 |
+
#endif
|
| 114 |
+
|
| 115 |
+
/**
|
| 116 |
+
* LIBXML_OUTPUT_ENABLED:
|
| 117 |
+
*
|
| 118 |
+
* Whether the serialization/saving support is configured in
|
| 119 |
+
*/
|
| 120 |
+
#if 1
|
| 121 |
+
#define LIBXML_OUTPUT_ENABLED
|
| 122 |
+
#endif
|
| 123 |
+
|
| 124 |
+
/**
|
| 125 |
+
* LIBXML_PUSH_ENABLED:
|
| 126 |
+
*
|
| 127 |
+
* Whether the push parsing interfaces are configured in
|
| 128 |
+
*/
|
| 129 |
+
#if 1
|
| 130 |
+
#define LIBXML_PUSH_ENABLED
|
| 131 |
+
#endif
|
| 132 |
+
|
| 133 |
+
/**
|
| 134 |
+
* LIBXML_READER_ENABLED:
|
| 135 |
+
*
|
| 136 |
+
* Whether the xmlReader parsing interface is configured in
|
| 137 |
+
*/
|
| 138 |
+
#if 1
|
| 139 |
+
#define LIBXML_READER_ENABLED
|
| 140 |
+
#endif
|
| 141 |
+
|
| 142 |
+
/**
|
| 143 |
+
* LIBXML_PATTERN_ENABLED:
|
| 144 |
+
*
|
| 145 |
+
* Whether the xmlPattern node selection interface is configured in
|
| 146 |
+
*/
|
| 147 |
+
#if 1
|
| 148 |
+
#define LIBXML_PATTERN_ENABLED
|
| 149 |
+
#endif
|
| 150 |
+
|
| 151 |
+
/**
|
| 152 |
+
* LIBXML_WRITER_ENABLED:
|
| 153 |
+
*
|
| 154 |
+
* Whether the xmlWriter saving interface is configured in
|
| 155 |
+
*/
|
| 156 |
+
#if 1
|
| 157 |
+
#define LIBXML_WRITER_ENABLED
|
| 158 |
+
#endif
|
| 159 |
+
|
| 160 |
+
/**
|
| 161 |
+
* LIBXML_SAX1_ENABLED:
|
| 162 |
+
*
|
| 163 |
+
* Whether the older SAX1 interface is configured in
|
| 164 |
+
*/
|
| 165 |
+
#if 1
|
| 166 |
+
#define LIBXML_SAX1_ENABLED
|
| 167 |
+
#endif
|
| 168 |
+
|
| 169 |
+
/**
|
| 170 |
+
* LIBXML_FTP_ENABLED:
|
| 171 |
+
*
|
| 172 |
+
* Whether the FTP support is configured in
|
| 173 |
+
*/
|
| 174 |
+
#if 0
|
| 175 |
+
#define LIBXML_FTP_ENABLED
|
| 176 |
+
#endif
|
| 177 |
+
|
| 178 |
+
/**
|
| 179 |
+
* LIBXML_HTTP_ENABLED:
|
| 180 |
+
*
|
| 181 |
+
* Whether the HTTP support is configured in
|
| 182 |
+
*/
|
| 183 |
+
#if 1
|
| 184 |
+
#define LIBXML_HTTP_ENABLED
|
| 185 |
+
#endif
|
| 186 |
+
|
| 187 |
+
/**
|
| 188 |
+
* LIBXML_VALID_ENABLED:
|
| 189 |
+
*
|
| 190 |
+
* Whether the DTD validation support is configured in
|
| 191 |
+
*/
|
| 192 |
+
#if 1
|
| 193 |
+
#define LIBXML_VALID_ENABLED
|
| 194 |
+
#endif
|
| 195 |
+
|
| 196 |
+
/**
|
| 197 |
+
* LIBXML_HTML_ENABLED:
|
| 198 |
+
*
|
| 199 |
+
* Whether the HTML support is configured in
|
| 200 |
+
*/
|
| 201 |
+
#if 1
|
| 202 |
+
#define LIBXML_HTML_ENABLED
|
| 203 |
+
#endif
|
| 204 |
+
|
| 205 |
+
/**
|
| 206 |
+
* LIBXML_LEGACY_ENABLED:
|
| 207 |
+
*
|
| 208 |
+
* Whether the deprecated APIs are compiled in for compatibility
|
| 209 |
+
*/
|
| 210 |
+
#if 0
|
| 211 |
+
#define LIBXML_LEGACY_ENABLED
|
| 212 |
+
#endif
|
| 213 |
+
|
| 214 |
+
/**
|
| 215 |
+
* LIBXML_C14N_ENABLED:
|
| 216 |
+
*
|
| 217 |
+
* Whether the Canonicalization support is configured in
|
| 218 |
+
*/
|
| 219 |
+
#if 1
|
| 220 |
+
#define LIBXML_C14N_ENABLED
|
| 221 |
+
#endif
|
| 222 |
+
|
| 223 |
+
/**
|
| 224 |
+
* LIBXML_CATALOG_ENABLED:
|
| 225 |
+
*
|
| 226 |
+
* Whether the Catalog support is configured in
|
| 227 |
+
*/
|
| 228 |
+
#if 1
|
| 229 |
+
#define LIBXML_CATALOG_ENABLED
|
| 230 |
+
#endif
|
| 231 |
+
|
| 232 |
+
/**
|
| 233 |
+
* LIBXML_XPATH_ENABLED:
|
| 234 |
+
*
|
| 235 |
+
* Whether XPath is configured in
|
| 236 |
+
*/
|
| 237 |
+
#if 1
|
| 238 |
+
#define LIBXML_XPATH_ENABLED
|
| 239 |
+
#endif
|
| 240 |
+
|
| 241 |
+
/**
|
| 242 |
+
* LIBXML_XPTR_ENABLED:
|
| 243 |
+
*
|
| 244 |
+
* Whether XPointer is configured in
|
| 245 |
+
*/
|
| 246 |
+
#if 1
|
| 247 |
+
#define LIBXML_XPTR_ENABLED
|
| 248 |
+
#endif
|
| 249 |
+
|
| 250 |
+
/**
|
| 251 |
+
* LIBXML_XPTR_LOCS_ENABLED:
|
| 252 |
+
*
|
| 253 |
+
* Whether support for XPointer locations is configured in
|
| 254 |
+
*/
|
| 255 |
+
#if 0
|
| 256 |
+
#define LIBXML_XPTR_LOCS_ENABLED
|
| 257 |
+
#endif
|
| 258 |
+
|
| 259 |
+
/**
|
| 260 |
+
* LIBXML_XINCLUDE_ENABLED:
|
| 261 |
+
*
|
| 262 |
+
* Whether XInclude is configured in
|
| 263 |
+
*/
|
| 264 |
+
#if 1
|
| 265 |
+
#define LIBXML_XINCLUDE_ENABLED
|
| 266 |
+
#endif
|
| 267 |
+
|
| 268 |
+
/**
|
| 269 |
+
* LIBXML_ICONV_ENABLED:
|
| 270 |
+
*
|
| 271 |
+
* Whether iconv support is available
|
| 272 |
+
*/
|
| 273 |
+
#if 1
|
| 274 |
+
#define LIBXML_ICONV_ENABLED
|
| 275 |
+
#endif
|
| 276 |
+
|
| 277 |
+
/**
|
| 278 |
+
* LIBXML_ICU_ENABLED:
|
| 279 |
+
*
|
| 280 |
+
* Whether icu support is available
|
| 281 |
+
*/
|
| 282 |
+
#if 0
|
| 283 |
+
#define LIBXML_ICU_ENABLED
|
| 284 |
+
#endif
|
| 285 |
+
|
| 286 |
+
/**
|
| 287 |
+
* LIBXML_ISO8859X_ENABLED:
|
| 288 |
+
*
|
| 289 |
+
* Whether ISO-8859-* support is made available in case iconv is not
|
| 290 |
+
*/
|
| 291 |
+
#if 1
|
| 292 |
+
#define LIBXML_ISO8859X_ENABLED
|
| 293 |
+
#endif
|
| 294 |
+
|
| 295 |
+
/**
|
| 296 |
+
* LIBXML_DEBUG_ENABLED:
|
| 297 |
+
*
|
| 298 |
+
* Whether Debugging module is configured in
|
| 299 |
+
*/
|
| 300 |
+
#if 1
|
| 301 |
+
#define LIBXML_DEBUG_ENABLED
|
| 302 |
+
#endif
|
| 303 |
+
|
| 304 |
+
/**
|
| 305 |
+
* DEBUG_MEMORY_LOCATION:
|
| 306 |
+
*
|
| 307 |
+
* Whether the memory debugging is configured in
|
| 308 |
+
*/
|
| 309 |
+
#if 0
|
| 310 |
+
#define DEBUG_MEMORY_LOCATION
|
| 311 |
+
#endif
|
| 312 |
+
|
| 313 |
+
/**
|
| 314 |
+
* LIBXML_DEBUG_RUNTIME:
|
| 315 |
+
*
|
| 316 |
+
* Removed
|
| 317 |
+
*/
|
| 318 |
+
#if 0
|
| 319 |
+
#define LIBXML_DEBUG_RUNTIME
|
| 320 |
+
#endif
|
| 321 |
+
|
| 322 |
+
/**
|
| 323 |
+
* LIBXML_UNICODE_ENABLED:
|
| 324 |
+
*
|
| 325 |
+
* Whether the Unicode related interfaces are compiled in
|
| 326 |
+
*/
|
| 327 |
+
#if 1
|
| 328 |
+
#define LIBXML_UNICODE_ENABLED
|
| 329 |
+
#endif
|
| 330 |
+
|
| 331 |
+
/**
|
| 332 |
+
* LIBXML_REGEXP_ENABLED:
|
| 333 |
+
*
|
| 334 |
+
* Whether the regular expressions interfaces are compiled in
|
| 335 |
+
*/
|
| 336 |
+
#if 1
|
| 337 |
+
#define LIBXML_REGEXP_ENABLED
|
| 338 |
+
#endif
|
| 339 |
+
|
| 340 |
+
/**
|
| 341 |
+
* LIBXML_AUTOMATA_ENABLED:
|
| 342 |
+
*
|
| 343 |
+
* Whether the automata interfaces are compiled in
|
| 344 |
+
*/
|
| 345 |
+
#if 1
|
| 346 |
+
#define LIBXML_AUTOMATA_ENABLED
|
| 347 |
+
#endif
|
| 348 |
+
|
| 349 |
+
/**
|
| 350 |
+
* LIBXML_EXPR_ENABLED:
|
| 351 |
+
*
|
| 352 |
+
* Whether the formal expressions interfaces are compiled in
|
| 353 |
+
*
|
| 354 |
+
* This code is unused and disabled unconditionally for now.
|
| 355 |
+
*/
|
| 356 |
+
#if 0
|
| 357 |
+
#define LIBXML_EXPR_ENABLED
|
| 358 |
+
#endif
|
| 359 |
+
|
| 360 |
+
/**
|
| 361 |
+
* LIBXML_SCHEMAS_ENABLED:
|
| 362 |
+
*
|
| 363 |
+
* Whether the Schemas validation interfaces are compiled in
|
| 364 |
+
*/
|
| 365 |
+
#if 1
|
| 366 |
+
#define LIBXML_SCHEMAS_ENABLED
|
| 367 |
+
#endif
|
| 368 |
+
|
| 369 |
+
/**
|
| 370 |
+
* LIBXML_SCHEMATRON_ENABLED:
|
| 371 |
+
*
|
| 372 |
+
* Whether the Schematron validation interfaces are compiled in
|
| 373 |
+
*/
|
| 374 |
+
#if 1
|
| 375 |
+
#define LIBXML_SCHEMATRON_ENABLED
|
| 376 |
+
#endif
|
| 377 |
+
|
| 378 |
+
/**
|
| 379 |
+
* LIBXML_MODULES_ENABLED:
|
| 380 |
+
*
|
| 381 |
+
* Whether the module interfaces are compiled in
|
| 382 |
+
*/
|
| 383 |
+
#if 1
|
| 384 |
+
#define LIBXML_MODULES_ENABLED
|
| 385 |
+
/**
|
| 386 |
+
* LIBXML_MODULE_EXTENSION:
|
| 387 |
+
*
|
| 388 |
+
* the string suffix used by dynamic modules (usually shared libraries)
|
| 389 |
+
*/
|
| 390 |
+
#define LIBXML_MODULE_EXTENSION ".so"
|
| 391 |
+
#endif
|
| 392 |
+
|
| 393 |
+
/**
|
| 394 |
+
* LIBXML_ZLIB_ENABLED:
|
| 395 |
+
*
|
| 396 |
+
* Whether the Zlib support is compiled in
|
| 397 |
+
*/
|
| 398 |
+
#if 1
|
| 399 |
+
#define LIBXML_ZLIB_ENABLED
|
| 400 |
+
#endif
|
| 401 |
+
|
| 402 |
+
/**
|
| 403 |
+
* LIBXML_LZMA_ENABLED:
|
| 404 |
+
*
|
| 405 |
+
* Whether the Lzma support is compiled in
|
| 406 |
+
*/
|
| 407 |
+
#if 0
|
| 408 |
+
#define LIBXML_LZMA_ENABLED
|
| 409 |
+
#endif
|
| 410 |
+
|
| 411 |
+
#ifdef __GNUC__
|
| 412 |
+
/** DOC_DISABLE */
|
| 413 |
+
|
| 414 |
+
#ifndef ATTRIBUTE_UNUSED
|
| 415 |
+
# if ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7)))
|
| 416 |
+
# define ATTRIBUTE_UNUSED __attribute__((unused))
|
| 417 |
+
# else
|
| 418 |
+
# define ATTRIBUTE_UNUSED
|
| 419 |
+
# endif
|
| 420 |
+
#endif
|
| 421 |
+
|
| 422 |
+
#ifndef LIBXML_ATTR_ALLOC_SIZE
|
| 423 |
+
# if (!defined(__clang__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3))))
|
| 424 |
+
# define LIBXML_ATTR_ALLOC_SIZE(x) __attribute__((alloc_size(x)))
|
| 425 |
+
# else
|
| 426 |
+
# define LIBXML_ATTR_ALLOC_SIZE(x)
|
| 427 |
+
# endif
|
| 428 |
+
#else
|
| 429 |
+
# define LIBXML_ATTR_ALLOC_SIZE(x)
|
| 430 |
+
#endif
|
| 431 |
+
|
| 432 |
+
#ifndef LIBXML_ATTR_FORMAT
|
| 433 |
+
# if ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)))
|
| 434 |
+
# define LIBXML_ATTR_FORMAT(fmt,args) __attribute__((__format__(__printf__,fmt,args)))
|
| 435 |
+
# else
|
| 436 |
+
# define LIBXML_ATTR_FORMAT(fmt,args)
|
| 437 |
+
# endif
|
| 438 |
+
#else
|
| 439 |
+
# define LIBXML_ATTR_FORMAT(fmt,args)
|
| 440 |
+
#endif
|
| 441 |
+
|
| 442 |
+
#ifndef XML_DEPRECATED
|
| 443 |
+
# if defined (IN_LIBXML) || (__GNUC__ * 100 + __GNUC_MINOR__ < 301)
|
| 444 |
+
# define XML_DEPRECATED
|
| 445 |
+
/* Available since at least GCC 3.1 */
|
| 446 |
+
# else
|
| 447 |
+
# define XML_DEPRECATED __attribute__((deprecated))
|
| 448 |
+
# endif
|
| 449 |
+
#endif
|
| 450 |
+
|
| 451 |
+
#if defined(__clang__) || (__GNUC__ * 100 + __GNUC_MINOR__ >= 406)
|
| 452 |
+
#if defined(__clang__) || (__GNUC__ * 100 + __GNUC_MINOR__ >= 800)
|
| 453 |
+
#define XML_IGNORE_FPTR_CAST_WARNINGS \
|
| 454 |
+
_Pragma("GCC diagnostic push") \
|
| 455 |
+
_Pragma("GCC diagnostic ignored \"-Wpedantic\"") \
|
| 456 |
+
_Pragma("GCC diagnostic ignored \"-Wcast-function-type\"")
|
| 457 |
+
#else
|
| 458 |
+
#define XML_IGNORE_FPTR_CAST_WARNINGS \
|
| 459 |
+
_Pragma("GCC diagnostic push") \
|
| 460 |
+
_Pragma("GCC diagnostic ignored \"-Wpedantic\"")
|
| 461 |
+
#endif
|
| 462 |
+
#define XML_POP_WARNINGS \
|
| 463 |
+
_Pragma("GCC diagnostic pop")
|
| 464 |
+
#else
|
| 465 |
+
#define XML_IGNORE_FPTR_CAST_WARNINGS
|
| 466 |
+
#define XML_POP_WARNINGS
|
| 467 |
+
#endif
|
| 468 |
+
|
| 469 |
+
#else /* ! __GNUC__ */
|
| 470 |
+
#define ATTRIBUTE_UNUSED
|
| 471 |
+
#define LIBXML_ATTR_ALLOC_SIZE(x)
|
| 472 |
+
#define LIBXML_ATTR_FORMAT(fmt,args)
|
| 473 |
+
#ifndef XML_DEPRECATED
|
| 474 |
+
# if defined (IN_LIBXML) || !defined (_MSC_VER)
|
| 475 |
+
# define XML_DEPRECATED
|
| 476 |
+
/* Available since Visual Studio 2005 */
|
| 477 |
+
# elif defined (_MSC_VER) && (_MSC_VER >= 1400)
|
| 478 |
+
# define XML_DEPRECATED __declspec(deprecated)
|
| 479 |
+
# endif
|
| 480 |
+
#endif
|
| 481 |
+
#if defined (_MSC_VER) && (_MSC_VER >= 1400)
|
| 482 |
+
# define XML_IGNORE_FPTR_CAST_WARNINGS __pragma(warning(push))
|
| 483 |
+
#else
|
| 484 |
+
# define XML_IGNORE_FPTR_CAST_WARNINGS
|
| 485 |
+
#endif
|
| 486 |
+
#ifndef XML_POP_WARNINGS
|
| 487 |
+
# if defined (_MSC_VER) && (_MSC_VER >= 1400)
|
| 488 |
+
# define XML_POP_WARNINGS __pragma(warning(pop))
|
| 489 |
+
# else
|
| 490 |
+
# define XML_POP_WARNINGS
|
| 491 |
+
# endif
|
| 492 |
+
#endif
|
| 493 |
+
#endif /* __GNUC__ */
|
| 494 |
+
|
| 495 |
+
#define XML_NO_ATTR
|
| 496 |
+
|
| 497 |
+
#ifdef LIBXML_THREAD_ENABLED
|
| 498 |
+
#define XML_DECLARE_GLOBAL(name, type, attrs) \
|
| 499 |
+
attrs XMLPUBFUN type *__##name(void);
|
| 500 |
+
#define XML_GLOBAL_MACRO(name) (*__##name())
|
| 501 |
+
#else
|
| 502 |
+
#define XML_DECLARE_GLOBAL(name, type, attrs) \
|
| 503 |
+
attrs XMLPUBVAR type name;
|
| 504 |
+
#endif
|
| 505 |
+
|
| 506 |
+
#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|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Summary: text writing API for XML
|
| 3 |
+
* Description: text writing API for XML
|
| 4 |
+
*
|
| 5 |
+
* Copy: See Copyright for the status of this software.
|
| 6 |
+
*
|
| 7 |
+
* Author: Alfred Mickautsch <alfred@mickautsch.de>
|
| 8 |
+
*/
|
| 9 |
+
|
| 10 |
+
#ifndef __XML_XMLWRITER_H__
|
| 11 |
+
#define __XML_XMLWRITER_H__
|
| 12 |
+
|
| 13 |
+
#include <libxml/xmlversion.h>
|
| 14 |
+
|
| 15 |
+
#ifdef LIBXML_WRITER_ENABLED
|
| 16 |
+
|
| 17 |
+
#include <stdarg.h>
|
| 18 |
+
#include <libxml/xmlIO.h>
|
| 19 |
+
#include <libxml/list.h>
|
| 20 |
+
#include <libxml/xmlstring.h>
|
| 21 |
+
|
| 22 |
+
#ifdef __cplusplus
|
| 23 |
+
extern "C" {
|
| 24 |
+
#endif
|
| 25 |
+
|
| 26 |
+
typedef struct _xmlTextWriter xmlTextWriter;
|
| 27 |
+
typedef xmlTextWriter *xmlTextWriterPtr;
|
| 28 |
+
|
| 29 |
+
/*
|
| 30 |
+
* Constructors & Destructor
|
| 31 |
+
*/
|
| 32 |
+
XMLPUBFUN xmlTextWriterPtr
|
| 33 |
+
xmlNewTextWriter(xmlOutputBufferPtr out);
|
| 34 |
+
XMLPUBFUN xmlTextWriterPtr
|
| 35 |
+
xmlNewTextWriterFilename(const char *uri, int compression);
|
| 36 |
+
XMLPUBFUN xmlTextWriterPtr
|
| 37 |
+
xmlNewTextWriterMemory(xmlBufferPtr buf, int compression);
|
| 38 |
+
XMLPUBFUN xmlTextWriterPtr
|
| 39 |
+
xmlNewTextWriterPushParser(xmlParserCtxtPtr ctxt, int compression);
|
| 40 |
+
XMLPUBFUN xmlTextWriterPtr
|
| 41 |
+
xmlNewTextWriterDoc(xmlDocPtr * doc, int compression);
|
| 42 |
+
XMLPUBFUN xmlTextWriterPtr
|
| 43 |
+
xmlNewTextWriterTree(xmlDocPtr doc, xmlNodePtr node,
|
| 44 |
+
int compression);
|
| 45 |
+
XMLPUBFUN void xmlFreeTextWriter(xmlTextWriterPtr writer);
|
| 46 |
+
|
| 47 |
+
/*
|
| 48 |
+
* Functions
|
| 49 |
+
*/
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
/*
|
| 53 |
+
* Document
|
| 54 |
+
*/
|
| 55 |
+
XMLPUBFUN int
|
| 56 |
+
xmlTextWriterStartDocument(xmlTextWriterPtr writer,
|
| 57 |
+
const char *version,
|
| 58 |
+
const char *encoding,
|
| 59 |
+
const char *standalone);
|
| 60 |
+
XMLPUBFUN int xmlTextWriterEndDocument(xmlTextWriterPtr
|
| 61 |
+
writer);
|
| 62 |
+
|
| 63 |
+
/*
|
| 64 |
+
* Comments
|
| 65 |
+
*/
|
| 66 |
+
XMLPUBFUN int xmlTextWriterStartComment(xmlTextWriterPtr
|
| 67 |
+
writer);
|
| 68 |
+
XMLPUBFUN int xmlTextWriterEndComment(xmlTextWriterPtr writer);
|
| 69 |
+
XMLPUBFUN int
|
| 70 |
+
xmlTextWriterWriteFormatComment(xmlTextWriterPtr writer,
|
| 71 |
+
const char *format, ...)
|
| 72 |
+
LIBXML_ATTR_FORMAT(2,3);
|
| 73 |
+
XMLPUBFUN int
|
| 74 |
+
xmlTextWriterWriteVFormatComment(xmlTextWriterPtr writer,
|
| 75 |
+
const char *format,
|
| 76 |
+
va_list argptr)
|
| 77 |
+
LIBXML_ATTR_FORMAT(2,0);
|
| 78 |
+
XMLPUBFUN int xmlTextWriterWriteComment(xmlTextWriterPtr
|
| 79 |
+
writer,
|
| 80 |
+
const xmlChar *
|
| 81 |
+
content);
|
| 82 |
+
|
| 83 |
+
/*
|
| 84 |
+
* Elements
|
| 85 |
+
*/
|
| 86 |
+
XMLPUBFUN int
|
| 87 |
+
xmlTextWriterStartElement(xmlTextWriterPtr writer,
|
| 88 |
+
const xmlChar * name);
|
| 89 |
+
XMLPUBFUN int xmlTextWriterStartElementNS(xmlTextWriterPtr
|
| 90 |
+
writer,
|
| 91 |
+
const xmlChar *
|
| 92 |
+
prefix,
|
| 93 |
+
const xmlChar * name,
|
| 94 |
+
const xmlChar *
|
| 95 |
+
namespaceURI);
|
| 96 |
+
XMLPUBFUN int xmlTextWriterEndElement(xmlTextWriterPtr writer);
|
| 97 |
+
XMLPUBFUN int xmlTextWriterFullEndElement(xmlTextWriterPtr
|
| 98 |
+
writer);
|
| 99 |
+
|
| 100 |
+
/*
|
| 101 |
+
* Elements conveniency functions
|
| 102 |
+
*/
|
| 103 |
+
XMLPUBFUN int
|
| 104 |
+
xmlTextWriterWriteFormatElement(xmlTextWriterPtr writer,
|
| 105 |
+
const xmlChar * name,
|
| 106 |
+
const char *format, ...)
|
| 107 |
+
LIBXML_ATTR_FORMAT(3,4);
|
| 108 |
+
XMLPUBFUN int
|
| 109 |
+
xmlTextWriterWriteVFormatElement(xmlTextWriterPtr writer,
|
| 110 |
+
const xmlChar * name,
|
| 111 |
+
const char *format,
|
| 112 |
+
va_list argptr)
|
| 113 |
+
LIBXML_ATTR_FORMAT(3,0);
|
| 114 |
+
XMLPUBFUN int xmlTextWriterWriteElement(xmlTextWriterPtr
|
| 115 |
+
writer,
|
| 116 |
+
const xmlChar * name,
|
| 117 |
+
const xmlChar *
|
| 118 |
+
content);
|
| 119 |
+
XMLPUBFUN int
|
| 120 |
+
xmlTextWriterWriteFormatElementNS(xmlTextWriterPtr writer,
|
| 121 |
+
const xmlChar * prefix,
|
| 122 |
+
const xmlChar * name,
|
| 123 |
+
const xmlChar * namespaceURI,
|
| 124 |
+
const char *format, ...)
|
| 125 |
+
LIBXML_ATTR_FORMAT(5,6);
|
| 126 |
+
XMLPUBFUN int
|
| 127 |
+
xmlTextWriterWriteVFormatElementNS(xmlTextWriterPtr writer,
|
| 128 |
+
const xmlChar * prefix,
|
| 129 |
+
const xmlChar * name,
|
| 130 |
+
const xmlChar * namespaceURI,
|
| 131 |
+
const char *format,
|
| 132 |
+
va_list argptr)
|
| 133 |
+
LIBXML_ATTR_FORMAT(5,0);
|
| 134 |
+
XMLPUBFUN int xmlTextWriterWriteElementNS(xmlTextWriterPtr
|
| 135 |
+
writer,
|
| 136 |
+
const xmlChar *
|
| 137 |
+
prefix,
|
| 138 |
+
const xmlChar * name,
|
| 139 |
+
const xmlChar *
|
| 140 |
+
namespaceURI,
|
| 141 |
+
const xmlChar *
|
| 142 |
+
content);
|
| 143 |
+
|
| 144 |
+
/*
|
| 145 |
+
* Text
|
| 146 |
+
*/
|
| 147 |
+
XMLPUBFUN int
|
| 148 |
+
xmlTextWriterWriteFormatRaw(xmlTextWriterPtr writer,
|
| 149 |
+
const char *format, ...)
|
| 150 |
+
LIBXML_ATTR_FORMAT(2,3);
|
| 151 |
+
XMLPUBFUN int
|
| 152 |
+
xmlTextWriterWriteVFormatRaw(xmlTextWriterPtr writer,
|
| 153 |
+
const char *format, va_list argptr)
|
| 154 |
+
LIBXML_ATTR_FORMAT(2,0);
|
| 155 |
+
XMLPUBFUN int
|
| 156 |
+
xmlTextWriterWriteRawLen(xmlTextWriterPtr writer,
|
| 157 |
+
const xmlChar * content, int len);
|
| 158 |
+
XMLPUBFUN int
|
| 159 |
+
xmlTextWriterWriteRaw(xmlTextWriterPtr writer,
|
| 160 |
+
const xmlChar * content);
|
| 161 |
+
XMLPUBFUN int xmlTextWriterWriteFormatString(xmlTextWriterPtr
|
| 162 |
+
writer,
|
| 163 |
+
const char
|
| 164 |
+
*format, ...)
|
| 165 |
+
LIBXML_ATTR_FORMAT(2,3);
|
| 166 |
+
XMLPUBFUN int xmlTextWriterWriteVFormatString(xmlTextWriterPtr
|
| 167 |
+
writer,
|
| 168 |
+
const char
|
| 169 |
+
*format,
|
| 170 |
+
va_list argptr)
|
| 171 |
+
LIBXML_ATTR_FORMAT(2,0);
|
| 172 |
+
XMLPUBFUN int xmlTextWriterWriteString(xmlTextWriterPtr writer,
|
| 173 |
+
const xmlChar *
|
| 174 |
+
content);
|
| 175 |
+
XMLPUBFUN int xmlTextWriterWriteBase64(xmlTextWriterPtr writer,
|
| 176 |
+
const char *data,
|
| 177 |
+
int start, int len);
|
| 178 |
+
XMLPUBFUN int xmlTextWriterWriteBinHex(xmlTextWriterPtr writer,
|
| 179 |
+
const char *data,
|
| 180 |
+
int start, int len);
|
| 181 |
+
|
| 182 |
+
/*
|
| 183 |
+
* Attributes
|
| 184 |
+
*/
|
| 185 |
+
XMLPUBFUN int
|
| 186 |
+
xmlTextWriterStartAttribute(xmlTextWriterPtr writer,
|
| 187 |
+
const xmlChar * name);
|
| 188 |
+
XMLPUBFUN int xmlTextWriterStartAttributeNS(xmlTextWriterPtr
|
| 189 |
+
writer,
|
| 190 |
+
const xmlChar *
|
| 191 |
+
prefix,
|
| 192 |
+
const xmlChar *
|
| 193 |
+
name,
|
| 194 |
+
const xmlChar *
|
| 195 |
+
namespaceURI);
|
| 196 |
+
XMLPUBFUN int xmlTextWriterEndAttribute(xmlTextWriterPtr
|
| 197 |
+
writer);
|
| 198 |
+
|
| 199 |
+
/*
|
| 200 |
+
* Attributes conveniency functions
|
| 201 |
+
*/
|
| 202 |
+
XMLPUBFUN int
|
| 203 |
+
xmlTextWriterWriteFormatAttribute(xmlTextWriterPtr writer,
|
| 204 |
+
const xmlChar * name,
|
| 205 |
+
const char *format, ...)
|
| 206 |
+
LIBXML_ATTR_FORMAT(3,4);
|
| 207 |
+
XMLPUBFUN int
|
| 208 |
+
xmlTextWriterWriteVFormatAttribute(xmlTextWriterPtr writer,
|
| 209 |
+
const xmlChar * name,
|
| 210 |
+
const char *format,
|
| 211 |
+
va_list argptr)
|
| 212 |
+
LIBXML_ATTR_FORMAT(3,0);
|
| 213 |
+
XMLPUBFUN int xmlTextWriterWriteAttribute(xmlTextWriterPtr
|
| 214 |
+
writer,
|
| 215 |
+
const xmlChar * name,
|
| 216 |
+
const xmlChar *
|
| 217 |
+
content);
|
| 218 |
+
XMLPUBFUN int
|
| 219 |
+
xmlTextWriterWriteFormatAttributeNS(xmlTextWriterPtr writer,
|
| 220 |
+
const xmlChar * prefix,
|
| 221 |
+
const xmlChar * name,
|
| 222 |
+
const xmlChar * namespaceURI,
|
| 223 |
+
const char *format, ...)
|
| 224 |
+
LIBXML_ATTR_FORMAT(5,6);
|
| 225 |
+
XMLPUBFUN int
|
| 226 |
+
xmlTextWriterWriteVFormatAttributeNS(xmlTextWriterPtr writer,
|
| 227 |
+
const xmlChar * prefix,
|
| 228 |
+
const xmlChar * name,
|
| 229 |
+
const xmlChar * namespaceURI,
|
| 230 |
+
const char *format,
|
| 231 |
+
va_list argptr)
|
| 232 |
+
LIBXML_ATTR_FORMAT(5,0);
|
| 233 |
+
XMLPUBFUN int xmlTextWriterWriteAttributeNS(xmlTextWriterPtr
|
| 234 |
+
writer,
|
| 235 |
+
const xmlChar *
|
| 236 |
+
prefix,
|
| 237 |
+
const xmlChar *
|
| 238 |
+
name,
|
| 239 |
+
const xmlChar *
|
| 240 |
+
namespaceURI,
|
| 241 |
+
const xmlChar *
|
| 242 |
+
content);
|
| 243 |
+
|
| 244 |
+
/*
|
| 245 |
+
* PI's
|
| 246 |
+
*/
|
| 247 |
+
XMLPUBFUN int
|
| 248 |
+
xmlTextWriterStartPI(xmlTextWriterPtr writer,
|
| 249 |
+
const xmlChar * target);
|
| 250 |
+
XMLPUBFUN int xmlTextWriterEndPI(xmlTextWriterPtr writer);
|
| 251 |
+
|
| 252 |
+
/*
|
| 253 |
+
* PI conveniency functions
|
| 254 |
+
*/
|
| 255 |
+
XMLPUBFUN int
|
| 256 |
+
xmlTextWriterWriteFormatPI(xmlTextWriterPtr writer,
|
| 257 |
+
const xmlChar * target,
|
| 258 |
+
const char *format, ...)
|
| 259 |
+
LIBXML_ATTR_FORMAT(3,4);
|
| 260 |
+
XMLPUBFUN int
|
| 261 |
+
xmlTextWriterWriteVFormatPI(xmlTextWriterPtr writer,
|
| 262 |
+
const xmlChar * target,
|
| 263 |
+
const char *format, va_list argptr)
|
| 264 |
+
LIBXML_ATTR_FORMAT(3,0);
|
| 265 |
+
XMLPUBFUN int
|
| 266 |
+
xmlTextWriterWritePI(xmlTextWriterPtr writer,
|
| 267 |
+
const xmlChar * target,
|
| 268 |
+
const xmlChar * content);
|
| 269 |
+
|
| 270 |
+
/**
|
| 271 |
+
* xmlTextWriterWriteProcessingInstruction:
|
| 272 |
+
*
|
| 273 |
+
* This macro maps to xmlTextWriterWritePI
|
| 274 |
+
*/
|
| 275 |
+
#define xmlTextWriterWriteProcessingInstruction xmlTextWriterWritePI
|
| 276 |
+
|
| 277 |
+
/*
|
| 278 |
+
* CDATA
|
| 279 |
+
*/
|
| 280 |
+
XMLPUBFUN int xmlTextWriterStartCDATA(xmlTextWriterPtr writer);
|
| 281 |
+
XMLPUBFUN int xmlTextWriterEndCDATA(xmlTextWriterPtr writer);
|
| 282 |
+
|
| 283 |
+
/*
|
| 284 |
+
* CDATA conveniency functions
|
| 285 |
+
*/
|
| 286 |
+
XMLPUBFUN int
|
| 287 |
+
xmlTextWriterWriteFormatCDATA(xmlTextWriterPtr writer,
|
| 288 |
+
const char *format, ...)
|
| 289 |
+
LIBXML_ATTR_FORMAT(2,3);
|
| 290 |
+
XMLPUBFUN int
|
| 291 |
+
xmlTextWriterWriteVFormatCDATA(xmlTextWriterPtr writer,
|
| 292 |
+
const char *format, va_list argptr)
|
| 293 |
+
LIBXML_ATTR_FORMAT(2,0);
|
| 294 |
+
XMLPUBFUN int
|
| 295 |
+
xmlTextWriterWriteCDATA(xmlTextWriterPtr writer,
|
| 296 |
+
const xmlChar * content);
|
| 297 |
+
|
| 298 |
+
/*
|
| 299 |
+
* DTD
|
| 300 |
+
*/
|
| 301 |
+
XMLPUBFUN int
|
| 302 |
+
xmlTextWriterStartDTD(xmlTextWriterPtr writer,
|
| 303 |
+
const xmlChar * name,
|
| 304 |
+
const xmlChar * pubid,
|
| 305 |
+
const xmlChar * sysid);
|
| 306 |
+
XMLPUBFUN int xmlTextWriterEndDTD(xmlTextWriterPtr writer);
|
| 307 |
+
|
| 308 |
+
/*
|
| 309 |
+
* DTD conveniency functions
|
| 310 |
+
*/
|
| 311 |
+
XMLPUBFUN int
|
| 312 |
+
xmlTextWriterWriteFormatDTD(xmlTextWriterPtr writer,
|
| 313 |
+
const xmlChar * name,
|
| 314 |
+
const xmlChar * pubid,
|
| 315 |
+
const xmlChar * sysid,
|
| 316 |
+
const char *format, ...)
|
| 317 |
+
LIBXML_ATTR_FORMAT(5,6);
|
| 318 |
+
XMLPUBFUN int
|
| 319 |
+
xmlTextWriterWriteVFormatDTD(xmlTextWriterPtr writer,
|
| 320 |
+
const xmlChar * name,
|
| 321 |
+
const xmlChar * pubid,
|
| 322 |
+
const xmlChar * sysid,
|
| 323 |
+
const char *format, va_list argptr)
|
| 324 |
+
LIBXML_ATTR_FORMAT(5,0);
|
| 325 |
+
XMLPUBFUN int
|
| 326 |
+
xmlTextWriterWriteDTD(xmlTextWriterPtr writer,
|
| 327 |
+
const xmlChar * name,
|
| 328 |
+
const xmlChar * pubid,
|
| 329 |
+
const xmlChar * sysid,
|
| 330 |
+
const xmlChar * subset);
|
| 331 |
+
|
| 332 |
+
/**
|
| 333 |
+
* xmlTextWriterWriteDocType:
|
| 334 |
+
*
|
| 335 |
+
* this macro maps to xmlTextWriterWriteDTD
|
| 336 |
+
*/
|
| 337 |
+
#define xmlTextWriterWriteDocType xmlTextWriterWriteDTD
|
| 338 |
+
|
| 339 |
+
/*
|
| 340 |
+
* DTD element definition
|
| 341 |
+
*/
|
| 342 |
+
XMLPUBFUN int
|
| 343 |
+
xmlTextWriterStartDTDElement(xmlTextWriterPtr writer,
|
| 344 |
+
const xmlChar * name);
|
| 345 |
+
XMLPUBFUN int xmlTextWriterEndDTDElement(xmlTextWriterPtr
|
| 346 |
+
writer);
|
| 347 |
+
|
| 348 |
+
/*
|
| 349 |
+
* DTD element definition conveniency functions
|
| 350 |
+
*/
|
| 351 |
+
XMLPUBFUN int
|
| 352 |
+
xmlTextWriterWriteFormatDTDElement(xmlTextWriterPtr writer,
|
| 353 |
+
const xmlChar * name,
|
| 354 |
+
const char *format, ...)
|
| 355 |
+
LIBXML_ATTR_FORMAT(3,4);
|
| 356 |
+
XMLPUBFUN int
|
| 357 |
+
xmlTextWriterWriteVFormatDTDElement(xmlTextWriterPtr writer,
|
| 358 |
+
const xmlChar * name,
|
| 359 |
+
const char *format,
|
| 360 |
+
va_list argptr)
|
| 361 |
+
LIBXML_ATTR_FORMAT(3,0);
|
| 362 |
+
XMLPUBFUN int xmlTextWriterWriteDTDElement(xmlTextWriterPtr
|
| 363 |
+
writer,
|
| 364 |
+
const xmlChar *
|
| 365 |
+
name,
|
| 366 |
+
const xmlChar *
|
| 367 |
+
content);
|
| 368 |
+
|
| 369 |
+
/*
|
| 370 |
+
* DTD attribute list definition
|
| 371 |
+
*/
|
| 372 |
+
XMLPUBFUN int
|
| 373 |
+
xmlTextWriterStartDTDAttlist(xmlTextWriterPtr writer,
|
| 374 |
+
const xmlChar * name);
|
| 375 |
+
XMLPUBFUN int xmlTextWriterEndDTDAttlist(xmlTextWriterPtr
|
| 376 |
+
writer);
|
| 377 |
+
|
| 378 |
+
/*
|
| 379 |
+
* DTD attribute list definition conveniency functions
|
| 380 |
+
*/
|
| 381 |
+
XMLPUBFUN int
|
| 382 |
+
xmlTextWriterWriteFormatDTDAttlist(xmlTextWriterPtr writer,
|
| 383 |
+
const xmlChar * name,
|
| 384 |
+
const char *format, ...)
|
| 385 |
+
LIBXML_ATTR_FORMAT(3,4);
|
| 386 |
+
XMLPUBFUN int
|
| 387 |
+
xmlTextWriterWriteVFormatDTDAttlist(xmlTextWriterPtr writer,
|
| 388 |
+
const xmlChar * name,
|
| 389 |
+
const char *format,
|
| 390 |
+
va_list argptr)
|
| 391 |
+
LIBXML_ATTR_FORMAT(3,0);
|
| 392 |
+
XMLPUBFUN int xmlTextWriterWriteDTDAttlist(xmlTextWriterPtr
|
| 393 |
+
writer,
|
| 394 |
+
const xmlChar *
|
| 395 |
+
name,
|
| 396 |
+
const xmlChar *
|
| 397 |
+
content);
|
| 398 |
+
|
| 399 |
+
/*
|
| 400 |
+
* DTD entity definition
|
| 401 |
+
*/
|
| 402 |
+
XMLPUBFUN int
|
| 403 |
+
xmlTextWriterStartDTDEntity(xmlTextWriterPtr writer,
|
| 404 |
+
int pe, const xmlChar * name);
|
| 405 |
+
XMLPUBFUN int xmlTextWriterEndDTDEntity(xmlTextWriterPtr
|
| 406 |
+
writer);
|
| 407 |
+
|
| 408 |
+
/*
|
| 409 |
+
* DTD entity definition conveniency functions
|
| 410 |
+
*/
|
| 411 |
+
XMLPUBFUN int
|
| 412 |
+
xmlTextWriterWriteFormatDTDInternalEntity(xmlTextWriterPtr writer,
|
| 413 |
+
int pe,
|
| 414 |
+
const xmlChar * name,
|
| 415 |
+
const char *format, ...)
|
| 416 |
+
LIBXML_ATTR_FORMAT(4,5);
|
| 417 |
+
XMLPUBFUN int
|
| 418 |
+
xmlTextWriterWriteVFormatDTDInternalEntity(xmlTextWriterPtr writer,
|
| 419 |
+
int pe,
|
| 420 |
+
const xmlChar * name,
|
| 421 |
+
const char *format,
|
| 422 |
+
va_list argptr)
|
| 423 |
+
LIBXML_ATTR_FORMAT(4,0);
|
| 424 |
+
XMLPUBFUN int
|
| 425 |
+
xmlTextWriterWriteDTDInternalEntity(xmlTextWriterPtr writer,
|
| 426 |
+
int pe,
|
| 427 |
+
const xmlChar * name,
|
| 428 |
+
const xmlChar * content);
|
| 429 |
+
XMLPUBFUN int
|
| 430 |
+
xmlTextWriterWriteDTDExternalEntity(xmlTextWriterPtr writer,
|
| 431 |
+
int pe,
|
| 432 |
+
const xmlChar * name,
|
| 433 |
+
const xmlChar * pubid,
|
| 434 |
+
const xmlChar * sysid,
|
| 435 |
+
const xmlChar * ndataid);
|
| 436 |
+
XMLPUBFUN int
|
| 437 |
+
xmlTextWriterWriteDTDExternalEntityContents(xmlTextWriterPtr
|
| 438 |
+
writer,
|
| 439 |
+
const xmlChar * pubid,
|
| 440 |
+
const xmlChar * sysid,
|
| 441 |
+
const xmlChar *
|
| 442 |
+
ndataid);
|
| 443 |
+
XMLPUBFUN int xmlTextWriterWriteDTDEntity(xmlTextWriterPtr
|
| 444 |
+
writer, int pe,
|
| 445 |
+
const xmlChar * name,
|
| 446 |
+
const xmlChar *
|
| 447 |
+
pubid,
|
| 448 |
+
const xmlChar *
|
| 449 |
+
sysid,
|
| 450 |
+
const xmlChar *
|
| 451 |
+
ndataid,
|
| 452 |
+
const xmlChar *
|
| 453 |
+
content);
|
| 454 |
+
|
| 455 |
+
/*
|
| 456 |
+
* DTD notation definition
|
| 457 |
+
*/
|
| 458 |
+
XMLPUBFUN int
|
| 459 |
+
xmlTextWriterWriteDTDNotation(xmlTextWriterPtr writer,
|
| 460 |
+
const xmlChar * name,
|
| 461 |
+
const xmlChar * pubid,
|
| 462 |
+
const xmlChar * sysid);
|
| 463 |
+
|
| 464 |
+
/*
|
| 465 |
+
* Indentation
|
| 466 |
+
*/
|
| 467 |
+
XMLPUBFUN int
|
| 468 |
+
xmlTextWriterSetIndent(xmlTextWriterPtr writer, int indent);
|
| 469 |
+
XMLPUBFUN int
|
| 470 |
+
xmlTextWriterSetIndentString(xmlTextWriterPtr writer,
|
| 471 |
+
const xmlChar * str);
|
| 472 |
+
|
| 473 |
+
XMLPUBFUN int
|
| 474 |
+
xmlTextWriterSetQuoteChar(xmlTextWriterPtr writer, xmlChar quotechar);
|
| 475 |
+
|
| 476 |
+
|
| 477 |
+
/*
|
| 478 |
+
* misc
|
| 479 |
+
*/
|
| 480 |
+
XMLPUBFUN int xmlTextWriterFlush(xmlTextWriterPtr writer);
|
| 481 |
+
|
| 482 |
+
#ifdef __cplusplus
|
| 483 |
+
}
|
| 484 |
+
#endif
|
| 485 |
+
|
| 486 |
+
#endif /* LIBXML_WRITER_ENABLED */
|
| 487 |
+
|
| 488 |
+
#endif /* __XML_XMLWRITER_H__ */
|
omnilmm/lib/python3.10/site-packages/lxml/includes/libxml/xpath.h
ADDED
|
@@ -0,0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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Summary: XML Path Language implementation
|
| 3 |
+
* Description: API for the XML Path Language implementation
|
| 4 |
+
*
|
| 5 |
+
* XML Path Language implementation
|
| 6 |
+
* XPath is a language for addressing parts of an XML document,
|
| 7 |
+
* designed to be used by both XSLT and XPointer
|
| 8 |
+
* http://www.w3.org/TR/xpath
|
| 9 |
+
*
|
| 10 |
+
* Implements
|
| 11 |
+
* W3C Recommendation 16 November 1999
|
| 12 |
+
* http://www.w3.org/TR/1999/REC-xpath-19991116
|
| 13 |
+
*
|
| 14 |
+
* Copy: See Copyright for the status of this software.
|
| 15 |
+
*
|
| 16 |
+
* Author: Daniel Veillard
|
| 17 |
+
*/
|
| 18 |
+
|
| 19 |
+
#ifndef __XML_XPATH_H__
|
| 20 |
+
#define __XML_XPATH_H__
|
| 21 |
+
|
| 22 |
+
#include <libxml/xmlversion.h>
|
| 23 |
+
|
| 24 |
+
#ifdef LIBXML_XPATH_ENABLED
|
| 25 |
+
|
| 26 |
+
#include <libxml/xmlerror.h>
|
| 27 |
+
#include <libxml/tree.h>
|
| 28 |
+
#include <libxml/hash.h>
|
| 29 |
+
#endif /* LIBXML_XPATH_ENABLED */
|
| 30 |
+
|
| 31 |
+
#if defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
|
| 32 |
+
#ifdef __cplusplus
|
| 33 |
+
extern "C" {
|
| 34 |
+
#endif
|
| 35 |
+
#endif /* LIBXML_XPATH_ENABLED or LIBXML_SCHEMAS_ENABLED */
|
| 36 |
+
|
| 37 |
+
#ifdef LIBXML_XPATH_ENABLED
|
| 38 |
+
|
| 39 |
+
typedef struct _xmlXPathContext xmlXPathContext;
|
| 40 |
+
typedef xmlXPathContext *xmlXPathContextPtr;
|
| 41 |
+
typedef struct _xmlXPathParserContext xmlXPathParserContext;
|
| 42 |
+
typedef xmlXPathParserContext *xmlXPathParserContextPtr;
|
| 43 |
+
|
| 44 |
+
/**
|
| 45 |
+
* The set of XPath error codes.
|
| 46 |
+
*/
|
| 47 |
+
|
| 48 |
+
typedef enum {
|
| 49 |
+
XPATH_EXPRESSION_OK = 0,
|
| 50 |
+
XPATH_NUMBER_ERROR,
|
| 51 |
+
XPATH_UNFINISHED_LITERAL_ERROR,
|
| 52 |
+
XPATH_START_LITERAL_ERROR,
|
| 53 |
+
XPATH_VARIABLE_REF_ERROR,
|
| 54 |
+
XPATH_UNDEF_VARIABLE_ERROR,
|
| 55 |
+
XPATH_INVALID_PREDICATE_ERROR,
|
| 56 |
+
XPATH_EXPR_ERROR,
|
| 57 |
+
XPATH_UNCLOSED_ERROR,
|
| 58 |
+
XPATH_UNKNOWN_FUNC_ERROR,
|
| 59 |
+
XPATH_INVALID_OPERAND,
|
| 60 |
+
XPATH_INVALID_TYPE,
|
| 61 |
+
XPATH_INVALID_ARITY,
|
| 62 |
+
XPATH_INVALID_CTXT_SIZE,
|
| 63 |
+
XPATH_INVALID_CTXT_POSITION,
|
| 64 |
+
XPATH_MEMORY_ERROR,
|
| 65 |
+
XPTR_SYNTAX_ERROR,
|
| 66 |
+
XPTR_RESOURCE_ERROR,
|
| 67 |
+
XPTR_SUB_RESOURCE_ERROR,
|
| 68 |
+
XPATH_UNDEF_PREFIX_ERROR,
|
| 69 |
+
XPATH_ENCODING_ERROR,
|
| 70 |
+
XPATH_INVALID_CHAR_ERROR,
|
| 71 |
+
XPATH_INVALID_CTXT,
|
| 72 |
+
XPATH_STACK_ERROR,
|
| 73 |
+
XPATH_FORBID_VARIABLE_ERROR,
|
| 74 |
+
XPATH_OP_LIMIT_EXCEEDED,
|
| 75 |
+
XPATH_RECURSION_LIMIT_EXCEEDED
|
| 76 |
+
} xmlXPathError;
|
| 77 |
+
|
| 78 |
+
/*
|
| 79 |
+
* A node-set (an unordered collection of nodes without duplicates).
|
| 80 |
+
*/
|
| 81 |
+
typedef struct _xmlNodeSet xmlNodeSet;
|
| 82 |
+
typedef xmlNodeSet *xmlNodeSetPtr;
|
| 83 |
+
struct _xmlNodeSet {
|
| 84 |
+
int nodeNr; /* number of nodes in the set */
|
| 85 |
+
int nodeMax; /* size of the array as allocated */
|
| 86 |
+
xmlNodePtr *nodeTab; /* array of nodes in no particular order */
|
| 87 |
+
/* @@ with_ns to check whether namespace nodes should be looked at @@ */
|
| 88 |
+
};
|
| 89 |
+
|
| 90 |
+
/*
|
| 91 |
+
* An expression is evaluated to yield an object, which
|
| 92 |
+
* has one of the following four basic types:
|
| 93 |
+
* - node-set
|
| 94 |
+
* - boolean
|
| 95 |
+
* - number
|
| 96 |
+
* - string
|
| 97 |
+
*
|
| 98 |
+
* @@ XPointer will add more types !
|
| 99 |
+
*/
|
| 100 |
+
|
| 101 |
+
typedef enum {
|
| 102 |
+
XPATH_UNDEFINED = 0,
|
| 103 |
+
XPATH_NODESET = 1,
|
| 104 |
+
XPATH_BOOLEAN = 2,
|
| 105 |
+
XPATH_NUMBER = 3,
|
| 106 |
+
XPATH_STRING = 4,
|
| 107 |
+
#ifdef LIBXML_XPTR_LOCS_ENABLED
|
| 108 |
+
XPATH_POINT = 5,
|
| 109 |
+
XPATH_RANGE = 6,
|
| 110 |
+
XPATH_LOCATIONSET = 7,
|
| 111 |
+
#endif
|
| 112 |
+
XPATH_USERS = 8,
|
| 113 |
+
XPATH_XSLT_TREE = 9 /* An XSLT value tree, non modifiable */
|
| 114 |
+
} xmlXPathObjectType;
|
| 115 |
+
|
| 116 |
+
#ifndef LIBXML_XPTR_LOCS_ENABLED
|
| 117 |
+
/** DOC_DISABLE */
|
| 118 |
+
#define XPATH_POINT 5
|
| 119 |
+
#define XPATH_RANGE 6
|
| 120 |
+
#define XPATH_LOCATIONSET 7
|
| 121 |
+
/** DOC_ENABLE */
|
| 122 |
+
#endif
|
| 123 |
+
|
| 124 |
+
typedef struct _xmlXPathObject xmlXPathObject;
|
| 125 |
+
typedef xmlXPathObject *xmlXPathObjectPtr;
|
| 126 |
+
struct _xmlXPathObject {
|
| 127 |
+
xmlXPathObjectType type;
|
| 128 |
+
xmlNodeSetPtr nodesetval;
|
| 129 |
+
int boolval;
|
| 130 |
+
double floatval;
|
| 131 |
+
xmlChar *stringval;
|
| 132 |
+
void *user;
|
| 133 |
+
int index;
|
| 134 |
+
void *user2;
|
| 135 |
+
int index2;
|
| 136 |
+
};
|
| 137 |
+
|
| 138 |
+
/**
|
| 139 |
+
* xmlXPathConvertFunc:
|
| 140 |
+
* @obj: an XPath object
|
| 141 |
+
* @type: the number of the target type
|
| 142 |
+
*
|
| 143 |
+
* A conversion function is associated to a type and used to cast
|
| 144 |
+
* the new type to primitive values.
|
| 145 |
+
*
|
| 146 |
+
* Returns -1 in case of error, 0 otherwise
|
| 147 |
+
*/
|
| 148 |
+
typedef int (*xmlXPathConvertFunc) (xmlXPathObjectPtr obj, int type);
|
| 149 |
+
|
| 150 |
+
/*
|
| 151 |
+
* Extra type: a name and a conversion function.
|
| 152 |
+
*/
|
| 153 |
+
|
| 154 |
+
typedef struct _xmlXPathType xmlXPathType;
|
| 155 |
+
typedef xmlXPathType *xmlXPathTypePtr;
|
| 156 |
+
struct _xmlXPathType {
|
| 157 |
+
const xmlChar *name; /* the type name */
|
| 158 |
+
xmlXPathConvertFunc func; /* the conversion function */
|
| 159 |
+
};
|
| 160 |
+
|
| 161 |
+
/*
|
| 162 |
+
* Extra variable: a name and a value.
|
| 163 |
+
*/
|
| 164 |
+
|
| 165 |
+
typedef struct _xmlXPathVariable xmlXPathVariable;
|
| 166 |
+
typedef xmlXPathVariable *xmlXPathVariablePtr;
|
| 167 |
+
struct _xmlXPathVariable {
|
| 168 |
+
const xmlChar *name; /* the variable name */
|
| 169 |
+
xmlXPathObjectPtr value; /* the value */
|
| 170 |
+
};
|
| 171 |
+
|
| 172 |
+
/**
|
| 173 |
+
* xmlXPathEvalFunc:
|
| 174 |
+
* @ctxt: an XPath parser context
|
| 175 |
+
* @nargs: the number of arguments passed to the function
|
| 176 |
+
*
|
| 177 |
+
* An XPath evaluation function, the parameters are on the XPath context stack.
|
| 178 |
+
*/
|
| 179 |
+
|
| 180 |
+
typedef void (*xmlXPathEvalFunc)(xmlXPathParserContextPtr ctxt,
|
| 181 |
+
int nargs);
|
| 182 |
+
|
| 183 |
+
/*
|
| 184 |
+
* Extra function: a name and a evaluation function.
|
| 185 |
+
*/
|
| 186 |
+
|
| 187 |
+
typedef struct _xmlXPathFunct xmlXPathFunct;
|
| 188 |
+
typedef xmlXPathFunct *xmlXPathFuncPtr;
|
| 189 |
+
struct _xmlXPathFunct {
|
| 190 |
+
const xmlChar *name; /* the function name */
|
| 191 |
+
xmlXPathEvalFunc func; /* the evaluation function */
|
| 192 |
+
};
|
| 193 |
+
|
| 194 |
+
/**
|
| 195 |
+
* xmlXPathAxisFunc:
|
| 196 |
+
* @ctxt: the XPath interpreter context
|
| 197 |
+
* @cur: the previous node being explored on that axis
|
| 198 |
+
*
|
| 199 |
+
* An axis traversal function. To traverse an axis, the engine calls
|
| 200 |
+
* the first time with cur == NULL and repeat until the function returns
|
| 201 |
+
* NULL indicating the end of the axis traversal.
|
| 202 |
+
*
|
| 203 |
+
* Returns the next node in that axis or NULL if at the end of the axis.
|
| 204 |
+
*/
|
| 205 |
+
|
| 206 |
+
typedef xmlXPathObjectPtr (*xmlXPathAxisFunc) (xmlXPathParserContextPtr ctxt,
|
| 207 |
+
xmlXPathObjectPtr cur);
|
| 208 |
+
|
| 209 |
+
/*
|
| 210 |
+
* Extra axis: a name and an axis function.
|
| 211 |
+
*/
|
| 212 |
+
|
| 213 |
+
typedef struct _xmlXPathAxis xmlXPathAxis;
|
| 214 |
+
typedef xmlXPathAxis *xmlXPathAxisPtr;
|
| 215 |
+
struct _xmlXPathAxis {
|
| 216 |
+
const xmlChar *name; /* the axis name */
|
| 217 |
+
xmlXPathAxisFunc func; /* the search function */
|
| 218 |
+
};
|
| 219 |
+
|
| 220 |
+
/**
|
| 221 |
+
* xmlXPathFunction:
|
| 222 |
+
* @ctxt: the XPath interprestation context
|
| 223 |
+
* @nargs: the number of arguments
|
| 224 |
+
*
|
| 225 |
+
* An XPath function.
|
| 226 |
+
* The arguments (if any) are popped out from the context stack
|
| 227 |
+
* and the result is pushed on the stack.
|
| 228 |
+
*/
|
| 229 |
+
|
| 230 |
+
typedef void (*xmlXPathFunction) (xmlXPathParserContextPtr ctxt, int nargs);
|
| 231 |
+
|
| 232 |
+
/*
|
| 233 |
+
* Function and Variable Lookup.
|
| 234 |
+
*/
|
| 235 |
+
|
| 236 |
+
/**
|
| 237 |
+
* xmlXPathVariableLookupFunc:
|
| 238 |
+
* @ctxt: an XPath context
|
| 239 |
+
* @name: name of the variable
|
| 240 |
+
* @ns_uri: the namespace name hosting this variable
|
| 241 |
+
*
|
| 242 |
+
* Prototype for callbacks used to plug variable lookup in the XPath
|
| 243 |
+
* engine.
|
| 244 |
+
*
|
| 245 |
+
* Returns the XPath object value or NULL if not found.
|
| 246 |
+
*/
|
| 247 |
+
typedef xmlXPathObjectPtr (*xmlXPathVariableLookupFunc) (void *ctxt,
|
| 248 |
+
const xmlChar *name,
|
| 249 |
+
const xmlChar *ns_uri);
|
| 250 |
+
|
| 251 |
+
/**
|
| 252 |
+
* xmlXPathFuncLookupFunc:
|
| 253 |
+
* @ctxt: an XPath context
|
| 254 |
+
* @name: name of the function
|
| 255 |
+
* @ns_uri: the namespace name hosting this function
|
| 256 |
+
*
|
| 257 |
+
* Prototype for callbacks used to plug function lookup in the XPath
|
| 258 |
+
* engine.
|
| 259 |
+
*
|
| 260 |
+
* Returns the XPath function or NULL if not found.
|
| 261 |
+
*/
|
| 262 |
+
typedef xmlXPathFunction (*xmlXPathFuncLookupFunc) (void *ctxt,
|
| 263 |
+
const xmlChar *name,
|
| 264 |
+
const xmlChar *ns_uri);
|
| 265 |
+
|
| 266 |
+
/**
|
| 267 |
+
* xmlXPathFlags:
|
| 268 |
+
* Flags for XPath engine compilation and runtime
|
| 269 |
+
*/
|
| 270 |
+
/**
|
| 271 |
+
* XML_XPATH_CHECKNS:
|
| 272 |
+
*
|
| 273 |
+
* check namespaces at compilation
|
| 274 |
+
*/
|
| 275 |
+
#define XML_XPATH_CHECKNS (1<<0)
|
| 276 |
+
/**
|
| 277 |
+
* XML_XPATH_NOVAR:
|
| 278 |
+
*
|
| 279 |
+
* forbid variables in expression
|
| 280 |
+
*/
|
| 281 |
+
#define XML_XPATH_NOVAR (1<<1)
|
| 282 |
+
|
| 283 |
+
/**
|
| 284 |
+
* xmlXPathContext:
|
| 285 |
+
*
|
| 286 |
+
* Expression evaluation occurs with respect to a context.
|
| 287 |
+
* he context consists of:
|
| 288 |
+
* - a node (the context node)
|
| 289 |
+
* - a node list (the context node list)
|
| 290 |
+
* - a set of variable bindings
|
| 291 |
+
* - a function library
|
| 292 |
+
* - the set of namespace declarations in scope for the expression
|
| 293 |
+
* Following the switch to hash tables, this need to be trimmed up at
|
| 294 |
+
* the next binary incompatible release.
|
| 295 |
+
* The node may be modified when the context is passed to libxml2
|
| 296 |
+
* for an XPath evaluation so you may need to initialize it again
|
| 297 |
+
* before the next call.
|
| 298 |
+
*/
|
| 299 |
+
|
| 300 |
+
struct _xmlXPathContext {
|
| 301 |
+
xmlDocPtr doc; /* The current document */
|
| 302 |
+
xmlNodePtr node; /* The current node */
|
| 303 |
+
|
| 304 |
+
int nb_variables_unused; /* unused (hash table) */
|
| 305 |
+
int max_variables_unused; /* unused (hash table) */
|
| 306 |
+
xmlHashTablePtr varHash; /* Hash table of defined variables */
|
| 307 |
+
|
| 308 |
+
int nb_types; /* number of defined types */
|
| 309 |
+
int max_types; /* max number of types */
|
| 310 |
+
xmlXPathTypePtr types; /* Array of defined types */
|
| 311 |
+
|
| 312 |
+
int nb_funcs_unused; /* unused (hash table) */
|
| 313 |
+
int max_funcs_unused; /* unused (hash table) */
|
| 314 |
+
xmlHashTablePtr funcHash; /* Hash table of defined funcs */
|
| 315 |
+
|
| 316 |
+
int nb_axis; /* number of defined axis */
|
| 317 |
+
int max_axis; /* max number of axis */
|
| 318 |
+
xmlXPathAxisPtr axis; /* Array of defined axis */
|
| 319 |
+
|
| 320 |
+
/* the namespace nodes of the context node */
|
| 321 |
+
xmlNsPtr *namespaces; /* Array of namespaces */
|
| 322 |
+
int nsNr; /* number of namespace in scope */
|
| 323 |
+
void *user; /* function to free */
|
| 324 |
+
|
| 325 |
+
/* extra variables */
|
| 326 |
+
int contextSize; /* the context size */
|
| 327 |
+
int proximityPosition; /* the proximity position */
|
| 328 |
+
|
| 329 |
+
/* extra stuff for XPointer */
|
| 330 |
+
int xptr; /* is this an XPointer context? */
|
| 331 |
+
xmlNodePtr here; /* for here() */
|
| 332 |
+
xmlNodePtr origin; /* for origin() */
|
| 333 |
+
|
| 334 |
+
/* the set of namespace declarations in scope for the expression */
|
| 335 |
+
xmlHashTablePtr nsHash; /* The namespaces hash table */
|
| 336 |
+
xmlXPathVariableLookupFunc varLookupFunc;/* variable lookup func */
|
| 337 |
+
void *varLookupData; /* variable lookup data */
|
| 338 |
+
|
| 339 |
+
/* Possibility to link in an extra item */
|
| 340 |
+
void *extra; /* needed for XSLT */
|
| 341 |
+
|
| 342 |
+
/* The function name and URI when calling a function */
|
| 343 |
+
const xmlChar *function;
|
| 344 |
+
const xmlChar *functionURI;
|
| 345 |
+
|
| 346 |
+
/* function lookup function and data */
|
| 347 |
+
xmlXPathFuncLookupFunc funcLookupFunc;/* function lookup func */
|
| 348 |
+
void *funcLookupData; /* function lookup data */
|
| 349 |
+
|
| 350 |
+
/* temporary namespace lists kept for walking the namespace axis */
|
| 351 |
+
xmlNsPtr *tmpNsList; /* Array of namespaces */
|
| 352 |
+
int tmpNsNr; /* number of namespaces in scope */
|
| 353 |
+
|
| 354 |
+
/* error reporting mechanism */
|
| 355 |
+
void *userData; /* user specific data block */
|
| 356 |
+
xmlStructuredErrorFunc error; /* the callback in case of errors */
|
| 357 |
+
xmlError lastError; /* the last error */
|
| 358 |
+
xmlNodePtr debugNode; /* the source node XSLT */
|
| 359 |
+
|
| 360 |
+
/* dictionary */
|
| 361 |
+
xmlDictPtr dict; /* dictionary if any */
|
| 362 |
+
|
| 363 |
+
int flags; /* flags to control compilation */
|
| 364 |
+
|
| 365 |
+
/* Cache for reusal of XPath objects */
|
| 366 |
+
void *cache;
|
| 367 |
+
|
| 368 |
+
/* Resource limits */
|
| 369 |
+
unsigned long opLimit;
|
| 370 |
+
unsigned long opCount;
|
| 371 |
+
int depth;
|
| 372 |
+
};
|
| 373 |
+
|
| 374 |
+
/*
|
| 375 |
+
* The structure of a compiled expression form is not public.
|
| 376 |
+
*/
|
| 377 |
+
|
| 378 |
+
typedef struct _xmlXPathCompExpr xmlXPathCompExpr;
|
| 379 |
+
typedef xmlXPathCompExpr *xmlXPathCompExprPtr;
|
| 380 |
+
|
| 381 |
+
/**
|
| 382 |
+
* xmlXPathParserContext:
|
| 383 |
+
*
|
| 384 |
+
* An XPath parser context. It contains pure parsing information,
|
| 385 |
+
* an xmlXPathContext, and the stack of objects.
|
| 386 |
+
*/
|
| 387 |
+
struct _xmlXPathParserContext {
|
| 388 |
+
const xmlChar *cur; /* the current char being parsed */
|
| 389 |
+
const xmlChar *base; /* the full expression */
|
| 390 |
+
|
| 391 |
+
int error; /* error code */
|
| 392 |
+
|
| 393 |
+
xmlXPathContextPtr context; /* the evaluation context */
|
| 394 |
+
xmlXPathObjectPtr value; /* the current value */
|
| 395 |
+
int valueNr; /* number of values stacked */
|
| 396 |
+
int valueMax; /* max number of values stacked */
|
| 397 |
+
xmlXPathObjectPtr *valueTab; /* stack of values */
|
| 398 |
+
|
| 399 |
+
xmlXPathCompExprPtr comp; /* the precompiled expression */
|
| 400 |
+
int xptr; /* it this an XPointer expression */
|
| 401 |
+
xmlNodePtr ancestor; /* used for walking preceding axis */
|
| 402 |
+
|
| 403 |
+
int valueFrame; /* always zero for compatibility */
|
| 404 |
+
};
|
| 405 |
+
|
| 406 |
+
/************************************************************************
|
| 407 |
+
* *
|
| 408 |
+
* Public API *
|
| 409 |
+
* *
|
| 410 |
+
************************************************************************/
|
| 411 |
+
|
| 412 |
+
/**
|
| 413 |
+
* Objects and Nodesets handling
|
| 414 |
+
*/
|
| 415 |
+
|
| 416 |
+
XMLPUBVAR double xmlXPathNAN;
|
| 417 |
+
XMLPUBVAR double xmlXPathPINF;
|
| 418 |
+
XMLPUBVAR double xmlXPathNINF;
|
| 419 |
+
|
| 420 |
+
/* These macros may later turn into functions */
|
| 421 |
+
/**
|
| 422 |
+
* xmlXPathNodeSetGetLength:
|
| 423 |
+
* @ns: a node-set
|
| 424 |
+
*
|
| 425 |
+
* Implement a functionality similar to the DOM NodeList.length.
|
| 426 |
+
*
|
| 427 |
+
* Returns the number of nodes in the node-set.
|
| 428 |
+
*/
|
| 429 |
+
#define xmlXPathNodeSetGetLength(ns) ((ns) ? (ns)->nodeNr : 0)
|
| 430 |
+
/**
|
| 431 |
+
* xmlXPathNodeSetItem:
|
| 432 |
+
* @ns: a node-set
|
| 433 |
+
* @index: index of a node in the set
|
| 434 |
+
*
|
| 435 |
+
* Implements a functionality similar to the DOM NodeList.item().
|
| 436 |
+
*
|
| 437 |
+
* Returns the xmlNodePtr at the given @index in @ns or NULL if
|
| 438 |
+
* @index is out of range (0 to length-1)
|
| 439 |
+
*/
|
| 440 |
+
#define xmlXPathNodeSetItem(ns, index) \
|
| 441 |
+
((((ns) != NULL) && \
|
| 442 |
+
((index) >= 0) && ((index) < (ns)->nodeNr)) ? \
|
| 443 |
+
(ns)->nodeTab[(index)] \
|
| 444 |
+
: NULL)
|
| 445 |
+
/**
|
| 446 |
+
* xmlXPathNodeSetIsEmpty:
|
| 447 |
+
* @ns: a node-set
|
| 448 |
+
*
|
| 449 |
+
* Checks whether @ns is empty or not.
|
| 450 |
+
*
|
| 451 |
+
* Returns %TRUE if @ns is an empty node-set.
|
| 452 |
+
*/
|
| 453 |
+
#define xmlXPathNodeSetIsEmpty(ns) \
|
| 454 |
+
(((ns) == NULL) || ((ns)->nodeNr == 0) || ((ns)->nodeTab == NULL))
|
| 455 |
+
|
| 456 |
+
|
| 457 |
+
XMLPUBFUN void
|
| 458 |
+
xmlXPathFreeObject (xmlXPathObjectPtr obj);
|
| 459 |
+
XMLPUBFUN xmlNodeSetPtr
|
| 460 |
+
xmlXPathNodeSetCreate (xmlNodePtr val);
|
| 461 |
+
XMLPUBFUN void
|
| 462 |
+
xmlXPathFreeNodeSetList (xmlXPathObjectPtr obj);
|
| 463 |
+
XMLPUBFUN void
|
| 464 |
+
xmlXPathFreeNodeSet (xmlNodeSetPtr obj);
|
| 465 |
+
XMLPUBFUN xmlXPathObjectPtr
|
| 466 |
+
xmlXPathObjectCopy (xmlXPathObjectPtr val);
|
| 467 |
+
XMLPUBFUN int
|
| 468 |
+
xmlXPathCmpNodes (xmlNodePtr node1,
|
| 469 |
+
xmlNodePtr node2);
|
| 470 |
+
/**
|
| 471 |
+
* Conversion functions to basic types.
|
| 472 |
+
*/
|
| 473 |
+
XMLPUBFUN int
|
| 474 |
+
xmlXPathCastNumberToBoolean (double val);
|
| 475 |
+
XMLPUBFUN int
|
| 476 |
+
xmlXPathCastStringToBoolean (const xmlChar * val);
|
| 477 |
+
XMLPUBFUN int
|
| 478 |
+
xmlXPathCastNodeSetToBoolean(xmlNodeSetPtr ns);
|
| 479 |
+
XMLPUBFUN int
|
| 480 |
+
xmlXPathCastToBoolean (xmlXPathObjectPtr val);
|
| 481 |
+
|
| 482 |
+
XMLPUBFUN double
|
| 483 |
+
xmlXPathCastBooleanToNumber (int val);
|
| 484 |
+
XMLPUBFUN double
|
| 485 |
+
xmlXPathCastStringToNumber (const xmlChar * val);
|
| 486 |
+
XMLPUBFUN double
|
| 487 |
+
xmlXPathCastNodeToNumber (xmlNodePtr node);
|
| 488 |
+
XMLPUBFUN double
|
| 489 |
+
xmlXPathCastNodeSetToNumber (xmlNodeSetPtr ns);
|
| 490 |
+
XMLPUBFUN double
|
| 491 |
+
xmlXPathCastToNumber (xmlXPathObjectPtr val);
|
| 492 |
+
|
| 493 |
+
XMLPUBFUN xmlChar *
|
| 494 |
+
xmlXPathCastBooleanToString (int val);
|
| 495 |
+
XMLPUBFUN xmlChar *
|
| 496 |
+
xmlXPathCastNumberToString (double val);
|
| 497 |
+
XMLPUBFUN xmlChar *
|
| 498 |
+
xmlXPathCastNodeToString (xmlNodePtr node);
|
| 499 |
+
XMLPUBFUN xmlChar *
|
| 500 |
+
xmlXPathCastNodeSetToString (xmlNodeSetPtr ns);
|
| 501 |
+
XMLPUBFUN xmlChar *
|
| 502 |
+
xmlXPathCastToString (xmlXPathObjectPtr val);
|
| 503 |
+
|
| 504 |
+
XMLPUBFUN xmlXPathObjectPtr
|
| 505 |
+
xmlXPathConvertBoolean (xmlXPathObjectPtr val);
|
| 506 |
+
XMLPUBFUN xmlXPathObjectPtr
|
| 507 |
+
xmlXPathConvertNumber (xmlXPathObjectPtr val);
|
| 508 |
+
XMLPUBFUN xmlXPathObjectPtr
|
| 509 |
+
xmlXPathConvertString (xmlXPathObjectPtr val);
|
| 510 |
+
|
| 511 |
+
/**
|
| 512 |
+
* Context handling.
|
| 513 |
+
*/
|
| 514 |
+
XMLPUBFUN xmlXPathContextPtr
|
| 515 |
+
xmlXPathNewContext (xmlDocPtr doc);
|
| 516 |
+
XMLPUBFUN void
|
| 517 |
+
xmlXPathFreeContext (xmlXPathContextPtr ctxt);
|
| 518 |
+
XMLPUBFUN int
|
| 519 |
+
xmlXPathContextSetCache(xmlXPathContextPtr ctxt,
|
| 520 |
+
int active,
|
| 521 |
+
int value,
|
| 522 |
+
int options);
|
| 523 |
+
/**
|
| 524 |
+
* Evaluation functions.
|
| 525 |
+
*/
|
| 526 |
+
XMLPUBFUN long
|
| 527 |
+
xmlXPathOrderDocElems (xmlDocPtr doc);
|
| 528 |
+
XMLPUBFUN int
|
| 529 |
+
xmlXPathSetContextNode (xmlNodePtr node,
|
| 530 |
+
xmlXPathContextPtr ctx);
|
| 531 |
+
XMLPUBFUN xmlXPathObjectPtr
|
| 532 |
+
xmlXPathNodeEval (xmlNodePtr node,
|
| 533 |
+
const xmlChar *str,
|
| 534 |
+
xmlXPathContextPtr ctx);
|
| 535 |
+
XMLPUBFUN xmlXPathObjectPtr
|
| 536 |
+
xmlXPathEval (const xmlChar *str,
|
| 537 |
+
xmlXPathContextPtr ctx);
|
| 538 |
+
XMLPUBFUN xmlXPathObjectPtr
|
| 539 |
+
xmlXPathEvalExpression (const xmlChar *str,
|
| 540 |
+
xmlXPathContextPtr ctxt);
|
| 541 |
+
XMLPUBFUN int
|
| 542 |
+
xmlXPathEvalPredicate (xmlXPathContextPtr ctxt,
|
| 543 |
+
xmlXPathObjectPtr res);
|
| 544 |
+
/**
|
| 545 |
+
* Separate compilation/evaluation entry points.
|
| 546 |
+
*/
|
| 547 |
+
XMLPUBFUN xmlXPathCompExprPtr
|
| 548 |
+
xmlXPathCompile (const xmlChar *str);
|
| 549 |
+
XMLPUBFUN xmlXPathCompExprPtr
|
| 550 |
+
xmlXPathCtxtCompile (xmlXPathContextPtr ctxt,
|
| 551 |
+
const xmlChar *str);
|
| 552 |
+
XMLPUBFUN xmlXPathObjectPtr
|
| 553 |
+
xmlXPathCompiledEval (xmlXPathCompExprPtr comp,
|
| 554 |
+
xmlXPathContextPtr ctx);
|
| 555 |
+
XMLPUBFUN int
|
| 556 |
+
xmlXPathCompiledEvalToBoolean(xmlXPathCompExprPtr comp,
|
| 557 |
+
xmlXPathContextPtr ctxt);
|
| 558 |
+
XMLPUBFUN void
|
| 559 |
+
xmlXPathFreeCompExpr (xmlXPathCompExprPtr comp);
|
| 560 |
+
#endif /* LIBXML_XPATH_ENABLED */
|
| 561 |
+
#if defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
|
| 562 |
+
XML_DEPRECATED
|
| 563 |
+
XMLPUBFUN void
|
| 564 |
+
xmlXPathInit (void);
|
| 565 |
+
XMLPUBFUN int
|
| 566 |
+
xmlXPathIsNaN (double val);
|
| 567 |
+
XMLPUBFUN int
|
| 568 |
+
xmlXPathIsInf (double val);
|
| 569 |
+
|
| 570 |
+
#ifdef __cplusplus
|
| 571 |
+
}
|
| 572 |
+
#endif
|
| 573 |
+
|
| 574 |
+
#endif /* LIBXML_XPATH_ENABLED or LIBXML_SCHEMAS_ENABLED*/
|
| 575 |
+
#endif /* ! __XML_XPATH_H__ */
|
omnilmm/lib/python3.10/site-packages/lxml/includes/lxml-version.h
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#ifndef LXML_VERSION_STRING
|
| 2 |
+
#define LXML_VERSION_STRING "5.3.0"
|
| 3 |
+
#endif
|
omnilmm/lib/python3.10/site-packages/lxml/includes/relaxng.pxd
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from lxml.includes.tree cimport xmlDoc
|
| 2 |
+
from lxml.includes.xmlerror cimport xmlStructuredErrorFunc
|
| 3 |
+
|
| 4 |
+
cdef extern from "libxml/relaxng.h" nogil:
|
| 5 |
+
ctypedef struct xmlRelaxNG
|
| 6 |
+
ctypedef struct xmlRelaxNGParserCtxt
|
| 7 |
+
|
| 8 |
+
ctypedef struct xmlRelaxNGValidCtxt
|
| 9 |
+
|
| 10 |
+
ctypedef enum xmlRelaxNGValidErr:
|
| 11 |
+
XML_RELAXNG_OK = 0
|
| 12 |
+
XML_RELAXNG_ERR_MEMORY = 1
|
| 13 |
+
XML_RELAXNG_ERR_TYPE = 2
|
| 14 |
+
XML_RELAXNG_ERR_TYPEVAL = 3
|
| 15 |
+
XML_RELAXNG_ERR_DUPID = 4
|
| 16 |
+
XML_RELAXNG_ERR_TYPECMP = 5
|
| 17 |
+
XML_RELAXNG_ERR_NOSTATE = 6
|
| 18 |
+
XML_RELAXNG_ERR_NODEFINE = 7
|
| 19 |
+
XML_RELAXNG_ERR_LISTEXTRA = 8
|
| 20 |
+
XML_RELAXNG_ERR_LISTEMPTY = 9
|
| 21 |
+
XML_RELAXNG_ERR_INTERNODATA = 10
|
| 22 |
+
XML_RELAXNG_ERR_INTERSEQ = 11
|
| 23 |
+
XML_RELAXNG_ERR_INTEREXTRA = 12
|
| 24 |
+
XML_RELAXNG_ERR_ELEMNAME = 13
|
| 25 |
+
XML_RELAXNG_ERR_ATTRNAME = 14
|
| 26 |
+
XML_RELAXNG_ERR_ELEMNONS = 15
|
| 27 |
+
XML_RELAXNG_ERR_ATTRNONS = 16
|
| 28 |
+
XML_RELAXNG_ERR_ELEMWRONGNS = 17
|
| 29 |
+
XML_RELAXNG_ERR_ATTRWRONGNS = 18
|
| 30 |
+
XML_RELAXNG_ERR_ELEMEXTRANS = 19
|
| 31 |
+
XML_RELAXNG_ERR_ATTREXTRANS = 20
|
| 32 |
+
XML_RELAXNG_ERR_ELEMNOTEMPTY = 21
|
| 33 |
+
XML_RELAXNG_ERR_NOELEM = 22
|
| 34 |
+
XML_RELAXNG_ERR_NOTELEM = 23
|
| 35 |
+
XML_RELAXNG_ERR_ATTRVALID = 24
|
| 36 |
+
XML_RELAXNG_ERR_CONTENTVALID = 25
|
| 37 |
+
XML_RELAXNG_ERR_EXTRACONTENT = 26
|
| 38 |
+
XML_RELAXNG_ERR_INVALIDATTR = 27
|
| 39 |
+
XML_RELAXNG_ERR_DATAELEM = 28
|
| 40 |
+
XML_RELAXNG_ERR_VALELEM = 29
|
| 41 |
+
XML_RELAXNG_ERR_LISTELEM = 30
|
| 42 |
+
XML_RELAXNG_ERR_DATATYPE = 31
|
| 43 |
+
XML_RELAXNG_ERR_VALUE = 32
|
| 44 |
+
XML_RELAXNG_ERR_LIST = 33
|
| 45 |
+
XML_RELAXNG_ERR_NOGRAMMAR = 34
|
| 46 |
+
XML_RELAXNG_ERR_EXTRADATA = 35
|
| 47 |
+
XML_RELAXNG_ERR_LACKDATA = 36
|
| 48 |
+
XML_RELAXNG_ERR_INTERNAL = 37
|
| 49 |
+
XML_RELAXNG_ERR_ELEMWRONG = 38
|
| 50 |
+
XML_RELAXNG_ERR_TEXTWRONG = 39
|
| 51 |
+
|
| 52 |
+
cdef xmlRelaxNGValidCtxt* xmlRelaxNGNewValidCtxt(xmlRelaxNG* schema)
|
| 53 |
+
cdef int xmlRelaxNGValidateDoc(xmlRelaxNGValidCtxt* ctxt, xmlDoc* doc)
|
| 54 |
+
cdef xmlRelaxNG* xmlRelaxNGParse(xmlRelaxNGParserCtxt* ctxt)
|
| 55 |
+
cdef xmlRelaxNGParserCtxt* xmlRelaxNGNewParserCtxt(char* URL)
|
| 56 |
+
cdef xmlRelaxNGParserCtxt* xmlRelaxNGNewDocParserCtxt(xmlDoc* doc)
|
| 57 |
+
cdef void xmlRelaxNGFree(xmlRelaxNG* schema)
|
| 58 |
+
cdef void xmlRelaxNGFreeParserCtxt(xmlRelaxNGParserCtxt* ctxt)
|
| 59 |
+
cdef void xmlRelaxNGFreeValidCtxt(xmlRelaxNGValidCtxt* ctxt)
|
| 60 |
+
|
| 61 |
+
cdef void xmlRelaxNGSetValidStructuredErrors(
|
| 62 |
+
xmlRelaxNGValidCtxt* ctxt, xmlStructuredErrorFunc serror, void *ctx)
|
| 63 |
+
cdef void xmlRelaxNGSetParserStructuredErrors(
|
| 64 |
+
xmlRelaxNGParserCtxt* ctxt, xmlStructuredErrorFunc serror, void *ctx)
|
omnilmm/lib/python3.10/site-packages/lxml/includes/schematron.pxd
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from lxml.includes cimport xmlerror
|
| 2 |
+
from lxml.includes.tree cimport xmlDoc
|
| 3 |
+
|
| 4 |
+
cdef extern from "libxml/schematron.h" nogil:
|
| 5 |
+
ctypedef struct xmlSchematron
|
| 6 |
+
ctypedef struct xmlSchematronParserCtxt
|
| 7 |
+
ctypedef struct xmlSchematronValidCtxt
|
| 8 |
+
|
| 9 |
+
ctypedef enum xmlSchematronValidOptions:
|
| 10 |
+
XML_SCHEMATRON_OUT_QUIET = 1 # quiet no report
|
| 11 |
+
XML_SCHEMATRON_OUT_TEXT = 2 # build a textual report
|
| 12 |
+
XML_SCHEMATRON_OUT_XML = 4 # output SVRL
|
| 13 |
+
XML_SCHEMATRON_OUT_ERROR = 8 # output via xmlStructuredErrorFunc
|
| 14 |
+
XML_SCHEMATRON_OUT_FILE = 256 # output to a file descriptor
|
| 15 |
+
XML_SCHEMATRON_OUT_BUFFER = 512 # output to a buffer
|
| 16 |
+
XML_SCHEMATRON_OUT_IO = 1024 # output to I/O mechanism
|
| 17 |
+
|
| 18 |
+
cdef xmlSchematronParserCtxt* xmlSchematronNewDocParserCtxt(
|
| 19 |
+
xmlDoc* doc)
|
| 20 |
+
cdef xmlSchematronParserCtxt* xmlSchematronNewParserCtxt(
|
| 21 |
+
char* filename) nogil
|
| 22 |
+
cdef xmlSchematronValidCtxt* xmlSchematronNewValidCtxt(
|
| 23 |
+
xmlSchematron* schema, int options)
|
| 24 |
+
|
| 25 |
+
cdef xmlSchematron* xmlSchematronParse(xmlSchematronParserCtxt* ctxt)
|
| 26 |
+
cdef int xmlSchematronValidateDoc(xmlSchematronValidCtxt* ctxt,
|
| 27 |
+
xmlDoc* instance)
|
| 28 |
+
|
| 29 |
+
cdef void xmlSchematronFreeParserCtxt(xmlSchematronParserCtxt* ctxt)
|
| 30 |
+
cdef void xmlSchematronFreeValidCtxt(xmlSchematronValidCtxt* ctxt)
|
| 31 |
+
cdef void xmlSchematronFree(xmlSchematron* schema)
|
| 32 |
+
cdef void xmlSchematronSetValidStructuredErrors(
|
| 33 |
+
xmlSchematronValidCtxt* ctxt,
|
| 34 |
+
xmlerror.xmlStructuredErrorFunc error_func, void *data)
|
omnilmm/lib/python3.10/site-packages/lxml/includes/tree.pxd
ADDED
|
@@ -0,0 +1,494 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from libc cimport stdio
|
| 2 |
+
from libc.string cimport const_char, const_uchar
|
| 3 |
+
|
| 4 |
+
cdef extern from "lxml-version.h":
|
| 5 |
+
# deprecated declaration, use etreepublic.pxd instead
|
| 6 |
+
cdef char* LXML_VERSION_STRING
|
| 7 |
+
|
| 8 |
+
cdef extern from "libxml/xmlversion.h":
|
| 9 |
+
cdef const_char* xmlParserVersion
|
| 10 |
+
cdef int LIBXML_VERSION
|
| 11 |
+
|
| 12 |
+
cdef extern from "libxml/xmlstring.h" nogil:
|
| 13 |
+
ctypedef unsigned char xmlChar
|
| 14 |
+
ctypedef const xmlChar const_xmlChar "const xmlChar"
|
| 15 |
+
cdef int xmlStrlen(const_xmlChar* str)
|
| 16 |
+
cdef xmlChar* xmlStrdup(const_xmlChar* cur)
|
| 17 |
+
cdef int xmlStrncmp(const_xmlChar* str1, const_xmlChar* str2, int length)
|
| 18 |
+
cdef int xmlStrcmp(const_xmlChar* str1, const_xmlChar* str2)
|
| 19 |
+
cdef int xmlStrcasecmp(const xmlChar *str1, const xmlChar *str2)
|
| 20 |
+
cdef const_xmlChar* xmlStrstr(const_xmlChar* str1, const_xmlChar* str2)
|
| 21 |
+
cdef const_xmlChar* xmlStrchr(const_xmlChar* str1, xmlChar ch)
|
| 22 |
+
cdef const_xmlChar* _xcstr "(const xmlChar*)PyBytes_AS_STRING" (object s)
|
| 23 |
+
|
| 24 |
+
cdef extern from "libxml/encoding.h" nogil:
|
| 25 |
+
ctypedef enum xmlCharEncoding:
|
| 26 |
+
XML_CHAR_ENCODING_ERROR = -1 # No char encoding detected
|
| 27 |
+
XML_CHAR_ENCODING_NONE = 0 # No char encoding detected
|
| 28 |
+
XML_CHAR_ENCODING_UTF8 = 1 # UTF-8
|
| 29 |
+
XML_CHAR_ENCODING_UTF16LE = 2 # UTF-16 little endian
|
| 30 |
+
XML_CHAR_ENCODING_UTF16BE = 3 # UTF-16 big endian
|
| 31 |
+
XML_CHAR_ENCODING_UCS4LE = 4 # UCS-4 little endian
|
| 32 |
+
XML_CHAR_ENCODING_UCS4BE = 5 # UCS-4 big endian
|
| 33 |
+
XML_CHAR_ENCODING_EBCDIC = 6 # EBCDIC uh!
|
| 34 |
+
XML_CHAR_ENCODING_UCS4_2143 = 7 # UCS-4 unusual ordering
|
| 35 |
+
XML_CHAR_ENCODING_UCS4_3412 = 8 # UCS-4 unusual ordering
|
| 36 |
+
XML_CHAR_ENCODING_UCS2 = 9 # UCS-2
|
| 37 |
+
XML_CHAR_ENCODING_8859_1 = 10 # ISO-8859-1 ISO Latin 1
|
| 38 |
+
XML_CHAR_ENCODING_8859_2 = 11 # ISO-8859-2 ISO Latin 2
|
| 39 |
+
XML_CHAR_ENCODING_8859_3 = 12 # ISO-8859-3
|
| 40 |
+
XML_CHAR_ENCODING_8859_4 = 13 # ISO-8859-4
|
| 41 |
+
XML_CHAR_ENCODING_8859_5 = 14 # ISO-8859-5
|
| 42 |
+
XML_CHAR_ENCODING_8859_6 = 15 # ISO-8859-6
|
| 43 |
+
XML_CHAR_ENCODING_8859_7 = 16 # ISO-8859-7
|
| 44 |
+
XML_CHAR_ENCODING_8859_8 = 17 # ISO-8859-8
|
| 45 |
+
XML_CHAR_ENCODING_8859_9 = 18 # ISO-8859-9
|
| 46 |
+
XML_CHAR_ENCODING_2022_JP = 19 # ISO-2022-JP
|
| 47 |
+
XML_CHAR_ENCODING_SHIFT_JIS = 20 # Shift_JIS
|
| 48 |
+
XML_CHAR_ENCODING_EUC_JP = 21 # EUC-JP
|
| 49 |
+
XML_CHAR_ENCODING_ASCII = 22 # pure ASCII
|
| 50 |
+
|
| 51 |
+
ctypedef struct xmlCharEncodingHandler:
|
| 52 |
+
char* name
|
| 53 |
+
|
| 54 |
+
cdef xmlCharEncodingHandler* xmlFindCharEncodingHandler(char* name)
|
| 55 |
+
cdef xmlCharEncodingHandler* xmlGetCharEncodingHandler(
|
| 56 |
+
xmlCharEncoding enc)
|
| 57 |
+
cdef int xmlCharEncCloseFunc(xmlCharEncodingHandler* handler)
|
| 58 |
+
cdef xmlCharEncoding xmlDetectCharEncoding(const_xmlChar* text, int len)
|
| 59 |
+
cdef const_char* xmlGetCharEncodingName(xmlCharEncoding enc)
|
| 60 |
+
cdef xmlCharEncoding xmlParseCharEncoding(char* name)
|
| 61 |
+
ctypedef int (*xmlCharEncodingOutputFunc)(
|
| 62 |
+
unsigned char *out_buf, int *outlen, const_uchar *in_buf, int *inlen)
|
| 63 |
+
|
| 64 |
+
cdef extern from "libxml/chvalid.h" nogil:
|
| 65 |
+
cdef int xmlIsChar_ch(char c)
|
| 66 |
+
cdef int xmlIsCharQ(int ch)
|
| 67 |
+
|
| 68 |
+
cdef extern from "libxml/hash.h":
|
| 69 |
+
ctypedef struct xmlHashTable
|
| 70 |
+
ctypedef void (*xmlHashScanner)(void* payload, void* data, const_xmlChar* name) noexcept # may require GIL!
|
| 71 |
+
void xmlHashScan(xmlHashTable* table, xmlHashScanner f, void* data) nogil
|
| 72 |
+
void* xmlHashLookup(xmlHashTable* table, const_xmlChar* name) nogil
|
| 73 |
+
ctypedef void (*xmlHashDeallocator)(void *payload, xmlChar *name) noexcept
|
| 74 |
+
cdef xmlHashTable* xmlHashCreate(int size) nogil
|
| 75 |
+
cdef xmlHashTable* xmlHashCreateDict(int size, xmlDict *dict) nogil
|
| 76 |
+
cdef int xmlHashSize(xmlHashTable* table) nogil
|
| 77 |
+
cdef void xmlHashFree(xmlHashTable* table, xmlHashDeallocator f) nogil
|
| 78 |
+
|
| 79 |
+
cdef extern from * nogil: # actually "libxml/dict.h"
|
| 80 |
+
# libxml/dict.h appears to be broken to include in C
|
| 81 |
+
ctypedef struct xmlDict
|
| 82 |
+
cdef const_xmlChar* xmlDictLookup(xmlDict* dict, const_xmlChar* name, int len)
|
| 83 |
+
cdef const_xmlChar* xmlDictExists(xmlDict* dict, const_xmlChar* name, int len)
|
| 84 |
+
cdef int xmlDictOwns(xmlDict* dict, const_xmlChar* name)
|
| 85 |
+
cdef size_t xmlDictSize(xmlDict* dict)
|
| 86 |
+
|
| 87 |
+
cdef extern from "libxml/tree.h" nogil:
|
| 88 |
+
ctypedef struct xmlDoc
|
| 89 |
+
ctypedef struct xmlAttr
|
| 90 |
+
ctypedef struct xmlNotationTable
|
| 91 |
+
|
| 92 |
+
ctypedef enum xmlElementType:
|
| 93 |
+
XML_ELEMENT_NODE= 1
|
| 94 |
+
XML_ATTRIBUTE_NODE= 2
|
| 95 |
+
XML_TEXT_NODE= 3
|
| 96 |
+
XML_CDATA_SECTION_NODE= 4
|
| 97 |
+
XML_ENTITY_REF_NODE= 5
|
| 98 |
+
XML_ENTITY_NODE= 6
|
| 99 |
+
XML_PI_NODE= 7
|
| 100 |
+
XML_COMMENT_NODE= 8
|
| 101 |
+
XML_DOCUMENT_NODE= 9
|
| 102 |
+
XML_DOCUMENT_TYPE_NODE= 10
|
| 103 |
+
XML_DOCUMENT_FRAG_NODE= 11
|
| 104 |
+
XML_NOTATION_NODE= 12
|
| 105 |
+
XML_HTML_DOCUMENT_NODE= 13
|
| 106 |
+
XML_DTD_NODE= 14
|
| 107 |
+
XML_ELEMENT_DECL= 15
|
| 108 |
+
XML_ATTRIBUTE_DECL= 16
|
| 109 |
+
XML_ENTITY_DECL= 17
|
| 110 |
+
XML_NAMESPACE_DECL= 18
|
| 111 |
+
XML_XINCLUDE_START= 19
|
| 112 |
+
XML_XINCLUDE_END= 20
|
| 113 |
+
|
| 114 |
+
ctypedef enum xmlElementTypeVal:
|
| 115 |
+
XML_ELEMENT_TYPE_UNDEFINED= 0
|
| 116 |
+
XML_ELEMENT_TYPE_EMPTY= 1
|
| 117 |
+
XML_ELEMENT_TYPE_ANY= 2
|
| 118 |
+
XML_ELEMENT_TYPE_MIXED= 3
|
| 119 |
+
XML_ELEMENT_TYPE_ELEMENT= 4
|
| 120 |
+
|
| 121 |
+
ctypedef enum xmlElementContentType:
|
| 122 |
+
XML_ELEMENT_CONTENT_PCDATA= 1
|
| 123 |
+
XML_ELEMENT_CONTENT_ELEMENT= 2
|
| 124 |
+
XML_ELEMENT_CONTENT_SEQ= 3
|
| 125 |
+
XML_ELEMENT_CONTENT_OR= 4
|
| 126 |
+
|
| 127 |
+
ctypedef enum xmlElementContentOccur:
|
| 128 |
+
XML_ELEMENT_CONTENT_ONCE= 1
|
| 129 |
+
XML_ELEMENT_CONTENT_OPT= 2
|
| 130 |
+
XML_ELEMENT_CONTENT_MULT= 3
|
| 131 |
+
XML_ELEMENT_CONTENT_PLUS= 4
|
| 132 |
+
|
| 133 |
+
ctypedef enum xmlAttributeType:
|
| 134 |
+
XML_ATTRIBUTE_CDATA = 1
|
| 135 |
+
XML_ATTRIBUTE_ID= 2
|
| 136 |
+
XML_ATTRIBUTE_IDREF= 3
|
| 137 |
+
XML_ATTRIBUTE_IDREFS= 4
|
| 138 |
+
XML_ATTRIBUTE_ENTITY= 5
|
| 139 |
+
XML_ATTRIBUTE_ENTITIES= 6
|
| 140 |
+
XML_ATTRIBUTE_NMTOKEN= 7
|
| 141 |
+
XML_ATTRIBUTE_NMTOKENS= 8
|
| 142 |
+
XML_ATTRIBUTE_ENUMERATION= 9
|
| 143 |
+
XML_ATTRIBUTE_NOTATION= 10
|
| 144 |
+
|
| 145 |
+
ctypedef enum xmlAttributeDefault:
|
| 146 |
+
XML_ATTRIBUTE_NONE= 1
|
| 147 |
+
XML_ATTRIBUTE_REQUIRED= 2
|
| 148 |
+
XML_ATTRIBUTE_IMPLIED= 3
|
| 149 |
+
XML_ATTRIBUTE_FIXED= 4
|
| 150 |
+
|
| 151 |
+
ctypedef enum xmlEntityType:
|
| 152 |
+
XML_INTERNAL_GENERAL_ENTITY= 1
|
| 153 |
+
XML_EXTERNAL_GENERAL_PARSED_ENTITY= 2
|
| 154 |
+
XML_EXTERNAL_GENERAL_UNPARSED_ENTITY= 3
|
| 155 |
+
XML_INTERNAL_PARAMETER_ENTITY= 4
|
| 156 |
+
XML_EXTERNAL_PARAMETER_ENTITY= 5
|
| 157 |
+
XML_INTERNAL_PREDEFINED_ENTITY= 6
|
| 158 |
+
|
| 159 |
+
ctypedef enum xmlDocProperties:
|
| 160 |
+
XML_DOC_WELLFORMED = 1 # /* document is XML well formed */
|
| 161 |
+
XML_DOC_NSVALID = 2 # /* document is Namespace valid */
|
| 162 |
+
XML_DOC_OLD10 = 4 # /* parsed with old XML-1.0 parser */
|
| 163 |
+
XML_DOC_DTDVALID = 8 # /* DTD validation was successful */
|
| 164 |
+
XML_DOC_XINCLUDE = 16 # /* XInclude substitution was done */
|
| 165 |
+
XML_DOC_USERBUILT = 32 # /* Document was built using the API
|
| 166 |
+
# and not by parsing an instance */
|
| 167 |
+
XML_DOC_INTERNAL = 64 # /* built for internal processing */
|
| 168 |
+
XML_DOC_HTML = 128 # /* parsed or built HTML document */
|
| 169 |
+
|
| 170 |
+
ctypedef struct xmlNs:
|
| 171 |
+
const_xmlChar* href
|
| 172 |
+
const_xmlChar* prefix
|
| 173 |
+
xmlNs* next
|
| 174 |
+
|
| 175 |
+
ctypedef struct xmlNode:
|
| 176 |
+
void* _private
|
| 177 |
+
xmlElementType type
|
| 178 |
+
const_xmlChar* name
|
| 179 |
+
xmlNode* children
|
| 180 |
+
xmlNode* last
|
| 181 |
+
xmlNode* parent
|
| 182 |
+
xmlNode* next
|
| 183 |
+
xmlNode* prev
|
| 184 |
+
xmlDoc* doc
|
| 185 |
+
xmlChar* content
|
| 186 |
+
xmlAttr* properties
|
| 187 |
+
xmlNs* ns
|
| 188 |
+
xmlNs* nsDef
|
| 189 |
+
unsigned short line
|
| 190 |
+
|
| 191 |
+
ctypedef struct xmlElementContent:
|
| 192 |
+
xmlElementContentType type
|
| 193 |
+
xmlElementContentOccur ocur
|
| 194 |
+
const_xmlChar *name
|
| 195 |
+
xmlElementContent *c1
|
| 196 |
+
xmlElementContent *c2
|
| 197 |
+
xmlElementContent *parent
|
| 198 |
+
const_xmlChar *prefix
|
| 199 |
+
|
| 200 |
+
ctypedef struct xmlEnumeration:
|
| 201 |
+
xmlEnumeration *next
|
| 202 |
+
const_xmlChar *name
|
| 203 |
+
|
| 204 |
+
ctypedef struct xmlAttribute:
|
| 205 |
+
void* _private
|
| 206 |
+
xmlElementType type
|
| 207 |
+
const_xmlChar* name
|
| 208 |
+
xmlNode* children
|
| 209 |
+
xmlNode* last
|
| 210 |
+
xmlDtd* parent
|
| 211 |
+
xmlNode* next
|
| 212 |
+
xmlNode* prev
|
| 213 |
+
xmlDoc* doc
|
| 214 |
+
xmlAttribute* nexth
|
| 215 |
+
xmlAttributeType atype
|
| 216 |
+
xmlAttributeDefault def_ "def"
|
| 217 |
+
const_xmlChar* defaultValue
|
| 218 |
+
xmlEnumeration* tree
|
| 219 |
+
const_xmlChar* prefix
|
| 220 |
+
const_xmlChar* elem
|
| 221 |
+
|
| 222 |
+
ctypedef struct xmlElement:
|
| 223 |
+
void* _private
|
| 224 |
+
xmlElementType type
|
| 225 |
+
const_xmlChar* name
|
| 226 |
+
xmlNode* children
|
| 227 |
+
xmlNode* last
|
| 228 |
+
xmlNode* parent
|
| 229 |
+
xmlNode* next
|
| 230 |
+
xmlNode* prev
|
| 231 |
+
xmlDoc* doc
|
| 232 |
+
xmlElementTypeVal etype
|
| 233 |
+
xmlElementContent* content
|
| 234 |
+
xmlAttribute* attributes
|
| 235 |
+
const_xmlChar* prefix
|
| 236 |
+
void *contModel
|
| 237 |
+
|
| 238 |
+
ctypedef struct xmlEntity:
|
| 239 |
+
void* _private
|
| 240 |
+
xmlElementType type
|
| 241 |
+
const_xmlChar* name
|
| 242 |
+
xmlNode* children
|
| 243 |
+
xmlNode* last
|
| 244 |
+
xmlDtd* parent
|
| 245 |
+
xmlNode* next
|
| 246 |
+
xmlNode* prev
|
| 247 |
+
xmlDoc* doc
|
| 248 |
+
xmlChar* orig
|
| 249 |
+
xmlChar* content
|
| 250 |
+
int length
|
| 251 |
+
xmlEntityType etype
|
| 252 |
+
const_xmlChar* ExternalID
|
| 253 |
+
const_xmlChar* SystemID
|
| 254 |
+
xmlEntity* nexte
|
| 255 |
+
const_xmlChar* URI
|
| 256 |
+
int owner
|
| 257 |
+
int checked
|
| 258 |
+
|
| 259 |
+
ctypedef struct xmlDtd:
|
| 260 |
+
const_xmlChar* name
|
| 261 |
+
const_xmlChar* ExternalID
|
| 262 |
+
const_xmlChar* SystemID
|
| 263 |
+
void* notations
|
| 264 |
+
void* entities
|
| 265 |
+
void* pentities
|
| 266 |
+
void* attributes
|
| 267 |
+
void* elements
|
| 268 |
+
xmlNode* children
|
| 269 |
+
xmlNode* last
|
| 270 |
+
xmlDoc* doc
|
| 271 |
+
|
| 272 |
+
ctypedef struct xmlDoc:
|
| 273 |
+
xmlElementType type
|
| 274 |
+
char* name
|
| 275 |
+
xmlNode* children
|
| 276 |
+
xmlNode* last
|
| 277 |
+
xmlNode* parent
|
| 278 |
+
xmlNode* next
|
| 279 |
+
xmlNode* prev
|
| 280 |
+
xmlDoc* doc
|
| 281 |
+
xmlDict* dict
|
| 282 |
+
xmlHashTable* ids
|
| 283 |
+
int standalone
|
| 284 |
+
const_xmlChar* version
|
| 285 |
+
const_xmlChar* encoding
|
| 286 |
+
const_xmlChar* URL
|
| 287 |
+
void* _private
|
| 288 |
+
xmlDtd* intSubset
|
| 289 |
+
xmlDtd* extSubset
|
| 290 |
+
int properties
|
| 291 |
+
|
| 292 |
+
ctypedef struct xmlAttr:
|
| 293 |
+
void* _private
|
| 294 |
+
xmlElementType type
|
| 295 |
+
const_xmlChar* name
|
| 296 |
+
xmlNode* children
|
| 297 |
+
xmlNode* last
|
| 298 |
+
xmlNode* parent
|
| 299 |
+
xmlAttr* next
|
| 300 |
+
xmlAttr* prev
|
| 301 |
+
xmlDoc* doc
|
| 302 |
+
xmlNs* ns
|
| 303 |
+
xmlAttributeType atype
|
| 304 |
+
|
| 305 |
+
ctypedef struct xmlID:
|
| 306 |
+
const_xmlChar* value
|
| 307 |
+
const_xmlChar* name
|
| 308 |
+
xmlAttr* attr
|
| 309 |
+
xmlDoc* doc
|
| 310 |
+
|
| 311 |
+
ctypedef struct xmlBuffer
|
| 312 |
+
|
| 313 |
+
ctypedef struct xmlBuf # new in libxml2 2.9
|
| 314 |
+
|
| 315 |
+
ctypedef struct xmlOutputBuffer:
|
| 316 |
+
xmlBuf* buffer
|
| 317 |
+
xmlBuf* conv
|
| 318 |
+
int error
|
| 319 |
+
|
| 320 |
+
const_xmlChar* XML_XML_NAMESPACE
|
| 321 |
+
|
| 322 |
+
cdef void xmlFreeDoc(xmlDoc* cur)
|
| 323 |
+
cdef void xmlFreeDtd(xmlDtd* cur)
|
| 324 |
+
cdef void xmlFreeNode(xmlNode* cur)
|
| 325 |
+
cdef void xmlFreeNsList(xmlNs* ns)
|
| 326 |
+
cdef void xmlFreeNs(xmlNs* ns)
|
| 327 |
+
cdef void xmlFree(void* buf)
|
| 328 |
+
|
| 329 |
+
cdef xmlNode* xmlNewNode(xmlNs* ns, const_xmlChar* name)
|
| 330 |
+
cdef xmlNode* xmlNewDocText(xmlDoc* doc, const_xmlChar* content)
|
| 331 |
+
cdef xmlNode* xmlNewDocComment(xmlDoc* doc, const_xmlChar* content)
|
| 332 |
+
cdef xmlNode* xmlNewDocPI(xmlDoc* doc, const_xmlChar* name, const_xmlChar* content)
|
| 333 |
+
cdef xmlNode* xmlNewReference(xmlDoc* doc, const_xmlChar* name)
|
| 334 |
+
cdef xmlNode* xmlNewCDataBlock(xmlDoc* doc, const_xmlChar* text, int len)
|
| 335 |
+
cdef xmlNs* xmlNewNs(xmlNode* node, const_xmlChar* href, const_xmlChar* prefix)
|
| 336 |
+
cdef xmlNode* xmlAddChild(xmlNode* parent, xmlNode* cur)
|
| 337 |
+
cdef xmlNode* xmlReplaceNode(xmlNode* old, xmlNode* cur)
|
| 338 |
+
cdef xmlNode* xmlAddPrevSibling(xmlNode* cur, xmlNode* elem)
|
| 339 |
+
cdef xmlNode* xmlAddNextSibling(xmlNode* cur, xmlNode* elem)
|
| 340 |
+
cdef xmlNode* xmlNewDocNode(xmlDoc* doc, xmlNs* ns,
|
| 341 |
+
const_xmlChar* name, const_xmlChar* content)
|
| 342 |
+
cdef xmlDoc* xmlNewDoc(const_xmlChar* version)
|
| 343 |
+
cdef xmlAttr* xmlNewProp(xmlNode* node, const_xmlChar* name, const_xmlChar* value)
|
| 344 |
+
cdef xmlAttr* xmlNewNsProp(xmlNode* node, xmlNs* ns,
|
| 345 |
+
const_xmlChar* name, const_xmlChar* value)
|
| 346 |
+
cdef xmlChar* xmlGetNoNsProp(xmlNode* node, const_xmlChar* name)
|
| 347 |
+
cdef xmlChar* xmlGetNsProp(xmlNode* node, const_xmlChar* name, const_xmlChar* nameSpace)
|
| 348 |
+
cdef void xmlSetNs(xmlNode* node, xmlNs* ns)
|
| 349 |
+
cdef xmlAttr* xmlSetProp(xmlNode* node, const_xmlChar* name, const_xmlChar* value)
|
| 350 |
+
cdef xmlAttr* xmlSetNsProp(xmlNode* node, xmlNs* ns,
|
| 351 |
+
const_xmlChar* name, const_xmlChar* value)
|
| 352 |
+
cdef int xmlRemoveID(xmlDoc* doc, xmlAttr* cur)
|
| 353 |
+
cdef int xmlRemoveProp(xmlAttr* cur)
|
| 354 |
+
cdef void xmlFreePropList(xmlAttr* cur)
|
| 355 |
+
cdef xmlChar* xmlGetNodePath(xmlNode* node)
|
| 356 |
+
cdef void xmlDocDumpMemory(xmlDoc* cur, char** mem, int* size)
|
| 357 |
+
cdef void xmlDocDumpMemoryEnc(xmlDoc* cur, char** mem, int* size,
|
| 358 |
+
char* encoding)
|
| 359 |
+
cdef int xmlSaveFileTo(xmlOutputBuffer* out, xmlDoc* cur,
|
| 360 |
+
char* encoding)
|
| 361 |
+
|
| 362 |
+
cdef void xmlUnlinkNode(xmlNode* cur)
|
| 363 |
+
cdef xmlNode* xmlDocSetRootElement(xmlDoc* doc, xmlNode* root)
|
| 364 |
+
cdef xmlNode* xmlDocGetRootElement(xmlDoc* doc)
|
| 365 |
+
cdef void xmlSetTreeDoc(xmlNode* tree, xmlDoc* doc)
|
| 366 |
+
cdef xmlAttr* xmlHasProp(xmlNode* node, const_xmlChar* name)
|
| 367 |
+
cdef xmlAttr* xmlHasNsProp(xmlNode* node, const_xmlChar* name, const_xmlChar* nameSpace)
|
| 368 |
+
cdef xmlChar* xmlNodeGetContent(xmlNode* cur)
|
| 369 |
+
cdef int xmlNodeBufGetContent(xmlBuffer* buffer, xmlNode* cur)
|
| 370 |
+
cdef xmlNs* xmlSearchNs(xmlDoc* doc, xmlNode* node, const_xmlChar* prefix)
|
| 371 |
+
cdef xmlNs* xmlSearchNsByHref(xmlDoc* doc, xmlNode* node, const_xmlChar* href)
|
| 372 |
+
cdef int xmlIsBlankNode(xmlNode* node)
|
| 373 |
+
cdef long xmlGetLineNo(xmlNode* node)
|
| 374 |
+
cdef void xmlElemDump(stdio.FILE* f, xmlDoc* doc, xmlNode* cur)
|
| 375 |
+
cdef void xmlNodeDumpOutput(xmlOutputBuffer* buf,
|
| 376 |
+
xmlDoc* doc, xmlNode* cur, int level,
|
| 377 |
+
int format, const_char* encoding)
|
| 378 |
+
cdef void xmlBufAttrSerializeTxtContent(xmlOutputBuffer *buf, xmlDoc *doc,
|
| 379 |
+
xmlAttr *attr, const_xmlChar *string)
|
| 380 |
+
cdef void xmlNodeSetName(xmlNode* cur, const_xmlChar* name)
|
| 381 |
+
cdef void xmlNodeSetContent(xmlNode* cur, const_xmlChar* content)
|
| 382 |
+
cdef xmlDtd* xmlCopyDtd(xmlDtd* dtd)
|
| 383 |
+
cdef xmlDoc* xmlCopyDoc(xmlDoc* doc, int recursive)
|
| 384 |
+
cdef xmlNode* xmlCopyNode(xmlNode* node, int extended)
|
| 385 |
+
cdef xmlNode* xmlDocCopyNode(xmlNode* node, xmlDoc* doc, int extended)
|
| 386 |
+
cdef int xmlReconciliateNs(xmlDoc* doc, xmlNode* tree)
|
| 387 |
+
cdef xmlNs* xmlNewReconciliedNs(xmlDoc* doc, xmlNode* tree, xmlNs* ns)
|
| 388 |
+
cdef xmlBuffer* xmlBufferCreate()
|
| 389 |
+
cdef void xmlBufferWriteChar(xmlBuffer* buf, char* string)
|
| 390 |
+
cdef void xmlBufferFree(xmlBuffer* buf)
|
| 391 |
+
cdef const_xmlChar* xmlBufferContent(xmlBuffer* buf)
|
| 392 |
+
cdef int xmlBufferLength(xmlBuffer* buf)
|
| 393 |
+
cdef const_xmlChar* xmlBufContent(xmlBuf* buf) # new in libxml2 2.9
|
| 394 |
+
cdef size_t xmlBufUse(xmlBuf* buf) # new in libxml2 2.9
|
| 395 |
+
cdef int xmlKeepBlanksDefault(int val)
|
| 396 |
+
cdef xmlChar* xmlNodeGetBase(xmlDoc* doc, xmlNode* node)
|
| 397 |
+
cdef xmlDtd* xmlCreateIntSubset(xmlDoc* doc, const_xmlChar* name,
|
| 398 |
+
const_xmlChar* ExternalID, const_xmlChar* SystemID)
|
| 399 |
+
cdef void xmlNodeSetBase(xmlNode* node, const_xmlChar* uri)
|
| 400 |
+
cdef int xmlValidateNCName(const_xmlChar* value, int space)
|
| 401 |
+
|
| 402 |
+
cdef extern from "libxml/uri.h" nogil:
|
| 403 |
+
cdef const_xmlChar* xmlBuildURI(const_xmlChar* href, const_xmlChar* base)
|
| 404 |
+
|
| 405 |
+
cdef extern from "libxml/HTMLtree.h" nogil:
|
| 406 |
+
cdef void htmlNodeDumpFormatOutput(xmlOutputBuffer* buf,
|
| 407 |
+
xmlDoc* doc, xmlNode* cur,
|
| 408 |
+
char* encoding, int format)
|
| 409 |
+
cdef xmlDoc* htmlNewDoc(const_xmlChar* uri, const_xmlChar* externalID)
|
| 410 |
+
|
| 411 |
+
cdef extern from "libxml/valid.h" nogil:
|
| 412 |
+
cdef xmlAttr* xmlGetID(xmlDoc* doc, const_xmlChar* ID)
|
| 413 |
+
cdef void xmlDumpNotationTable(xmlBuffer* buffer,
|
| 414 |
+
xmlNotationTable* table)
|
| 415 |
+
cdef int xmlValidateNameValue(const_xmlChar* value)
|
| 416 |
+
|
| 417 |
+
cdef extern from "libxml/xmlIO.h":
|
| 418 |
+
cdef int xmlOutputBufferWrite(xmlOutputBuffer* out,
|
| 419 |
+
int len, const_char* str) nogil
|
| 420 |
+
cdef int xmlOutputBufferWriteString(xmlOutputBuffer* out, const_char* str) nogil
|
| 421 |
+
cdef int xmlOutputBufferWriteEscape(xmlOutputBuffer* out,
|
| 422 |
+
const_xmlChar* str,
|
| 423 |
+
xmlCharEncodingOutputFunc escapefunc) nogil
|
| 424 |
+
cdef int xmlOutputBufferFlush(xmlOutputBuffer* out) nogil
|
| 425 |
+
cdef int xmlOutputBufferClose(xmlOutputBuffer* out) nogil
|
| 426 |
+
|
| 427 |
+
ctypedef int (*xmlInputReadCallback)(void* context,
|
| 428 |
+
char* buffer, int len) noexcept nogil
|
| 429 |
+
ctypedef int (*xmlInputCloseCallback)(void* context) noexcept nogil
|
| 430 |
+
|
| 431 |
+
ctypedef int (*xmlOutputWriteCallback)(void* context,
|
| 432 |
+
char* buffer, int len) noexcept
|
| 433 |
+
ctypedef int (*xmlOutputCloseCallback)(void* context) noexcept
|
| 434 |
+
|
| 435 |
+
cdef xmlOutputBuffer* xmlAllocOutputBuffer(
|
| 436 |
+
xmlCharEncodingHandler* encoder) nogil
|
| 437 |
+
cdef xmlOutputBuffer* xmlOutputBufferCreateIO(
|
| 438 |
+
xmlOutputWriteCallback iowrite,
|
| 439 |
+
xmlOutputCloseCallback ioclose,
|
| 440 |
+
void * ioctx,
|
| 441 |
+
xmlCharEncodingHandler* encoder) nogil
|
| 442 |
+
cdef xmlOutputBuffer* xmlOutputBufferCreateFile(
|
| 443 |
+
stdio.FILE* file, xmlCharEncodingHandler* encoder) nogil
|
| 444 |
+
cdef xmlOutputBuffer* xmlOutputBufferCreateFilename(
|
| 445 |
+
char* URI, xmlCharEncodingHandler* encoder, int compression) nogil
|
| 446 |
+
|
| 447 |
+
cdef extern from "libxml/xmlsave.h" nogil:
|
| 448 |
+
ctypedef struct xmlSaveCtxt
|
| 449 |
+
|
| 450 |
+
ctypedef enum xmlSaveOption:
|
| 451 |
+
XML_SAVE_FORMAT = 1 # format save output (2.6.17)
|
| 452 |
+
XML_SAVE_NO_DECL = 2 # drop the xml declaration (2.6.21)
|
| 453 |
+
XML_SAVE_NO_EMPTY = 4 # no empty tags (2.6.22)
|
| 454 |
+
XML_SAVE_NO_XHTML = 8 # disable XHTML1 specific rules (2.6.22)
|
| 455 |
+
XML_SAVE_XHTML = 16 # force XHTML1 specific rules (2.7.2)
|
| 456 |
+
XML_SAVE_AS_XML = 32 # force XML serialization on HTML doc (2.7.2)
|
| 457 |
+
XML_SAVE_AS_HTML = 64 # force HTML serialization on XML doc (2.7.2)
|
| 458 |
+
|
| 459 |
+
cdef xmlSaveCtxt* xmlSaveToFilename(char* filename, char* encoding,
|
| 460 |
+
int options)
|
| 461 |
+
cdef xmlSaveCtxt* xmlSaveToBuffer(xmlBuffer* buffer, char* encoding,
|
| 462 |
+
int options) # libxml2 2.6.23
|
| 463 |
+
cdef long xmlSaveDoc(xmlSaveCtxt* ctxt, xmlDoc* doc)
|
| 464 |
+
cdef long xmlSaveTree(xmlSaveCtxt* ctxt, xmlNode* node)
|
| 465 |
+
cdef int xmlSaveClose(xmlSaveCtxt* ctxt)
|
| 466 |
+
cdef int xmlSaveFlush(xmlSaveCtxt* ctxt)
|
| 467 |
+
cdef int xmlSaveSetAttrEscape(xmlSaveCtxt* ctxt, void* escape_func)
|
| 468 |
+
cdef int xmlSaveSetEscape(xmlSaveCtxt* ctxt, void* escape_func)
|
| 469 |
+
|
| 470 |
+
cdef extern from "libxml/globals.h" nogil:
|
| 471 |
+
cdef int xmlThrDefKeepBlanksDefaultValue(int onoff)
|
| 472 |
+
cdef int xmlThrDefLineNumbersDefaultValue(int onoff)
|
| 473 |
+
cdef int xmlThrDefIndentTreeOutput(int onoff)
|
| 474 |
+
|
| 475 |
+
cdef extern from "libxml/xmlmemory.h" nogil:
|
| 476 |
+
cdef void* xmlMalloc(size_t size)
|
| 477 |
+
cdef int xmlMemBlocks()
|
| 478 |
+
cdef int xmlMemUsed()
|
| 479 |
+
cdef void xmlMemDisplay(stdio.FILE* file)
|
| 480 |
+
cdef void xmlMemDisplayLast(stdio.FILE* file, long num_bytes)
|
| 481 |
+
cdef void xmlMemShow(stdio.FILE* file, int count)
|
| 482 |
+
|
| 483 |
+
cdef extern from "etree_defs.h" nogil:
|
| 484 |
+
cdef bint _isElement(xmlNode* node)
|
| 485 |
+
cdef bint _isElementOrXInclude(xmlNode* node)
|
| 486 |
+
cdef const_xmlChar* _getNs(xmlNode* node)
|
| 487 |
+
cdef void BEGIN_FOR_EACH_ELEMENT_FROM(xmlNode* tree_top,
|
| 488 |
+
xmlNode* start_node,
|
| 489 |
+
bint inclusive)
|
| 490 |
+
cdef void END_FOR_EACH_ELEMENT_FROM(xmlNode* start_node)
|
| 491 |
+
cdef void BEGIN_FOR_EACH_FROM(xmlNode* tree_top,
|
| 492 |
+
xmlNode* start_node,
|
| 493 |
+
bint inclusive)
|
| 494 |
+
cdef void END_FOR_EACH_FROM(xmlNode* start_node)
|
omnilmm/lib/python3.10/site-packages/lxml/includes/uri.pxd
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
cdef extern from "libxml/uri.h" nogil:
|
| 2 |
+
ctypedef struct xmlURI
|
| 3 |
+
|
| 4 |
+
cdef xmlURI* xmlParseURI(char* str)
|
| 5 |
+
cdef void xmlFreeURI(xmlURI* uri)
|
omnilmm/lib/python3.10/site-packages/lxml/includes/xinclude.pxd
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from lxml.includes.tree cimport xmlDoc, xmlNode
|
| 2 |
+
|
| 3 |
+
cdef extern from "libxml/xinclude.h" nogil:
|
| 4 |
+
|
| 5 |
+
ctypedef struct xmlXIncludeCtxt
|
| 6 |
+
|
| 7 |
+
cdef int xmlXIncludeProcess(xmlDoc* doc)
|
| 8 |
+
cdef int xmlXIncludeProcessFlags(xmlDoc* doc, int parser_opts)
|
| 9 |
+
cdef int xmlXIncludeProcessTree(xmlNode* doc)
|
| 10 |
+
cdef int xmlXIncludeProcessTreeFlags(xmlNode* doc, int parser_opts)
|
| 11 |
+
|
| 12 |
+
# libxml2 >= 2.7.4
|
| 13 |
+
cdef int xmlXIncludeProcessTreeFlagsData(
|
| 14 |
+
xmlNode* doc, int parser_opts, void* data)
|
| 15 |
+
|
| 16 |
+
cdef xmlXIncludeCtxt* xmlXIncludeNewContext(xmlDoc* doc)
|
| 17 |
+
cdef int xmlXIncludeProcessNode(xmlXIncludeCtxt* ctxt, xmlNode* node)
|
| 18 |
+
cdef int xmlXIncludeSetFlags(xmlXIncludeCtxt* ctxt, int flags)
|
| 19 |
+
|
| 20 |
+
# libxml2 >= 2.6.27
|
| 21 |
+
cdef int xmlXIncludeProcessFlagsData(
|
| 22 |
+
xmlDoc* doc, int flags, void* data)
|
omnilmm/lib/python3.10/site-packages/lxml/includes/xmlerror.pxd
ADDED
|
@@ -0,0 +1,852 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
# --- BEGIN: GENERATED CONSTANTS ---
|
| 3 |
+
|
| 4 |
+
# This section is generated by the script 'update-error-constants.py'.
|
| 5 |
+
|
| 6 |
+
cdef extern from "libxml/xmlerror.h":
|
| 7 |
+
ctypedef enum xmlErrorLevel:
|
| 8 |
+
XML_ERR_NONE = 0
|
| 9 |
+
XML_ERR_WARNING = 1 # A simple warning
|
| 10 |
+
XML_ERR_ERROR = 2 # A recoverable error
|
| 11 |
+
XML_ERR_FATAL = 3 # A fatal error
|
| 12 |
+
|
| 13 |
+
ctypedef enum xmlErrorDomain:
|
| 14 |
+
XML_FROM_NONE = 0
|
| 15 |
+
XML_FROM_PARSER = 1 # The XML parser
|
| 16 |
+
XML_FROM_TREE = 2 # The tree module
|
| 17 |
+
XML_FROM_NAMESPACE = 3 # The XML Namespace module
|
| 18 |
+
XML_FROM_DTD = 4 # The XML DTD validation with parser contex
|
| 19 |
+
XML_FROM_HTML = 5 # The HTML parser
|
| 20 |
+
XML_FROM_MEMORY = 6 # The memory allocator
|
| 21 |
+
XML_FROM_OUTPUT = 7 # The serialization code
|
| 22 |
+
XML_FROM_IO = 8 # The Input/Output stack
|
| 23 |
+
XML_FROM_FTP = 9 # The FTP module
|
| 24 |
+
XML_FROM_HTTP = 10 # The HTTP module
|
| 25 |
+
XML_FROM_XINCLUDE = 11 # The XInclude processing
|
| 26 |
+
XML_FROM_XPATH = 12 # The XPath module
|
| 27 |
+
XML_FROM_XPOINTER = 13 # The XPointer module
|
| 28 |
+
XML_FROM_REGEXP = 14 # The regular expressions module
|
| 29 |
+
XML_FROM_DATATYPE = 15 # The W3C XML Schemas Datatype module
|
| 30 |
+
XML_FROM_SCHEMASP = 16 # The W3C XML Schemas parser module
|
| 31 |
+
XML_FROM_SCHEMASV = 17 # The W3C XML Schemas validation module
|
| 32 |
+
XML_FROM_RELAXNGP = 18 # The Relax-NG parser module
|
| 33 |
+
XML_FROM_RELAXNGV = 19 # The Relax-NG validator module
|
| 34 |
+
XML_FROM_CATALOG = 20 # The Catalog module
|
| 35 |
+
XML_FROM_C14N = 21 # The Canonicalization module
|
| 36 |
+
XML_FROM_XSLT = 22 # The XSLT engine from libxslt
|
| 37 |
+
XML_FROM_VALID = 23 # The XML DTD validation with valid context
|
| 38 |
+
XML_FROM_CHECK = 24 # The error checking module
|
| 39 |
+
XML_FROM_WRITER = 25 # The xmlwriter module
|
| 40 |
+
XML_FROM_MODULE = 26 # The dynamically loaded module modul
|
| 41 |
+
XML_FROM_I18N = 27 # The module handling character conversion
|
| 42 |
+
XML_FROM_SCHEMATRONV = 28 # The Schematron validator module
|
| 43 |
+
XML_FROM_BUFFER = 29 # The buffers module
|
| 44 |
+
XML_FROM_URI = 30 # The URI module
|
| 45 |
+
|
| 46 |
+
ctypedef enum xmlParserErrors:
|
| 47 |
+
XML_ERR_OK = 0
|
| 48 |
+
XML_ERR_INTERNAL_ERROR = 1
|
| 49 |
+
XML_ERR_NO_MEMORY = 2
|
| 50 |
+
XML_ERR_DOCUMENT_START = 3
|
| 51 |
+
XML_ERR_DOCUMENT_EMPTY = 4
|
| 52 |
+
XML_ERR_DOCUMENT_END = 5
|
| 53 |
+
XML_ERR_INVALID_HEX_CHARREF = 6
|
| 54 |
+
XML_ERR_INVALID_DEC_CHARREF = 7
|
| 55 |
+
XML_ERR_INVALID_CHARREF = 8
|
| 56 |
+
XML_ERR_INVALID_CHAR = 9
|
| 57 |
+
XML_ERR_CHARREF_AT_EOF = 10
|
| 58 |
+
XML_ERR_CHARREF_IN_PROLOG = 11
|
| 59 |
+
XML_ERR_CHARREF_IN_EPILOG = 12
|
| 60 |
+
XML_ERR_CHARREF_IN_DTD = 13
|
| 61 |
+
XML_ERR_ENTITYREF_AT_EOF = 14
|
| 62 |
+
XML_ERR_ENTITYREF_IN_PROLOG = 15
|
| 63 |
+
XML_ERR_ENTITYREF_IN_EPILOG = 16
|
| 64 |
+
XML_ERR_ENTITYREF_IN_DTD = 17
|
| 65 |
+
XML_ERR_PEREF_AT_EOF = 18
|
| 66 |
+
XML_ERR_PEREF_IN_PROLOG = 19
|
| 67 |
+
XML_ERR_PEREF_IN_EPILOG = 20
|
| 68 |
+
XML_ERR_PEREF_IN_INT_SUBSET = 21
|
| 69 |
+
XML_ERR_ENTITYREF_NO_NAME = 22
|
| 70 |
+
XML_ERR_ENTITYREF_SEMICOL_MISSING = 23
|
| 71 |
+
XML_ERR_PEREF_NO_NAME = 24
|
| 72 |
+
XML_ERR_PEREF_SEMICOL_MISSING = 25
|
| 73 |
+
XML_ERR_UNDECLARED_ENTITY = 26
|
| 74 |
+
XML_WAR_UNDECLARED_ENTITY = 27
|
| 75 |
+
XML_ERR_UNPARSED_ENTITY = 28
|
| 76 |
+
XML_ERR_ENTITY_IS_EXTERNAL = 29
|
| 77 |
+
XML_ERR_ENTITY_IS_PARAMETER = 30
|
| 78 |
+
XML_ERR_UNKNOWN_ENCODING = 31
|
| 79 |
+
XML_ERR_UNSUPPORTED_ENCODING = 32
|
| 80 |
+
XML_ERR_STRING_NOT_STARTED = 33
|
| 81 |
+
XML_ERR_STRING_NOT_CLOSED = 34
|
| 82 |
+
XML_ERR_NS_DECL_ERROR = 35
|
| 83 |
+
XML_ERR_ENTITY_NOT_STARTED = 36
|
| 84 |
+
XML_ERR_ENTITY_NOT_FINISHED = 37
|
| 85 |
+
XML_ERR_LT_IN_ATTRIBUTE = 38
|
| 86 |
+
XML_ERR_ATTRIBUTE_NOT_STARTED = 39
|
| 87 |
+
XML_ERR_ATTRIBUTE_NOT_FINISHED = 40
|
| 88 |
+
XML_ERR_ATTRIBUTE_WITHOUT_VALUE = 41
|
| 89 |
+
XML_ERR_ATTRIBUTE_REDEFINED = 42
|
| 90 |
+
XML_ERR_LITERAL_NOT_STARTED = 43
|
| 91 |
+
XML_ERR_LITERAL_NOT_FINISHED = 44
|
| 92 |
+
XML_ERR_COMMENT_NOT_FINISHED = 45
|
| 93 |
+
XML_ERR_PI_NOT_STARTED = 46
|
| 94 |
+
XML_ERR_PI_NOT_FINISHED = 47
|
| 95 |
+
XML_ERR_NOTATION_NOT_STARTED = 48
|
| 96 |
+
XML_ERR_NOTATION_NOT_FINISHED = 49
|
| 97 |
+
XML_ERR_ATTLIST_NOT_STARTED = 50
|
| 98 |
+
XML_ERR_ATTLIST_NOT_FINISHED = 51
|
| 99 |
+
XML_ERR_MIXED_NOT_STARTED = 52
|
| 100 |
+
XML_ERR_MIXED_NOT_FINISHED = 53
|
| 101 |
+
XML_ERR_ELEMCONTENT_NOT_STARTED = 54
|
| 102 |
+
XML_ERR_ELEMCONTENT_NOT_FINISHED = 55
|
| 103 |
+
XML_ERR_XMLDECL_NOT_STARTED = 56
|
| 104 |
+
XML_ERR_XMLDECL_NOT_FINISHED = 57
|
| 105 |
+
XML_ERR_CONDSEC_NOT_STARTED = 58
|
| 106 |
+
XML_ERR_CONDSEC_NOT_FINISHED = 59
|
| 107 |
+
XML_ERR_EXT_SUBSET_NOT_FINISHED = 60
|
| 108 |
+
XML_ERR_DOCTYPE_NOT_FINISHED = 61
|
| 109 |
+
XML_ERR_MISPLACED_CDATA_END = 62
|
| 110 |
+
XML_ERR_CDATA_NOT_FINISHED = 63
|
| 111 |
+
XML_ERR_RESERVED_XML_NAME = 64
|
| 112 |
+
XML_ERR_SPACE_REQUIRED = 65
|
| 113 |
+
XML_ERR_SEPARATOR_REQUIRED = 66
|
| 114 |
+
XML_ERR_NMTOKEN_REQUIRED = 67
|
| 115 |
+
XML_ERR_NAME_REQUIRED = 68
|
| 116 |
+
XML_ERR_PCDATA_REQUIRED = 69
|
| 117 |
+
XML_ERR_URI_REQUIRED = 70
|
| 118 |
+
XML_ERR_PUBID_REQUIRED = 71
|
| 119 |
+
XML_ERR_LT_REQUIRED = 72
|
| 120 |
+
XML_ERR_GT_REQUIRED = 73
|
| 121 |
+
XML_ERR_LTSLASH_REQUIRED = 74
|
| 122 |
+
XML_ERR_EQUAL_REQUIRED = 75
|
| 123 |
+
XML_ERR_TAG_NAME_MISMATCH = 76
|
| 124 |
+
XML_ERR_TAG_NOT_FINISHED = 77
|
| 125 |
+
XML_ERR_STANDALONE_VALUE = 78
|
| 126 |
+
XML_ERR_ENCODING_NAME = 79
|
| 127 |
+
XML_ERR_HYPHEN_IN_COMMENT = 80
|
| 128 |
+
XML_ERR_INVALID_ENCODING = 81
|
| 129 |
+
XML_ERR_EXT_ENTITY_STANDALONE = 82
|
| 130 |
+
XML_ERR_CONDSEC_INVALID = 83
|
| 131 |
+
XML_ERR_VALUE_REQUIRED = 84
|
| 132 |
+
XML_ERR_NOT_WELL_BALANCED = 85
|
| 133 |
+
XML_ERR_EXTRA_CONTENT = 86
|
| 134 |
+
XML_ERR_ENTITY_CHAR_ERROR = 87
|
| 135 |
+
XML_ERR_ENTITY_PE_INTERNAL = 88
|
| 136 |
+
XML_ERR_ENTITY_LOOP = 89
|
| 137 |
+
XML_ERR_ENTITY_BOUNDARY = 90
|
| 138 |
+
XML_ERR_INVALID_URI = 91
|
| 139 |
+
XML_ERR_URI_FRAGMENT = 92
|
| 140 |
+
XML_WAR_CATALOG_PI = 93
|
| 141 |
+
XML_ERR_NO_DTD = 94
|
| 142 |
+
XML_ERR_CONDSEC_INVALID_KEYWORD = 95
|
| 143 |
+
XML_ERR_VERSION_MISSING = 96
|
| 144 |
+
XML_WAR_UNKNOWN_VERSION = 97
|
| 145 |
+
XML_WAR_LANG_VALUE = 98
|
| 146 |
+
XML_WAR_NS_URI = 99
|
| 147 |
+
XML_WAR_NS_URI_RELATIVE = 100
|
| 148 |
+
XML_ERR_MISSING_ENCODING = 101
|
| 149 |
+
XML_WAR_SPACE_VALUE = 102
|
| 150 |
+
XML_ERR_NOT_STANDALONE = 103
|
| 151 |
+
XML_ERR_ENTITY_PROCESSING = 104
|
| 152 |
+
XML_ERR_NOTATION_PROCESSING = 105
|
| 153 |
+
XML_WAR_NS_COLUMN = 106
|
| 154 |
+
XML_WAR_ENTITY_REDEFINED = 107
|
| 155 |
+
XML_ERR_UNKNOWN_VERSION = 108
|
| 156 |
+
XML_ERR_VERSION_MISMATCH = 109
|
| 157 |
+
XML_ERR_NAME_TOO_LONG = 110
|
| 158 |
+
XML_ERR_USER_STOP = 111
|
| 159 |
+
XML_ERR_COMMENT_ABRUPTLY_ENDED = 112
|
| 160 |
+
XML_NS_ERR_XML_NAMESPACE = 200
|
| 161 |
+
XML_NS_ERR_UNDEFINED_NAMESPACE = 201
|
| 162 |
+
XML_NS_ERR_QNAME = 202
|
| 163 |
+
XML_NS_ERR_ATTRIBUTE_REDEFINED = 203
|
| 164 |
+
XML_NS_ERR_EMPTY = 204
|
| 165 |
+
XML_NS_ERR_COLON = 205
|
| 166 |
+
XML_DTD_ATTRIBUTE_DEFAULT = 500
|
| 167 |
+
XML_DTD_ATTRIBUTE_REDEFINED = 501
|
| 168 |
+
XML_DTD_ATTRIBUTE_VALUE = 502
|
| 169 |
+
XML_DTD_CONTENT_ERROR = 503
|
| 170 |
+
XML_DTD_CONTENT_MODEL = 504
|
| 171 |
+
XML_DTD_CONTENT_NOT_DETERMINIST = 505
|
| 172 |
+
XML_DTD_DIFFERENT_PREFIX = 506
|
| 173 |
+
XML_DTD_ELEM_DEFAULT_NAMESPACE = 507
|
| 174 |
+
XML_DTD_ELEM_NAMESPACE = 508
|
| 175 |
+
XML_DTD_ELEM_REDEFINED = 509
|
| 176 |
+
XML_DTD_EMPTY_NOTATION = 510
|
| 177 |
+
XML_DTD_ENTITY_TYPE = 511
|
| 178 |
+
XML_DTD_ID_FIXED = 512
|
| 179 |
+
XML_DTD_ID_REDEFINED = 513
|
| 180 |
+
XML_DTD_ID_SUBSET = 514
|
| 181 |
+
XML_DTD_INVALID_CHILD = 515
|
| 182 |
+
XML_DTD_INVALID_DEFAULT = 516
|
| 183 |
+
XML_DTD_LOAD_ERROR = 517
|
| 184 |
+
XML_DTD_MISSING_ATTRIBUTE = 518
|
| 185 |
+
XML_DTD_MIXED_CORRUPT = 519
|
| 186 |
+
XML_DTD_MULTIPLE_ID = 520
|
| 187 |
+
XML_DTD_NO_DOC = 521
|
| 188 |
+
XML_DTD_NO_DTD = 522
|
| 189 |
+
XML_DTD_NO_ELEM_NAME = 523
|
| 190 |
+
XML_DTD_NO_PREFIX = 524
|
| 191 |
+
XML_DTD_NO_ROOT = 525
|
| 192 |
+
XML_DTD_NOTATION_REDEFINED = 526
|
| 193 |
+
XML_DTD_NOTATION_VALUE = 527
|
| 194 |
+
XML_DTD_NOT_EMPTY = 528
|
| 195 |
+
XML_DTD_NOT_PCDATA = 529
|
| 196 |
+
XML_DTD_NOT_STANDALONE = 530
|
| 197 |
+
XML_DTD_ROOT_NAME = 531
|
| 198 |
+
XML_DTD_STANDALONE_WHITE_SPACE = 532
|
| 199 |
+
XML_DTD_UNKNOWN_ATTRIBUTE = 533
|
| 200 |
+
XML_DTD_UNKNOWN_ELEM = 534
|
| 201 |
+
XML_DTD_UNKNOWN_ENTITY = 535
|
| 202 |
+
XML_DTD_UNKNOWN_ID = 536
|
| 203 |
+
XML_DTD_UNKNOWN_NOTATION = 537
|
| 204 |
+
XML_DTD_STANDALONE_DEFAULTED = 538
|
| 205 |
+
XML_DTD_XMLID_VALUE = 539
|
| 206 |
+
XML_DTD_XMLID_TYPE = 540
|
| 207 |
+
XML_DTD_DUP_TOKEN = 541
|
| 208 |
+
XML_HTML_STRUCURE_ERROR = 800
|
| 209 |
+
XML_HTML_UNKNOWN_TAG = 801
|
| 210 |
+
XML_RNGP_ANYNAME_ATTR_ANCESTOR = 1000
|
| 211 |
+
XML_RNGP_ATTR_CONFLICT = 1001
|
| 212 |
+
XML_RNGP_ATTRIBUTE_CHILDREN = 1002
|
| 213 |
+
XML_RNGP_ATTRIBUTE_CONTENT = 1003
|
| 214 |
+
XML_RNGP_ATTRIBUTE_EMPTY = 1004
|
| 215 |
+
XML_RNGP_ATTRIBUTE_NOOP = 1005
|
| 216 |
+
XML_RNGP_CHOICE_CONTENT = 1006
|
| 217 |
+
XML_RNGP_CHOICE_EMPTY = 1007
|
| 218 |
+
XML_RNGP_CREATE_FAILURE = 1008
|
| 219 |
+
XML_RNGP_DATA_CONTENT = 1009
|
| 220 |
+
XML_RNGP_DEF_CHOICE_AND_INTERLEAVE = 1010
|
| 221 |
+
XML_RNGP_DEFINE_CREATE_FAILED = 1011
|
| 222 |
+
XML_RNGP_DEFINE_EMPTY = 1012
|
| 223 |
+
XML_RNGP_DEFINE_MISSING = 1013
|
| 224 |
+
XML_RNGP_DEFINE_NAME_MISSING = 1014
|
| 225 |
+
XML_RNGP_ELEM_CONTENT_EMPTY = 1015
|
| 226 |
+
XML_RNGP_ELEM_CONTENT_ERROR = 1016
|
| 227 |
+
XML_RNGP_ELEMENT_EMPTY = 1017
|
| 228 |
+
XML_RNGP_ELEMENT_CONTENT = 1018
|
| 229 |
+
XML_RNGP_ELEMENT_NAME = 1019
|
| 230 |
+
XML_RNGP_ELEMENT_NO_CONTENT = 1020
|
| 231 |
+
XML_RNGP_ELEM_TEXT_CONFLICT = 1021
|
| 232 |
+
XML_RNGP_EMPTY = 1022
|
| 233 |
+
XML_RNGP_EMPTY_CONSTRUCT = 1023
|
| 234 |
+
XML_RNGP_EMPTY_CONTENT = 1024
|
| 235 |
+
XML_RNGP_EMPTY_NOT_EMPTY = 1025
|
| 236 |
+
XML_RNGP_ERROR_TYPE_LIB = 1026
|
| 237 |
+
XML_RNGP_EXCEPT_EMPTY = 1027
|
| 238 |
+
XML_RNGP_EXCEPT_MISSING = 1028
|
| 239 |
+
XML_RNGP_EXCEPT_MULTIPLE = 1029
|
| 240 |
+
XML_RNGP_EXCEPT_NO_CONTENT = 1030
|
| 241 |
+
XML_RNGP_EXTERNALREF_EMTPY = 1031
|
| 242 |
+
XML_RNGP_EXTERNAL_REF_FAILURE = 1032
|
| 243 |
+
XML_RNGP_EXTERNALREF_RECURSE = 1033
|
| 244 |
+
XML_RNGP_FORBIDDEN_ATTRIBUTE = 1034
|
| 245 |
+
XML_RNGP_FOREIGN_ELEMENT = 1035
|
| 246 |
+
XML_RNGP_GRAMMAR_CONTENT = 1036
|
| 247 |
+
XML_RNGP_GRAMMAR_EMPTY = 1037
|
| 248 |
+
XML_RNGP_GRAMMAR_MISSING = 1038
|
| 249 |
+
XML_RNGP_GRAMMAR_NO_START = 1039
|
| 250 |
+
XML_RNGP_GROUP_ATTR_CONFLICT = 1040
|
| 251 |
+
XML_RNGP_HREF_ERROR = 1041
|
| 252 |
+
XML_RNGP_INCLUDE_EMPTY = 1042
|
| 253 |
+
XML_RNGP_INCLUDE_FAILURE = 1043
|
| 254 |
+
XML_RNGP_INCLUDE_RECURSE = 1044
|
| 255 |
+
XML_RNGP_INTERLEAVE_ADD = 1045
|
| 256 |
+
XML_RNGP_INTERLEAVE_CREATE_FAILED = 1046
|
| 257 |
+
XML_RNGP_INTERLEAVE_EMPTY = 1047
|
| 258 |
+
XML_RNGP_INTERLEAVE_NO_CONTENT = 1048
|
| 259 |
+
XML_RNGP_INVALID_DEFINE_NAME = 1049
|
| 260 |
+
XML_RNGP_INVALID_URI = 1050
|
| 261 |
+
XML_RNGP_INVALID_VALUE = 1051
|
| 262 |
+
XML_RNGP_MISSING_HREF = 1052
|
| 263 |
+
XML_RNGP_NAME_MISSING = 1053
|
| 264 |
+
XML_RNGP_NEED_COMBINE = 1054
|
| 265 |
+
XML_RNGP_NOTALLOWED_NOT_EMPTY = 1055
|
| 266 |
+
XML_RNGP_NSNAME_ATTR_ANCESTOR = 1056
|
| 267 |
+
XML_RNGP_NSNAME_NO_NS = 1057
|
| 268 |
+
XML_RNGP_PARAM_FORBIDDEN = 1058
|
| 269 |
+
XML_RNGP_PARAM_NAME_MISSING = 1059
|
| 270 |
+
XML_RNGP_PARENTREF_CREATE_FAILED = 1060
|
| 271 |
+
XML_RNGP_PARENTREF_NAME_INVALID = 1061
|
| 272 |
+
XML_RNGP_PARENTREF_NO_NAME = 1062
|
| 273 |
+
XML_RNGP_PARENTREF_NO_PARENT = 1063
|
| 274 |
+
XML_RNGP_PARENTREF_NOT_EMPTY = 1064
|
| 275 |
+
XML_RNGP_PARSE_ERROR = 1065
|
| 276 |
+
XML_RNGP_PAT_ANYNAME_EXCEPT_ANYNAME = 1066
|
| 277 |
+
XML_RNGP_PAT_ATTR_ATTR = 1067
|
| 278 |
+
XML_RNGP_PAT_ATTR_ELEM = 1068
|
| 279 |
+
XML_RNGP_PAT_DATA_EXCEPT_ATTR = 1069
|
| 280 |
+
XML_RNGP_PAT_DATA_EXCEPT_ELEM = 1070
|
| 281 |
+
XML_RNGP_PAT_DATA_EXCEPT_EMPTY = 1071
|
| 282 |
+
XML_RNGP_PAT_DATA_EXCEPT_GROUP = 1072
|
| 283 |
+
XML_RNGP_PAT_DATA_EXCEPT_INTERLEAVE = 1073
|
| 284 |
+
XML_RNGP_PAT_DATA_EXCEPT_LIST = 1074
|
| 285 |
+
XML_RNGP_PAT_DATA_EXCEPT_ONEMORE = 1075
|
| 286 |
+
XML_RNGP_PAT_DATA_EXCEPT_REF = 1076
|
| 287 |
+
XML_RNGP_PAT_DATA_EXCEPT_TEXT = 1077
|
| 288 |
+
XML_RNGP_PAT_LIST_ATTR = 1078
|
| 289 |
+
XML_RNGP_PAT_LIST_ELEM = 1079
|
| 290 |
+
XML_RNGP_PAT_LIST_INTERLEAVE = 1080
|
| 291 |
+
XML_RNGP_PAT_LIST_LIST = 1081
|
| 292 |
+
XML_RNGP_PAT_LIST_REF = 1082
|
| 293 |
+
XML_RNGP_PAT_LIST_TEXT = 1083
|
| 294 |
+
XML_RNGP_PAT_NSNAME_EXCEPT_ANYNAME = 1084
|
| 295 |
+
XML_RNGP_PAT_NSNAME_EXCEPT_NSNAME = 1085
|
| 296 |
+
XML_RNGP_PAT_ONEMORE_GROUP_ATTR = 1086
|
| 297 |
+
XML_RNGP_PAT_ONEMORE_INTERLEAVE_ATTR = 1087
|
| 298 |
+
XML_RNGP_PAT_START_ATTR = 1088
|
| 299 |
+
XML_RNGP_PAT_START_DATA = 1089
|
| 300 |
+
XML_RNGP_PAT_START_EMPTY = 1090
|
| 301 |
+
XML_RNGP_PAT_START_GROUP = 1091
|
| 302 |
+
XML_RNGP_PAT_START_INTERLEAVE = 1092
|
| 303 |
+
XML_RNGP_PAT_START_LIST = 1093
|
| 304 |
+
XML_RNGP_PAT_START_ONEMORE = 1094
|
| 305 |
+
XML_RNGP_PAT_START_TEXT = 1095
|
| 306 |
+
XML_RNGP_PAT_START_VALUE = 1096
|
| 307 |
+
XML_RNGP_PREFIX_UNDEFINED = 1097
|
| 308 |
+
XML_RNGP_REF_CREATE_FAILED = 1098
|
| 309 |
+
XML_RNGP_REF_CYCLE = 1099
|
| 310 |
+
XML_RNGP_REF_NAME_INVALID = 1100
|
| 311 |
+
XML_RNGP_REF_NO_DEF = 1101
|
| 312 |
+
XML_RNGP_REF_NO_NAME = 1102
|
| 313 |
+
XML_RNGP_REF_NOT_EMPTY = 1103
|
| 314 |
+
XML_RNGP_START_CHOICE_AND_INTERLEAVE = 1104
|
| 315 |
+
XML_RNGP_START_CONTENT = 1105
|
| 316 |
+
XML_RNGP_START_EMPTY = 1106
|
| 317 |
+
XML_RNGP_START_MISSING = 1107
|
| 318 |
+
XML_RNGP_TEXT_EXPECTED = 1108
|
| 319 |
+
XML_RNGP_TEXT_HAS_CHILD = 1109
|
| 320 |
+
XML_RNGP_TYPE_MISSING = 1110
|
| 321 |
+
XML_RNGP_TYPE_NOT_FOUND = 1111
|
| 322 |
+
XML_RNGP_TYPE_VALUE = 1112
|
| 323 |
+
XML_RNGP_UNKNOWN_ATTRIBUTE = 1113
|
| 324 |
+
XML_RNGP_UNKNOWN_COMBINE = 1114
|
| 325 |
+
XML_RNGP_UNKNOWN_CONSTRUCT = 1115
|
| 326 |
+
XML_RNGP_UNKNOWN_TYPE_LIB = 1116
|
| 327 |
+
XML_RNGP_URI_FRAGMENT = 1117
|
| 328 |
+
XML_RNGP_URI_NOT_ABSOLUTE = 1118
|
| 329 |
+
XML_RNGP_VALUE_EMPTY = 1119
|
| 330 |
+
XML_RNGP_VALUE_NO_CONTENT = 1120
|
| 331 |
+
XML_RNGP_XMLNS_NAME = 1121
|
| 332 |
+
XML_RNGP_XML_NS = 1122
|
| 333 |
+
XML_XPATH_EXPRESSION_OK = 1200
|
| 334 |
+
XML_XPATH_NUMBER_ERROR = 1201
|
| 335 |
+
XML_XPATH_UNFINISHED_LITERAL_ERROR = 1202
|
| 336 |
+
XML_XPATH_START_LITERAL_ERROR = 1203
|
| 337 |
+
XML_XPATH_VARIABLE_REF_ERROR = 1204
|
| 338 |
+
XML_XPATH_UNDEF_VARIABLE_ERROR = 1205
|
| 339 |
+
XML_XPATH_INVALID_PREDICATE_ERROR = 1206
|
| 340 |
+
XML_XPATH_EXPR_ERROR = 1207
|
| 341 |
+
XML_XPATH_UNCLOSED_ERROR = 1208
|
| 342 |
+
XML_XPATH_UNKNOWN_FUNC_ERROR = 1209
|
| 343 |
+
XML_XPATH_INVALID_OPERAND = 1210
|
| 344 |
+
XML_XPATH_INVALID_TYPE = 1211
|
| 345 |
+
XML_XPATH_INVALID_ARITY = 1212
|
| 346 |
+
XML_XPATH_INVALID_CTXT_SIZE = 1213
|
| 347 |
+
XML_XPATH_INVALID_CTXT_POSITION = 1214
|
| 348 |
+
XML_XPATH_MEMORY_ERROR = 1215
|
| 349 |
+
XML_XPTR_SYNTAX_ERROR = 1216
|
| 350 |
+
XML_XPTR_RESOURCE_ERROR = 1217
|
| 351 |
+
XML_XPTR_SUB_RESOURCE_ERROR = 1218
|
| 352 |
+
XML_XPATH_UNDEF_PREFIX_ERROR = 1219
|
| 353 |
+
XML_XPATH_ENCODING_ERROR = 1220
|
| 354 |
+
XML_XPATH_INVALID_CHAR_ERROR = 1221
|
| 355 |
+
XML_TREE_INVALID_HEX = 1300
|
| 356 |
+
XML_TREE_INVALID_DEC = 1301
|
| 357 |
+
XML_TREE_UNTERMINATED_ENTITY = 1302
|
| 358 |
+
XML_TREE_NOT_UTF8 = 1303
|
| 359 |
+
XML_SAVE_NOT_UTF8 = 1400
|
| 360 |
+
XML_SAVE_CHAR_INVALID = 1401
|
| 361 |
+
XML_SAVE_NO_DOCTYPE = 1402
|
| 362 |
+
XML_SAVE_UNKNOWN_ENCODING = 1403
|
| 363 |
+
XML_REGEXP_COMPILE_ERROR = 1450
|
| 364 |
+
XML_IO_UNKNOWN = 1500
|
| 365 |
+
XML_IO_EACCES = 1501
|
| 366 |
+
XML_IO_EAGAIN = 1502
|
| 367 |
+
XML_IO_EBADF = 1503
|
| 368 |
+
XML_IO_EBADMSG = 1504
|
| 369 |
+
XML_IO_EBUSY = 1505
|
| 370 |
+
XML_IO_ECANCELED = 1506
|
| 371 |
+
XML_IO_ECHILD = 1507
|
| 372 |
+
XML_IO_EDEADLK = 1508
|
| 373 |
+
XML_IO_EDOM = 1509
|
| 374 |
+
XML_IO_EEXIST = 1510
|
| 375 |
+
XML_IO_EFAULT = 1511
|
| 376 |
+
XML_IO_EFBIG = 1512
|
| 377 |
+
XML_IO_EINPROGRESS = 1513
|
| 378 |
+
XML_IO_EINTR = 1514
|
| 379 |
+
XML_IO_EINVAL = 1515
|
| 380 |
+
XML_IO_EIO = 1516
|
| 381 |
+
XML_IO_EISDIR = 1517
|
| 382 |
+
XML_IO_EMFILE = 1518
|
| 383 |
+
XML_IO_EMLINK = 1519
|
| 384 |
+
XML_IO_EMSGSIZE = 1520
|
| 385 |
+
XML_IO_ENAMETOOLONG = 1521
|
| 386 |
+
XML_IO_ENFILE = 1522
|
| 387 |
+
XML_IO_ENODEV = 1523
|
| 388 |
+
XML_IO_ENOENT = 1524
|
| 389 |
+
XML_IO_ENOEXEC = 1525
|
| 390 |
+
XML_IO_ENOLCK = 1526
|
| 391 |
+
XML_IO_ENOMEM = 1527
|
| 392 |
+
XML_IO_ENOSPC = 1528
|
| 393 |
+
XML_IO_ENOSYS = 1529
|
| 394 |
+
XML_IO_ENOTDIR = 1530
|
| 395 |
+
XML_IO_ENOTEMPTY = 1531
|
| 396 |
+
XML_IO_ENOTSUP = 1532
|
| 397 |
+
XML_IO_ENOTTY = 1533
|
| 398 |
+
XML_IO_ENXIO = 1534
|
| 399 |
+
XML_IO_EPERM = 1535
|
| 400 |
+
XML_IO_EPIPE = 1536
|
| 401 |
+
XML_IO_ERANGE = 1537
|
| 402 |
+
XML_IO_EROFS = 1538
|
| 403 |
+
XML_IO_ESPIPE = 1539
|
| 404 |
+
XML_IO_ESRCH = 1540
|
| 405 |
+
XML_IO_ETIMEDOUT = 1541
|
| 406 |
+
XML_IO_EXDEV = 1542
|
| 407 |
+
XML_IO_NETWORK_ATTEMPT = 1543
|
| 408 |
+
XML_IO_ENCODER = 1544
|
| 409 |
+
XML_IO_FLUSH = 1545
|
| 410 |
+
XML_IO_WRITE = 1546
|
| 411 |
+
XML_IO_NO_INPUT = 1547
|
| 412 |
+
XML_IO_BUFFER_FULL = 1548
|
| 413 |
+
XML_IO_LOAD_ERROR = 1549
|
| 414 |
+
XML_IO_ENOTSOCK = 1550
|
| 415 |
+
XML_IO_EISCONN = 1551
|
| 416 |
+
XML_IO_ECONNREFUSED = 1552
|
| 417 |
+
XML_IO_ENETUNREACH = 1553
|
| 418 |
+
XML_IO_EADDRINUSE = 1554
|
| 419 |
+
XML_IO_EALREADY = 1555
|
| 420 |
+
XML_IO_EAFNOSUPPORT = 1556
|
| 421 |
+
XML_XINCLUDE_RECURSION = 1600
|
| 422 |
+
XML_XINCLUDE_PARSE_VALUE = 1601
|
| 423 |
+
XML_XINCLUDE_ENTITY_DEF_MISMATCH = 1602
|
| 424 |
+
XML_XINCLUDE_NO_HREF = 1603
|
| 425 |
+
XML_XINCLUDE_NO_FALLBACK = 1604
|
| 426 |
+
XML_XINCLUDE_HREF_URI = 1605
|
| 427 |
+
XML_XINCLUDE_TEXT_FRAGMENT = 1606
|
| 428 |
+
XML_XINCLUDE_TEXT_DOCUMENT = 1607
|
| 429 |
+
XML_XINCLUDE_INVALID_CHAR = 1608
|
| 430 |
+
XML_XINCLUDE_BUILD_FAILED = 1609
|
| 431 |
+
XML_XINCLUDE_UNKNOWN_ENCODING = 1610
|
| 432 |
+
XML_XINCLUDE_MULTIPLE_ROOT = 1611
|
| 433 |
+
XML_XINCLUDE_XPTR_FAILED = 1612
|
| 434 |
+
XML_XINCLUDE_XPTR_RESULT = 1613
|
| 435 |
+
XML_XINCLUDE_INCLUDE_IN_INCLUDE = 1614
|
| 436 |
+
XML_XINCLUDE_FALLBACKS_IN_INCLUDE = 1615
|
| 437 |
+
XML_XINCLUDE_FALLBACK_NOT_IN_INCLUDE = 1616
|
| 438 |
+
XML_XINCLUDE_DEPRECATED_NS = 1617
|
| 439 |
+
XML_XINCLUDE_FRAGMENT_ID = 1618
|
| 440 |
+
XML_CATALOG_MISSING_ATTR = 1650
|
| 441 |
+
XML_CATALOG_ENTRY_BROKEN = 1651
|
| 442 |
+
XML_CATALOG_PREFER_VALUE = 1652
|
| 443 |
+
XML_CATALOG_NOT_CATALOG = 1653
|
| 444 |
+
XML_CATALOG_RECURSION = 1654
|
| 445 |
+
XML_SCHEMAP_PREFIX_UNDEFINED = 1700
|
| 446 |
+
XML_SCHEMAP_ATTRFORMDEFAULT_VALUE = 1701
|
| 447 |
+
XML_SCHEMAP_ATTRGRP_NONAME_NOREF = 1702
|
| 448 |
+
XML_SCHEMAP_ATTR_NONAME_NOREF = 1703
|
| 449 |
+
XML_SCHEMAP_COMPLEXTYPE_NONAME_NOREF = 1704
|
| 450 |
+
XML_SCHEMAP_ELEMFORMDEFAULT_VALUE = 1705
|
| 451 |
+
XML_SCHEMAP_ELEM_NONAME_NOREF = 1706
|
| 452 |
+
XML_SCHEMAP_EXTENSION_NO_BASE = 1707
|
| 453 |
+
XML_SCHEMAP_FACET_NO_VALUE = 1708
|
| 454 |
+
XML_SCHEMAP_FAILED_BUILD_IMPORT = 1709
|
| 455 |
+
XML_SCHEMAP_GROUP_NONAME_NOREF = 1710
|
| 456 |
+
XML_SCHEMAP_IMPORT_NAMESPACE_NOT_URI = 1711
|
| 457 |
+
XML_SCHEMAP_IMPORT_REDEFINE_NSNAME = 1712
|
| 458 |
+
XML_SCHEMAP_IMPORT_SCHEMA_NOT_URI = 1713
|
| 459 |
+
XML_SCHEMAP_INVALID_BOOLEAN = 1714
|
| 460 |
+
XML_SCHEMAP_INVALID_ENUM = 1715
|
| 461 |
+
XML_SCHEMAP_INVALID_FACET = 1716
|
| 462 |
+
XML_SCHEMAP_INVALID_FACET_VALUE = 1717
|
| 463 |
+
XML_SCHEMAP_INVALID_MAXOCCURS = 1718
|
| 464 |
+
XML_SCHEMAP_INVALID_MINOCCURS = 1719
|
| 465 |
+
XML_SCHEMAP_INVALID_REF_AND_SUBTYPE = 1720
|
| 466 |
+
XML_SCHEMAP_INVALID_WHITE_SPACE = 1721
|
| 467 |
+
XML_SCHEMAP_NOATTR_NOREF = 1722
|
| 468 |
+
XML_SCHEMAP_NOTATION_NO_NAME = 1723
|
| 469 |
+
XML_SCHEMAP_NOTYPE_NOREF = 1724
|
| 470 |
+
XML_SCHEMAP_REF_AND_SUBTYPE = 1725
|
| 471 |
+
XML_SCHEMAP_RESTRICTION_NONAME_NOREF = 1726
|
| 472 |
+
XML_SCHEMAP_SIMPLETYPE_NONAME = 1727
|
| 473 |
+
XML_SCHEMAP_TYPE_AND_SUBTYPE = 1728
|
| 474 |
+
XML_SCHEMAP_UNKNOWN_ALL_CHILD = 1729
|
| 475 |
+
XML_SCHEMAP_UNKNOWN_ANYATTRIBUTE_CHILD = 1730
|
| 476 |
+
XML_SCHEMAP_UNKNOWN_ATTR_CHILD = 1731
|
| 477 |
+
XML_SCHEMAP_UNKNOWN_ATTRGRP_CHILD = 1732
|
| 478 |
+
XML_SCHEMAP_UNKNOWN_ATTRIBUTE_GROUP = 1733
|
| 479 |
+
XML_SCHEMAP_UNKNOWN_BASE_TYPE = 1734
|
| 480 |
+
XML_SCHEMAP_UNKNOWN_CHOICE_CHILD = 1735
|
| 481 |
+
XML_SCHEMAP_UNKNOWN_COMPLEXCONTENT_CHILD = 1736
|
| 482 |
+
XML_SCHEMAP_UNKNOWN_COMPLEXTYPE_CHILD = 1737
|
| 483 |
+
XML_SCHEMAP_UNKNOWN_ELEM_CHILD = 1738
|
| 484 |
+
XML_SCHEMAP_UNKNOWN_EXTENSION_CHILD = 1739
|
| 485 |
+
XML_SCHEMAP_UNKNOWN_FACET_CHILD = 1740
|
| 486 |
+
XML_SCHEMAP_UNKNOWN_FACET_TYPE = 1741
|
| 487 |
+
XML_SCHEMAP_UNKNOWN_GROUP_CHILD = 1742
|
| 488 |
+
XML_SCHEMAP_UNKNOWN_IMPORT_CHILD = 1743
|
| 489 |
+
XML_SCHEMAP_UNKNOWN_LIST_CHILD = 1744
|
| 490 |
+
XML_SCHEMAP_UNKNOWN_NOTATION_CHILD = 1745
|
| 491 |
+
XML_SCHEMAP_UNKNOWN_PROCESSCONTENT_CHILD = 1746
|
| 492 |
+
XML_SCHEMAP_UNKNOWN_REF = 1747
|
| 493 |
+
XML_SCHEMAP_UNKNOWN_RESTRICTION_CHILD = 1748
|
| 494 |
+
XML_SCHEMAP_UNKNOWN_SCHEMAS_CHILD = 1749
|
| 495 |
+
XML_SCHEMAP_UNKNOWN_SEQUENCE_CHILD = 1750
|
| 496 |
+
XML_SCHEMAP_UNKNOWN_SIMPLECONTENT_CHILD = 1751
|
| 497 |
+
XML_SCHEMAP_UNKNOWN_SIMPLETYPE_CHILD = 1752
|
| 498 |
+
XML_SCHEMAP_UNKNOWN_TYPE = 1753
|
| 499 |
+
XML_SCHEMAP_UNKNOWN_UNION_CHILD = 1754
|
| 500 |
+
XML_SCHEMAP_ELEM_DEFAULT_FIXED = 1755
|
| 501 |
+
XML_SCHEMAP_REGEXP_INVALID = 1756
|
| 502 |
+
XML_SCHEMAP_FAILED_LOAD = 1757
|
| 503 |
+
XML_SCHEMAP_NOTHING_TO_PARSE = 1758
|
| 504 |
+
XML_SCHEMAP_NOROOT = 1759
|
| 505 |
+
XML_SCHEMAP_REDEFINED_GROUP = 1760
|
| 506 |
+
XML_SCHEMAP_REDEFINED_TYPE = 1761
|
| 507 |
+
XML_SCHEMAP_REDEFINED_ELEMENT = 1762
|
| 508 |
+
XML_SCHEMAP_REDEFINED_ATTRGROUP = 1763
|
| 509 |
+
XML_SCHEMAP_REDEFINED_ATTR = 1764
|
| 510 |
+
XML_SCHEMAP_REDEFINED_NOTATION = 1765
|
| 511 |
+
XML_SCHEMAP_FAILED_PARSE = 1766
|
| 512 |
+
XML_SCHEMAP_UNKNOWN_PREFIX = 1767
|
| 513 |
+
XML_SCHEMAP_DEF_AND_PREFIX = 1768
|
| 514 |
+
XML_SCHEMAP_UNKNOWN_INCLUDE_CHILD = 1769
|
| 515 |
+
XML_SCHEMAP_INCLUDE_SCHEMA_NOT_URI = 1770
|
| 516 |
+
XML_SCHEMAP_INCLUDE_SCHEMA_NO_URI = 1771
|
| 517 |
+
XML_SCHEMAP_NOT_SCHEMA = 1772
|
| 518 |
+
XML_SCHEMAP_UNKNOWN_MEMBER_TYPE = 1773
|
| 519 |
+
XML_SCHEMAP_INVALID_ATTR_USE = 1774
|
| 520 |
+
XML_SCHEMAP_RECURSIVE = 1775
|
| 521 |
+
XML_SCHEMAP_SUPERNUMEROUS_LIST_ITEM_TYPE = 1776
|
| 522 |
+
XML_SCHEMAP_INVALID_ATTR_COMBINATION = 1777
|
| 523 |
+
XML_SCHEMAP_INVALID_ATTR_INLINE_COMBINATION = 1778
|
| 524 |
+
XML_SCHEMAP_MISSING_SIMPLETYPE_CHILD = 1779
|
| 525 |
+
XML_SCHEMAP_INVALID_ATTR_NAME = 1780
|
| 526 |
+
XML_SCHEMAP_REF_AND_CONTENT = 1781
|
| 527 |
+
XML_SCHEMAP_CT_PROPS_CORRECT_1 = 1782
|
| 528 |
+
XML_SCHEMAP_CT_PROPS_CORRECT_2 = 1783
|
| 529 |
+
XML_SCHEMAP_CT_PROPS_CORRECT_3 = 1784
|
| 530 |
+
XML_SCHEMAP_CT_PROPS_CORRECT_4 = 1785
|
| 531 |
+
XML_SCHEMAP_CT_PROPS_CORRECT_5 = 1786
|
| 532 |
+
XML_SCHEMAP_DERIVATION_OK_RESTRICTION_1 = 1787
|
| 533 |
+
XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_1 = 1788
|
| 534 |
+
XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_2 = 1789
|
| 535 |
+
XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_2 = 1790
|
| 536 |
+
XML_SCHEMAP_DERIVATION_OK_RESTRICTION_3 = 1791
|
| 537 |
+
XML_SCHEMAP_WILDCARD_INVALID_NS_MEMBER = 1792
|
| 538 |
+
XML_SCHEMAP_INTERSECTION_NOT_EXPRESSIBLE = 1793
|
| 539 |
+
XML_SCHEMAP_UNION_NOT_EXPRESSIBLE = 1794
|
| 540 |
+
XML_SCHEMAP_SRC_IMPORT_3_1 = 1795
|
| 541 |
+
XML_SCHEMAP_SRC_IMPORT_3_2 = 1796
|
| 542 |
+
XML_SCHEMAP_DERIVATION_OK_RESTRICTION_4_1 = 1797
|
| 543 |
+
XML_SCHEMAP_DERIVATION_OK_RESTRICTION_4_2 = 1798
|
| 544 |
+
XML_SCHEMAP_DERIVATION_OK_RESTRICTION_4_3 = 1799
|
| 545 |
+
XML_SCHEMAP_COS_CT_EXTENDS_1_3 = 1800
|
| 546 |
+
XML_SCHEMAV_NOROOT = 1801
|
| 547 |
+
XML_SCHEMAV_UNDECLAREDELEM = 1802
|
| 548 |
+
XML_SCHEMAV_NOTTOPLEVEL = 1803
|
| 549 |
+
XML_SCHEMAV_MISSING = 1804
|
| 550 |
+
XML_SCHEMAV_WRONGELEM = 1805
|
| 551 |
+
XML_SCHEMAV_NOTYPE = 1806
|
| 552 |
+
XML_SCHEMAV_NOROLLBACK = 1807
|
| 553 |
+
XML_SCHEMAV_ISABSTRACT = 1808
|
| 554 |
+
XML_SCHEMAV_NOTEMPTY = 1809
|
| 555 |
+
XML_SCHEMAV_ELEMCONT = 1810
|
| 556 |
+
XML_SCHEMAV_HAVEDEFAULT = 1811
|
| 557 |
+
XML_SCHEMAV_NOTNILLABLE = 1812
|
| 558 |
+
XML_SCHEMAV_EXTRACONTENT = 1813
|
| 559 |
+
XML_SCHEMAV_INVALIDATTR = 1814
|
| 560 |
+
XML_SCHEMAV_INVALIDELEM = 1815
|
| 561 |
+
XML_SCHEMAV_NOTDETERMINIST = 1816
|
| 562 |
+
XML_SCHEMAV_CONSTRUCT = 1817
|
| 563 |
+
XML_SCHEMAV_INTERNAL = 1818
|
| 564 |
+
XML_SCHEMAV_NOTSIMPLE = 1819
|
| 565 |
+
XML_SCHEMAV_ATTRUNKNOWN = 1820
|
| 566 |
+
XML_SCHEMAV_ATTRINVALID = 1821
|
| 567 |
+
XML_SCHEMAV_VALUE = 1822
|
| 568 |
+
XML_SCHEMAV_FACET = 1823
|
| 569 |
+
XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_1 = 1824
|
| 570 |
+
XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_2 = 1825
|
| 571 |
+
XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_3 = 1826
|
| 572 |
+
XML_SCHEMAV_CVC_TYPE_3_1_1 = 1827
|
| 573 |
+
XML_SCHEMAV_CVC_TYPE_3_1_2 = 1828
|
| 574 |
+
XML_SCHEMAV_CVC_FACET_VALID = 1829
|
| 575 |
+
XML_SCHEMAV_CVC_LENGTH_VALID = 1830
|
| 576 |
+
XML_SCHEMAV_CVC_MINLENGTH_VALID = 1831
|
| 577 |
+
XML_SCHEMAV_CVC_MAXLENGTH_VALID = 1832
|
| 578 |
+
XML_SCHEMAV_CVC_MININCLUSIVE_VALID = 1833
|
| 579 |
+
XML_SCHEMAV_CVC_MAXINCLUSIVE_VALID = 1834
|
| 580 |
+
XML_SCHEMAV_CVC_MINEXCLUSIVE_VALID = 1835
|
| 581 |
+
XML_SCHEMAV_CVC_MAXEXCLUSIVE_VALID = 1836
|
| 582 |
+
XML_SCHEMAV_CVC_TOTALDIGITS_VALID = 1837
|
| 583 |
+
XML_SCHEMAV_CVC_FRACTIONDIGITS_VALID = 1838
|
| 584 |
+
XML_SCHEMAV_CVC_PATTERN_VALID = 1839
|
| 585 |
+
XML_SCHEMAV_CVC_ENUMERATION_VALID = 1840
|
| 586 |
+
XML_SCHEMAV_CVC_COMPLEX_TYPE_2_1 = 1841
|
| 587 |
+
XML_SCHEMAV_CVC_COMPLEX_TYPE_2_2 = 1842
|
| 588 |
+
XML_SCHEMAV_CVC_COMPLEX_TYPE_2_3 = 1843
|
| 589 |
+
XML_SCHEMAV_CVC_COMPLEX_TYPE_2_4 = 1844
|
| 590 |
+
XML_SCHEMAV_CVC_ELT_1 = 1845
|
| 591 |
+
XML_SCHEMAV_CVC_ELT_2 = 1846
|
| 592 |
+
XML_SCHEMAV_CVC_ELT_3_1 = 1847
|
| 593 |
+
XML_SCHEMAV_CVC_ELT_3_2_1 = 1848
|
| 594 |
+
XML_SCHEMAV_CVC_ELT_3_2_2 = 1849
|
| 595 |
+
XML_SCHEMAV_CVC_ELT_4_1 = 1850
|
| 596 |
+
XML_SCHEMAV_CVC_ELT_4_2 = 1851
|
| 597 |
+
XML_SCHEMAV_CVC_ELT_4_3 = 1852
|
| 598 |
+
XML_SCHEMAV_CVC_ELT_5_1_1 = 1853
|
| 599 |
+
XML_SCHEMAV_CVC_ELT_5_1_2 = 1854
|
| 600 |
+
XML_SCHEMAV_CVC_ELT_5_2_1 = 1855
|
| 601 |
+
XML_SCHEMAV_CVC_ELT_5_2_2_1 = 1856
|
| 602 |
+
XML_SCHEMAV_CVC_ELT_5_2_2_2_1 = 1857
|
| 603 |
+
XML_SCHEMAV_CVC_ELT_5_2_2_2_2 = 1858
|
| 604 |
+
XML_SCHEMAV_CVC_ELT_6 = 1859
|
| 605 |
+
XML_SCHEMAV_CVC_ELT_7 = 1860
|
| 606 |
+
XML_SCHEMAV_CVC_ATTRIBUTE_1 = 1861
|
| 607 |
+
XML_SCHEMAV_CVC_ATTRIBUTE_2 = 1862
|
| 608 |
+
XML_SCHEMAV_CVC_ATTRIBUTE_3 = 1863
|
| 609 |
+
XML_SCHEMAV_CVC_ATTRIBUTE_4 = 1864
|
| 610 |
+
XML_SCHEMAV_CVC_COMPLEX_TYPE_3_1 = 1865
|
| 611 |
+
XML_SCHEMAV_CVC_COMPLEX_TYPE_3_2_1 = 1866
|
| 612 |
+
XML_SCHEMAV_CVC_COMPLEX_TYPE_3_2_2 = 1867
|
| 613 |
+
XML_SCHEMAV_CVC_COMPLEX_TYPE_4 = 1868
|
| 614 |
+
XML_SCHEMAV_CVC_COMPLEX_TYPE_5_1 = 1869
|
| 615 |
+
XML_SCHEMAV_CVC_COMPLEX_TYPE_5_2 = 1870
|
| 616 |
+
XML_SCHEMAV_ELEMENT_CONTENT = 1871
|
| 617 |
+
XML_SCHEMAV_DOCUMENT_ELEMENT_MISSING = 1872
|
| 618 |
+
XML_SCHEMAV_CVC_COMPLEX_TYPE_1 = 1873
|
| 619 |
+
XML_SCHEMAV_CVC_AU = 1874
|
| 620 |
+
XML_SCHEMAV_CVC_TYPE_1 = 1875
|
| 621 |
+
XML_SCHEMAV_CVC_TYPE_2 = 1876
|
| 622 |
+
XML_SCHEMAV_CVC_IDC = 1877
|
| 623 |
+
XML_SCHEMAV_CVC_WILDCARD = 1878
|
| 624 |
+
XML_SCHEMAV_MISC = 1879
|
| 625 |
+
XML_XPTR_UNKNOWN_SCHEME = 1900
|
| 626 |
+
XML_XPTR_CHILDSEQ_START = 1901
|
| 627 |
+
XML_XPTR_EVAL_FAILED = 1902
|
| 628 |
+
XML_XPTR_EXTRA_OBJECTS = 1903
|
| 629 |
+
XML_C14N_CREATE_CTXT = 1950
|
| 630 |
+
XML_C14N_REQUIRES_UTF8 = 1951
|
| 631 |
+
XML_C14N_CREATE_STACK = 1952
|
| 632 |
+
XML_C14N_INVALID_NODE = 1953
|
| 633 |
+
XML_C14N_UNKNOW_NODE = 1954
|
| 634 |
+
XML_C14N_RELATIVE_NAMESPACE = 1955
|
| 635 |
+
XML_FTP_PASV_ANSWER = 2000
|
| 636 |
+
XML_FTP_EPSV_ANSWER = 2001
|
| 637 |
+
XML_FTP_ACCNT = 2002
|
| 638 |
+
XML_FTP_URL_SYNTAX = 2003
|
| 639 |
+
XML_HTTP_URL_SYNTAX = 2020
|
| 640 |
+
XML_HTTP_USE_IP = 2021
|
| 641 |
+
XML_HTTP_UNKNOWN_HOST = 2022
|
| 642 |
+
XML_SCHEMAP_SRC_SIMPLE_TYPE_1 = 3000
|
| 643 |
+
XML_SCHEMAP_SRC_SIMPLE_TYPE_2 = 3001
|
| 644 |
+
XML_SCHEMAP_SRC_SIMPLE_TYPE_3 = 3002
|
| 645 |
+
XML_SCHEMAP_SRC_SIMPLE_TYPE_4 = 3003
|
| 646 |
+
XML_SCHEMAP_SRC_RESOLVE = 3004
|
| 647 |
+
XML_SCHEMAP_SRC_RESTRICTION_BASE_OR_SIMPLETYPE = 3005
|
| 648 |
+
XML_SCHEMAP_SRC_LIST_ITEMTYPE_OR_SIMPLETYPE = 3006
|
| 649 |
+
XML_SCHEMAP_SRC_UNION_MEMBERTYPES_OR_SIMPLETYPES = 3007
|
| 650 |
+
XML_SCHEMAP_ST_PROPS_CORRECT_1 = 3008
|
| 651 |
+
XML_SCHEMAP_ST_PROPS_CORRECT_2 = 3009
|
| 652 |
+
XML_SCHEMAP_ST_PROPS_CORRECT_3 = 3010
|
| 653 |
+
XML_SCHEMAP_COS_ST_RESTRICTS_1_1 = 3011
|
| 654 |
+
XML_SCHEMAP_COS_ST_RESTRICTS_1_2 = 3012
|
| 655 |
+
XML_SCHEMAP_COS_ST_RESTRICTS_1_3_1 = 3013
|
| 656 |
+
XML_SCHEMAP_COS_ST_RESTRICTS_1_3_2 = 3014
|
| 657 |
+
XML_SCHEMAP_COS_ST_RESTRICTS_2_1 = 3015
|
| 658 |
+
XML_SCHEMAP_COS_ST_RESTRICTS_2_3_1_1 = 3016
|
| 659 |
+
XML_SCHEMAP_COS_ST_RESTRICTS_2_3_1_2 = 3017
|
| 660 |
+
XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_1 = 3018
|
| 661 |
+
XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_2 = 3019
|
| 662 |
+
XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_3 = 3020
|
| 663 |
+
XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_4 = 3021
|
| 664 |
+
XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_5 = 3022
|
| 665 |
+
XML_SCHEMAP_COS_ST_RESTRICTS_3_1 = 3023
|
| 666 |
+
XML_SCHEMAP_COS_ST_RESTRICTS_3_3_1 = 3024
|
| 667 |
+
XML_SCHEMAP_COS_ST_RESTRICTS_3_3_1_2 = 3025
|
| 668 |
+
XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_2 = 3026
|
| 669 |
+
XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_1 = 3027
|
| 670 |
+
XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_3 = 3028
|
| 671 |
+
XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_4 = 3029
|
| 672 |
+
XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_5 = 3030
|
| 673 |
+
XML_SCHEMAP_COS_ST_DERIVED_OK_2_1 = 3031
|
| 674 |
+
XML_SCHEMAP_COS_ST_DERIVED_OK_2_2 = 3032
|
| 675 |
+
XML_SCHEMAP_S4S_ELEM_NOT_ALLOWED = 3033
|
| 676 |
+
XML_SCHEMAP_S4S_ELEM_MISSING = 3034
|
| 677 |
+
XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED = 3035
|
| 678 |
+
XML_SCHEMAP_S4S_ATTR_MISSING = 3036
|
| 679 |
+
XML_SCHEMAP_S4S_ATTR_INVALID_VALUE = 3037
|
| 680 |
+
XML_SCHEMAP_SRC_ELEMENT_1 = 3038
|
| 681 |
+
XML_SCHEMAP_SRC_ELEMENT_2_1 = 3039
|
| 682 |
+
XML_SCHEMAP_SRC_ELEMENT_2_2 = 3040
|
| 683 |
+
XML_SCHEMAP_SRC_ELEMENT_3 = 3041
|
| 684 |
+
XML_SCHEMAP_P_PROPS_CORRECT_1 = 3042
|
| 685 |
+
XML_SCHEMAP_P_PROPS_CORRECT_2_1 = 3043
|
| 686 |
+
XML_SCHEMAP_P_PROPS_CORRECT_2_2 = 3044
|
| 687 |
+
XML_SCHEMAP_E_PROPS_CORRECT_2 = 3045
|
| 688 |
+
XML_SCHEMAP_E_PROPS_CORRECT_3 = 3046
|
| 689 |
+
XML_SCHEMAP_E_PROPS_CORRECT_4 = 3047
|
| 690 |
+
XML_SCHEMAP_E_PROPS_CORRECT_5 = 3048
|
| 691 |
+
XML_SCHEMAP_E_PROPS_CORRECT_6 = 3049
|
| 692 |
+
XML_SCHEMAP_SRC_INCLUDE = 3050
|
| 693 |
+
XML_SCHEMAP_SRC_ATTRIBUTE_1 = 3051
|
| 694 |
+
XML_SCHEMAP_SRC_ATTRIBUTE_2 = 3052
|
| 695 |
+
XML_SCHEMAP_SRC_ATTRIBUTE_3_1 = 3053
|
| 696 |
+
XML_SCHEMAP_SRC_ATTRIBUTE_3_2 = 3054
|
| 697 |
+
XML_SCHEMAP_SRC_ATTRIBUTE_4 = 3055
|
| 698 |
+
XML_SCHEMAP_NO_XMLNS = 3056
|
| 699 |
+
XML_SCHEMAP_NO_XSI = 3057
|
| 700 |
+
XML_SCHEMAP_COS_VALID_DEFAULT_1 = 3058
|
| 701 |
+
XML_SCHEMAP_COS_VALID_DEFAULT_2_1 = 3059
|
| 702 |
+
XML_SCHEMAP_COS_VALID_DEFAULT_2_2_1 = 3060
|
| 703 |
+
XML_SCHEMAP_COS_VALID_DEFAULT_2_2_2 = 3061
|
| 704 |
+
XML_SCHEMAP_CVC_SIMPLE_TYPE = 3062
|
| 705 |
+
XML_SCHEMAP_COS_CT_EXTENDS_1_1 = 3063
|
| 706 |
+
XML_SCHEMAP_SRC_IMPORT_1_1 = 3064
|
| 707 |
+
XML_SCHEMAP_SRC_IMPORT_1_2 = 3065
|
| 708 |
+
XML_SCHEMAP_SRC_IMPORT_2 = 3066
|
| 709 |
+
XML_SCHEMAP_SRC_IMPORT_2_1 = 3067
|
| 710 |
+
XML_SCHEMAP_SRC_IMPORT_2_2 = 3068
|
| 711 |
+
XML_SCHEMAP_INTERNAL = 3069 # 3069 non-W3C
|
| 712 |
+
XML_SCHEMAP_NOT_DETERMINISTIC = 3070 # 3070 non-W3C
|
| 713 |
+
XML_SCHEMAP_SRC_ATTRIBUTE_GROUP_1 = 3071
|
| 714 |
+
XML_SCHEMAP_SRC_ATTRIBUTE_GROUP_2 = 3072
|
| 715 |
+
XML_SCHEMAP_SRC_ATTRIBUTE_GROUP_3 = 3073
|
| 716 |
+
XML_SCHEMAP_MG_PROPS_CORRECT_1 = 3074
|
| 717 |
+
XML_SCHEMAP_MG_PROPS_CORRECT_2 = 3075
|
| 718 |
+
XML_SCHEMAP_SRC_CT_1 = 3076
|
| 719 |
+
XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_3 = 3077
|
| 720 |
+
XML_SCHEMAP_AU_PROPS_CORRECT_2 = 3078
|
| 721 |
+
XML_SCHEMAP_A_PROPS_CORRECT_2 = 3079
|
| 722 |
+
XML_SCHEMAP_C_PROPS_CORRECT = 3080
|
| 723 |
+
XML_SCHEMAP_SRC_REDEFINE = 3081
|
| 724 |
+
XML_SCHEMAP_SRC_IMPORT = 3082
|
| 725 |
+
XML_SCHEMAP_WARN_SKIP_SCHEMA = 3083
|
| 726 |
+
XML_SCHEMAP_WARN_UNLOCATED_SCHEMA = 3084
|
| 727 |
+
XML_SCHEMAP_WARN_ATTR_REDECL_PROH = 3085
|
| 728 |
+
XML_SCHEMAP_WARN_ATTR_POINTLESS_PROH = 3086 # 3085
|
| 729 |
+
XML_SCHEMAP_AG_PROPS_CORRECT = 3087 # 3086
|
| 730 |
+
XML_SCHEMAP_COS_CT_EXTENDS_1_2 = 3088 # 3087
|
| 731 |
+
XML_SCHEMAP_AU_PROPS_CORRECT = 3089 # 3088
|
| 732 |
+
XML_SCHEMAP_A_PROPS_CORRECT_3 = 3090 # 3089
|
| 733 |
+
XML_SCHEMAP_COS_ALL_LIMITED = 3091 # 3090
|
| 734 |
+
XML_SCHEMATRONV_ASSERT = 4000
|
| 735 |
+
XML_SCHEMATRONV_REPORT = 4001
|
| 736 |
+
XML_MODULE_OPEN = 4900
|
| 737 |
+
XML_MODULE_CLOSE = 4901
|
| 738 |
+
XML_CHECK_FOUND_ELEMENT = 5000
|
| 739 |
+
XML_CHECK_FOUND_ATTRIBUTE = 5001
|
| 740 |
+
XML_CHECK_FOUND_TEXT = 5002
|
| 741 |
+
XML_CHECK_FOUND_CDATA = 5003
|
| 742 |
+
XML_CHECK_FOUND_ENTITYREF = 5004
|
| 743 |
+
XML_CHECK_FOUND_ENTITY = 5005
|
| 744 |
+
XML_CHECK_FOUND_PI = 5006
|
| 745 |
+
XML_CHECK_FOUND_COMMENT = 5007
|
| 746 |
+
XML_CHECK_FOUND_DOCTYPE = 5008
|
| 747 |
+
XML_CHECK_FOUND_FRAGMENT = 5009
|
| 748 |
+
XML_CHECK_FOUND_NOTATION = 5010
|
| 749 |
+
XML_CHECK_UNKNOWN_NODE = 5011
|
| 750 |
+
XML_CHECK_ENTITY_TYPE = 5012
|
| 751 |
+
XML_CHECK_NO_PARENT = 5013
|
| 752 |
+
XML_CHECK_NO_DOC = 5014
|
| 753 |
+
XML_CHECK_NO_NAME = 5015
|
| 754 |
+
XML_CHECK_NO_ELEM = 5016
|
| 755 |
+
XML_CHECK_WRONG_DOC = 5017
|
| 756 |
+
XML_CHECK_NO_PREV = 5018
|
| 757 |
+
XML_CHECK_WRONG_PREV = 5019
|
| 758 |
+
XML_CHECK_NO_NEXT = 5020
|
| 759 |
+
XML_CHECK_WRONG_NEXT = 5021
|
| 760 |
+
XML_CHECK_NOT_DTD = 5022
|
| 761 |
+
XML_CHECK_NOT_ATTR = 5023
|
| 762 |
+
XML_CHECK_NOT_ATTR_DECL = 5024
|
| 763 |
+
XML_CHECK_NOT_ELEM_DECL = 5025
|
| 764 |
+
XML_CHECK_NOT_ENTITY_DECL = 5026
|
| 765 |
+
XML_CHECK_NOT_NS_DECL = 5027
|
| 766 |
+
XML_CHECK_NO_HREF = 5028
|
| 767 |
+
XML_CHECK_WRONG_PARENT = 5029
|
| 768 |
+
XML_CHECK_NS_SCOPE = 5030
|
| 769 |
+
XML_CHECK_NS_ANCESTOR = 5031
|
| 770 |
+
XML_CHECK_NOT_UTF8 = 5032
|
| 771 |
+
XML_CHECK_NO_DICT = 5033
|
| 772 |
+
XML_CHECK_NOT_NCNAME = 5034
|
| 773 |
+
XML_CHECK_OUTSIDE_DICT = 5035
|
| 774 |
+
XML_CHECK_WRONG_NAME = 5036
|
| 775 |
+
XML_CHECK_NAME_NOT_NULL = 5037
|
| 776 |
+
XML_I18N_NO_NAME = 6000
|
| 777 |
+
XML_I18N_NO_HANDLER = 6001
|
| 778 |
+
XML_I18N_EXCESS_HANDLER = 6002
|
| 779 |
+
XML_I18N_CONV_FAILED = 6003
|
| 780 |
+
XML_I18N_NO_OUTPUT = 6004
|
| 781 |
+
XML_BUF_OVERFLOW = 7000
|
| 782 |
+
|
| 783 |
+
ctypedef enum xmlRelaxNGValidErr:
|
| 784 |
+
XML_RELAXNG_OK = 0
|
| 785 |
+
XML_RELAXNG_ERR_MEMORY = 1
|
| 786 |
+
XML_RELAXNG_ERR_TYPE = 2
|
| 787 |
+
XML_RELAXNG_ERR_TYPEVAL = 3
|
| 788 |
+
XML_RELAXNG_ERR_DUPID = 4
|
| 789 |
+
XML_RELAXNG_ERR_TYPECMP = 5
|
| 790 |
+
XML_RELAXNG_ERR_NOSTATE = 6
|
| 791 |
+
XML_RELAXNG_ERR_NODEFINE = 7
|
| 792 |
+
XML_RELAXNG_ERR_LISTEXTRA = 8
|
| 793 |
+
XML_RELAXNG_ERR_LISTEMPTY = 9
|
| 794 |
+
XML_RELAXNG_ERR_INTERNODATA = 10
|
| 795 |
+
XML_RELAXNG_ERR_INTERSEQ = 11
|
| 796 |
+
XML_RELAXNG_ERR_INTEREXTRA = 12
|
| 797 |
+
XML_RELAXNG_ERR_ELEMNAME = 13
|
| 798 |
+
XML_RELAXNG_ERR_ATTRNAME = 14
|
| 799 |
+
XML_RELAXNG_ERR_ELEMNONS = 15
|
| 800 |
+
XML_RELAXNG_ERR_ATTRNONS = 16
|
| 801 |
+
XML_RELAXNG_ERR_ELEMWRONGNS = 17
|
| 802 |
+
XML_RELAXNG_ERR_ATTRWRONGNS = 18
|
| 803 |
+
XML_RELAXNG_ERR_ELEMEXTRANS = 19
|
| 804 |
+
XML_RELAXNG_ERR_ATTREXTRANS = 20
|
| 805 |
+
XML_RELAXNG_ERR_ELEMNOTEMPTY = 21
|
| 806 |
+
XML_RELAXNG_ERR_NOELEM = 22
|
| 807 |
+
XML_RELAXNG_ERR_NOTELEM = 23
|
| 808 |
+
XML_RELAXNG_ERR_ATTRVALID = 24
|
| 809 |
+
XML_RELAXNG_ERR_CONTENTVALID = 25
|
| 810 |
+
XML_RELAXNG_ERR_EXTRACONTENT = 26
|
| 811 |
+
XML_RELAXNG_ERR_INVALIDATTR = 27
|
| 812 |
+
XML_RELAXNG_ERR_DATAELEM = 28
|
| 813 |
+
XML_RELAXNG_ERR_VALELEM = 29
|
| 814 |
+
XML_RELAXNG_ERR_LISTELEM = 30
|
| 815 |
+
XML_RELAXNG_ERR_DATATYPE = 31
|
| 816 |
+
XML_RELAXNG_ERR_VALUE = 32
|
| 817 |
+
XML_RELAXNG_ERR_LIST = 33
|
| 818 |
+
XML_RELAXNG_ERR_NOGRAMMAR = 34
|
| 819 |
+
XML_RELAXNG_ERR_EXTRADATA = 35
|
| 820 |
+
XML_RELAXNG_ERR_LACKDATA = 36
|
| 821 |
+
XML_RELAXNG_ERR_INTERNAL = 37
|
| 822 |
+
XML_RELAXNG_ERR_ELEMWRONG = 38
|
| 823 |
+
XML_RELAXNG_ERR_TEXTWRONG = 39
|
| 824 |
+
# --- END: GENERATED CONSTANTS ---
|
| 825 |
+
|
| 826 |
+
cdef extern from "libxml/xmlerror.h" nogil:
|
| 827 |
+
ctypedef struct xmlError:
|
| 828 |
+
int domain
|
| 829 |
+
int code
|
| 830 |
+
char* message
|
| 831 |
+
xmlErrorLevel level
|
| 832 |
+
char* file
|
| 833 |
+
char* str1
|
| 834 |
+
char* str2
|
| 835 |
+
char* str3
|
| 836 |
+
int line
|
| 837 |
+
int int1
|
| 838 |
+
int int2
|
| 839 |
+
void* node
|
| 840 |
+
|
| 841 |
+
ctypedef void (*xmlGenericErrorFunc)(void* ctxt, char* msg, ...) noexcept
|
| 842 |
+
ctypedef void (*xmlStructuredErrorFunc)(void* userData,
|
| 843 |
+
const xmlError* error) noexcept
|
| 844 |
+
|
| 845 |
+
cdef void xmlSetGenericErrorFunc(
|
| 846 |
+
void* ctxt, xmlGenericErrorFunc func)
|
| 847 |
+
cdef void xmlSetStructuredErrorFunc(
|
| 848 |
+
void* ctxt, xmlStructuredErrorFunc func)
|
| 849 |
+
|
| 850 |
+
cdef extern from "libxml/globals.h" nogil:
|
| 851 |
+
cdef xmlStructuredErrorFunc xmlStructuredError
|
| 852 |
+
cdef void* xmlStructuredErrorContext
|