rebuild for 10.11+
This commit is contained in:
parent
d989eff547
commit
901b731582
234 changed files with 1522 additions and 927 deletions
BIN
lib/python3.7/site-packages/lxml/_elementpath.cpython-37m-darwin.so
Executable file → Normal file
BIN
lib/python3.7/site-packages/lxml/_elementpath.cpython-37m-darwin.so
Executable file → Normal file
Binary file not shown.
|
|
@ -1,3 +1,5 @@
|
|||
# cython: language_level=2
|
||||
|
||||
#
|
||||
# ElementTree
|
||||
# $Id: ElementPath.py 3375 2008-02-13 08:05:08Z fredrik $
|
||||
|
|
@ -53,6 +55,8 @@
|
|||
# you, if needed.
|
||||
##
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import re
|
||||
|
||||
xpath_tokenizer_re = re.compile(
|
||||
|
|
|
|||
BIN
lib/python3.7/site-packages/lxml/builder.cpython-37m-darwin.so
Executable file → Normal file
BIN
lib/python3.7/site-packages/lxml/builder.cpython-37m-darwin.so
Executable file → Normal file
Binary file not shown.
|
|
@ -1,3 +1,5 @@
|
|||
# cython: language_level=2
|
||||
|
||||
#
|
||||
# Element generator factory by Fredrik Lundh.
|
||||
#
|
||||
|
|
@ -37,6 +39,8 @@
|
|||
The ``E`` Element factory for generating XML documents.
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import lxml.etree as ET
|
||||
|
||||
from functools import partial
|
||||
|
|
|
|||
|
|
@ -209,13 +209,12 @@ class LXMLOutputChecker(OutputChecker):
|
|||
else:
|
||||
return value
|
||||
html = parser is html_fromstring
|
||||
diff_parts = []
|
||||
diff_parts.append('Expected:')
|
||||
diff_parts.append(self.format_doc(want_doc, html, 2))
|
||||
diff_parts.append('Got:')
|
||||
diff_parts.append(self.format_doc(got_doc, html, 2))
|
||||
diff_parts.append('Diff:')
|
||||
diff_parts.append(self.collect_diff(want_doc, got_doc, html, 2))
|
||||
diff_parts = ['Expected:',
|
||||
self.format_doc(want_doc, html, 2),
|
||||
'Got:',
|
||||
self.format_doc(got_doc, html, 2),
|
||||
'Diff:',
|
||||
self.collect_diff(want_doc, got_doc, html, 2)]
|
||||
return '\n'.join(diff_parts)
|
||||
|
||||
def html_empty_tag(self, el, html=True):
|
||||
|
|
|
|||
BIN
lib/python3.7/site-packages/lxml/etree.cpython-37m-darwin.so
Executable file → Normal file
BIN
lib/python3.7/site-packages/lxml/etree.cpython-37m-darwin.so
Executable file → Normal file
Binary file not shown.
|
|
@ -1,4 +1,4 @@
|
|||
/* Generated by Cython 0.28.5 */
|
||||
/* Generated by Cython 0.29.2 */
|
||||
|
||||
#ifndef __PYX_HAVE__lxml__etree
|
||||
#define __PYX_HAVE__lxml__etree
|
||||
|
|
@ -12,7 +12,7 @@ struct LxmlElementBase;
|
|||
struct LxmlElementClassLookup;
|
||||
struct LxmlFallbackElementClassLookup;
|
||||
|
||||
/* "lxml/etree.pyx":320
|
||||
/* "lxml/etree.pyx":318
|
||||
*
|
||||
* # type of a function that steps from node to node
|
||||
* ctypedef public xmlNode* (*_node_to_node_function)(xmlNode*) # <<<<<<<<<<<<<<
|
||||
|
|
@ -21,7 +21,7 @@ struct LxmlFallbackElementClassLookup;
|
|||
*/
|
||||
typedef xmlNode *(*_node_to_node_function)(xmlNode *);
|
||||
|
||||
/* "lxml/etree.pyx":336
|
||||
/* "lxml/etree.pyx":334
|
||||
* @cython.final
|
||||
* @cython.freelist(8)
|
||||
* cdef public class _Document [ type LxmlDocumentType, object LxmlDocument ]: # <<<<<<<<<<<<<<
|
||||
|
|
@ -37,7 +37,7 @@ struct LxmlDocument {
|
|||
struct __pyx_obj_4lxml_5etree__BaseParser *_parser;
|
||||
};
|
||||
|
||||
/* "lxml/etree.pyx":685
|
||||
/* "lxml/etree.pyx":683
|
||||
*
|
||||
* @cython.no_gc_clear
|
||||
* cdef public class _Element [ type LxmlElementType, object LxmlElement ]: # <<<<<<<<<<<<<<
|
||||
|
|
@ -51,7 +51,7 @@ struct LxmlElement {
|
|||
PyObject *_tag;
|
||||
};
|
||||
|
||||
/* "lxml/etree.pyx":1849
|
||||
/* "lxml/etree.pyx":1847
|
||||
*
|
||||
*
|
||||
* cdef public class _ElementTree [ type LxmlElementTreeType, # <<<<<<<<<<<<<<
|
||||
|
|
@ -65,7 +65,7 @@ struct LxmlElementTree {
|
|||
struct LxmlElement *_context_node;
|
||||
};
|
||||
|
||||
/* "lxml/etree.pyx":2576
|
||||
/* "lxml/etree.pyx":2574
|
||||
*
|
||||
*
|
||||
* cdef public class _ElementTagMatcher [ object LxmlElementTagMatcher, # <<<<<<<<<<<<<<
|
||||
|
|
@ -81,7 +81,7 @@ struct LxmlElementTagMatcher {
|
|||
char *_name;
|
||||
};
|
||||
|
||||
/* "lxml/etree.pyx":2607
|
||||
/* "lxml/etree.pyx":2605
|
||||
* self._name = NULL
|
||||
*
|
||||
* cdef public class _ElementIterator(_ElementTagMatcher) [ # <<<<<<<<<<<<<<
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
/* Generated by Cython 0.28.5 */
|
||||
/* Generated by Cython 0.29.2 */
|
||||
|
||||
#ifndef __PYX_HAVE_API__lxml__etree
|
||||
#define __PYX_HAVE_API__lxml__etree
|
||||
#ifdef __MINGW64__
|
||||
#define MS_WIN64
|
||||
#endif
|
||||
#include "Python.h"
|
||||
#include "etree.h"
|
||||
|
||||
|
|
@ -103,23 +106,6 @@ static xmlNs *(*__pyx_api_f_4lxml_5etree_findOrBuildNodeNsPrefix)(struct LxmlDoc
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef __PYX_HAVE_RT_ImportModule
|
||||
#define __PYX_HAVE_RT_ImportModule
|
||||
static PyObject *__Pyx_ImportModule(const char *name) {
|
||||
PyObject *py_name = 0;
|
||||
PyObject *py_module = 0;
|
||||
py_name = __Pyx_PyIdentifier_FromString(name);
|
||||
if (!py_name)
|
||||
goto bad;
|
||||
py_module = PyImport_Import(py_name);
|
||||
Py_DECREF(py_name);
|
||||
return py_module;
|
||||
bad:
|
||||
Py_XDECREF(py_name);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef __PYX_HAVE_RT_ImportFunction
|
||||
#define __PYX_HAVE_RT_ImportFunction
|
||||
static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
|
||||
|
|
@ -176,7 +162,7 @@ bad:
|
|||
|
||||
static int import_lxml__etree(void) {
|
||||
PyObject *module = 0;
|
||||
module = __Pyx_ImportModule("lxml.etree");
|
||||
module = PyImport_ImportModule("lxml.etree");
|
||||
if (!module) goto bad;
|
||||
if (__Pyx_ImportFunction(module, "deepcopyNodeToDocument", (void (**)(void))&__pyx_api_f_4lxml_5etree_deepcopyNodeToDocument, "struct LxmlElement *(struct LxmlDocument *, xmlNode *)") < 0) goto bad;
|
||||
if (__Pyx_ImportFunction(module, "elementTreeFactory", (void (**)(void))&__pyx_api_f_4lxml_5etree_elementTreeFactory, "struct LxmlElementTree *(struct LxmlElement *)") < 0) goto bad;
|
||||
|
|
|
|||
|
|
@ -46,7 +46,6 @@ import re
|
|||
from functools import partial
|
||||
|
||||
try:
|
||||
# while unnecessary, importing from 'collections.abc' is the right way to do it
|
||||
from collections.abc import MutableMapping, MutableSet
|
||||
except ImportError:
|
||||
from collections import MutableMapping, MutableSet
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
from collections import MutableSet
|
||||
try:
|
||||
from collections.abc import MutableSet
|
||||
except ImportError:
|
||||
from collections import MutableSet
|
||||
|
||||
|
||||
class SetMixin(MutableSet):
|
||||
|
||||
|
|
|
|||
BIN
lib/python3.7/site-packages/lxml/html/clean.cpython-37m-darwin.so
Executable file → Normal file
BIN
lib/python3.7/site-packages/lxml/html/clean.cpython-37m-darwin.so
Executable file → Normal file
Binary file not shown.
|
|
@ -1,9 +1,13 @@
|
|||
# cython: language_level=2
|
||||
|
||||
"""A cleanup tool for HTML.
|
||||
|
||||
Removes unwanted tags and content. See the `Cleaner` class for
|
||||
details.
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import re
|
||||
import copy
|
||||
try:
|
||||
|
|
@ -27,11 +31,6 @@ try:
|
|||
except NameError:
|
||||
# Python 3
|
||||
unicode = str
|
||||
try:
|
||||
bytes
|
||||
except NameError:
|
||||
# Python < 2.6
|
||||
bytes = str
|
||||
try:
|
||||
basestring
|
||||
except NameError:
|
||||
|
|
@ -213,7 +212,7 @@ class Cleaner(object):
|
|||
safe_attrs = defs.safe_attrs
|
||||
add_nofollow = False
|
||||
host_whitelist = ()
|
||||
whitelist_tags = set(['iframe', 'embed'])
|
||||
whitelist_tags = {'iframe', 'embed'}
|
||||
|
||||
def __init__(self, **kw):
|
||||
for name, value in kw.items():
|
||||
|
|
|
|||
BIN
lib/python3.7/site-packages/lxml/html/diff.cpython-37m-darwin.so
Executable file → Normal file
BIN
lib/python3.7/site-packages/lxml/html/diff.cpython-37m-darwin.so
Executable file → Normal file
Binary file not shown.
|
|
@ -1,3 +1,7 @@
|
|||
# cython: language_level=3
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import difflib
|
||||
from lxml import etree
|
||||
from lxml.html import fragment_fromstring
|
||||
|
|
@ -621,7 +625,7 @@ def fixup_chunks(chunks):
|
|||
% (cur_word, result, chunk, chunks))
|
||||
cur_word.post_tags.append(chunk)
|
||||
else:
|
||||
assert(0)
|
||||
assert False
|
||||
|
||||
if not result:
|
||||
return [token('', pre_tags=tag_accum)]
|
||||
|
|
@ -799,7 +803,6 @@ def _move_el_inside_block(el, tag):
|
|||
if _contains_block_level_tag(child):
|
||||
break
|
||||
else:
|
||||
import sys
|
||||
# No block-level tags in any child
|
||||
children_tag = etree.Element(tag)
|
||||
children_tag.text = el.text
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@
|
|||
#ifndef PY_VERSION_HEX
|
||||
# error the development package of Python (header files etc.) is not installed correctly
|
||||
#else
|
||||
# if PY_VERSION_HEX < 0x02060000 || PY_MAJOR_VERSION >= 3 && PY_VERSION_HEX < 0x03020000
|
||||
# error this version of lxml requires Python 2.6, 2.7, 3.2 or later
|
||||
# if PY_VERSION_HEX < 0x02070000 || PY_MAJOR_VERSION >= 3 && PY_VERSION_HEX < 0x03030000
|
||||
# error this version of lxml requires Python 2.7, 3.3 or later
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
|
@ -262,8 +262,6 @@ long _ftol2( double dblSource ) { return _ftol( dblSource ); }
|
|||
(((c_node)->ns == 0) ? 0 : ((c_node)->ns->href))
|
||||
|
||||
|
||||
/* PyCapsule was added in Py2.7 */
|
||||
#if PY_VERSION_HEX >= 0x02070000
|
||||
#include "string.h"
|
||||
static void* lxml_unpack_xmldoc_capsule(PyObject* capsule, int* is_owned) {
|
||||
xmlDoc *c_doc;
|
||||
|
|
@ -301,9 +299,6 @@ static void* lxml_unpack_xmldoc_capsule(PyObject* capsule, int* is_owned) {
|
|||
}
|
||||
return c_doc;
|
||||
}
|
||||
#else
|
||||
# define lxml_unpack_xmldoc_capsule(capsule, is_owned) ((((void)capsule, 0) || ((void)is_owned, 0)) ? NULL : NULL)
|
||||
#endif
|
||||
|
||||
/* Macro pair implementation of a depth first tree walker
|
||||
*
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
#include <libxml/xmlversion.h>
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/xmlerror.h>
|
||||
#include <libxml/SAX.h>
|
||||
#include <libxml/SAX2.h>
|
||||
#include <libxml/xmlmemory.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -575,7 +575,7 @@ struct _xmlDoc {
|
|||
void *ids; /* Hash table for ID attributes if any */
|
||||
void *refs; /* Hash table for IDREFs attributes if any */
|
||||
const xmlChar *URL; /* The URI for that document */
|
||||
int charset; /* encoding of the in-memory content
|
||||
int charset; /* Internal flag for charset handling,
|
||||
actually an xmlCharEncoding */
|
||||
struct _xmlDict *dict; /* dict used to allocate names or NULL */
|
||||
void *psvi; /* for type/PSVI informations */
|
||||
|
|
|
|||
|
|
@ -131,8 +131,8 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
/* Cygwin platform, GNU compiler */
|
||||
#if defined(_WIN32) && defined(__CYGWIN__)
|
||||
/* Cygwin platform (does not define _WIN32), GNU compiler */
|
||||
#if defined(__CYGWIN__)
|
||||
#undef XMLPUBFUN
|
||||
#undef XMLPUBVAR
|
||||
#undef XMLCALL
|
||||
|
|
@ -145,7 +145,7 @@
|
|||
#if !defined(LIBXML_STATIC)
|
||||
#define XMLPUBVAR __declspec(dllimport) extern
|
||||
#else
|
||||
#define XMLPUBVAR
|
||||
#define XMLPUBVAR extern
|
||||
#endif
|
||||
#endif
|
||||
#define XMLCALL __cdecl
|
||||
|
|
|
|||
|
|
@ -29,21 +29,21 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
|
|||
*
|
||||
* the version string like "1.2.3"
|
||||
*/
|
||||
#define LIBXML_DOTTED_VERSION "2.9.8"
|
||||
#define LIBXML_DOTTED_VERSION "2.9.9"
|
||||
|
||||
/**
|
||||
* LIBXML_VERSION:
|
||||
*
|
||||
* the version number: 1.2.3 value is 10203
|
||||
*/
|
||||
#define LIBXML_VERSION 20908
|
||||
#define LIBXML_VERSION 20909
|
||||
|
||||
/**
|
||||
* LIBXML_VERSION_STRING:
|
||||
*
|
||||
* the version number string, 1.2.3 value is "10203"
|
||||
*/
|
||||
#define LIBXML_VERSION_STRING "20908"
|
||||
#define LIBXML_VERSION_STRING "20909"
|
||||
|
||||
/**
|
||||
* LIBXML_VERSION_EXTRA:
|
||||
|
|
@ -58,7 +58,7 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
|
|||
* Macro to check that the libxml version in use is compatible with
|
||||
* the version the software has been compiled against
|
||||
*/
|
||||
#define LIBXML_TEST_VERSION xmlCheckVersion(20908);
|
||||
#define LIBXML_TEST_VERSION xmlCheckVersion(20909);
|
||||
|
||||
#ifndef VMS
|
||||
#if 0
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
#ifndef LXML_VERSION_STRING
|
||||
#define LXML_VERSION_STRING "4.2.5"
|
||||
#define LXML_VERSION_STRING "4.3.0"
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -63,8 +63,8 @@ svrl_validation_errors = _etree.XPath(
|
|||
|
||||
|
||||
# RelaxNG validator for schematron schemas
|
||||
schematron_schema_valid = _etree.RelaxNG(_etree.parse(
|
||||
os.path.join(_resources_dir, 'rng', 'iso-schematron.rng')))
|
||||
schematron_schema_valid = _etree.RelaxNG(
|
||||
file=os.path.join(_resources_dir, 'rng', 'iso-schematron.rng'))
|
||||
|
||||
|
||||
def stylesheet_params(**kwargs):
|
||||
|
|
|
|||
|
|
@ -1,9 +1,29 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Copyright © ISO/IEC 2015 -->
|
||||
<!--
|
||||
(c) International Organization for Standardization 2005.
|
||||
Permission to copy in any form is granted for use with conforming
|
||||
SGML systems and applications as defined in ISO 8879,
|
||||
provided this notice is included in all copies.
|
||||
The following permission notice and disclaimer shall be included in all
|
||||
copies of this XML schema ("the Schema"), and derivations of the Schema:
|
||||
|
||||
Permission is hereby granted, free of charge in perpetuity, to any
|
||||
person obtaining a copy of the Schema, to use, copy, modify, merge and
|
||||
distribute free of charge, copies of the Schema for the purposes of
|
||||
developing, implementing, installing and using software based on the
|
||||
Schema, and to permit persons to whom the Schema is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
THE SCHEMA IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SCHEMA OR THE USE OR
|
||||
OTHER DEALINGS IN THE SCHEMA.
|
||||
|
||||
In addition, any modified copy of the Schema shall include the following
|
||||
notice:
|
||||
|
||||
"THIS SCHEMA HAS BEEN MODIFIED FROM THE SCHEMA DEFINED IN ISO/IEC 19757-3,
|
||||
AND SHOULD NOT BE INTERPRETED AS COMPLYING WITH THAT STANDARD".
|
||||
-->
|
||||
<grammar ns="http://purl.oclc.org/dsdl/schematron" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
|
||||
<start>
|
||||
|
|
@ -63,6 +83,10 @@
|
|||
<optional>
|
||||
<ref name="diagnostics"/>
|
||||
</optional>
|
||||
<optional>
|
||||
<!-- edited (lxml): required in standard, optional here (since it can be empty anyway) -->
|
||||
<ref name="properties"/>
|
||||
</optional>
|
||||
</group>
|
||||
</interleave>
|
||||
</element>
|
||||
|
|
@ -105,6 +129,11 @@
|
|||
<data type="IDREFS"/>
|
||||
</attribute>
|
||||
</optional>
|
||||
<optional>
|
||||
<attribute name="properties">
|
||||
<data type="IDREFS"/>
|
||||
</attribute>
|
||||
</optional>
|
||||
<ref name="rich"/>
|
||||
<ref name="linkable"/>
|
||||
<interleave>
|
||||
|
|
@ -178,9 +207,14 @@
|
|||
</define>
|
||||
<define name="extends">
|
||||
<element name="extends">
|
||||
<attribute name="rule">
|
||||
<data type="IDREF"/>
|
||||
</attribute>
|
||||
<choice>
|
||||
<attribute name="rule">
|
||||
<data type="IDREF"/>
|
||||
</attribute>
|
||||
<attribute name="href">
|
||||
<ref name="uriValue"/>
|
||||
</attribute>
|
||||
</choice>
|
||||
<ref name="foreign-empty"/>
|
||||
</element>
|
||||
</define>
|
||||
|
|
@ -189,9 +223,14 @@
|
|||
<attribute name="name">
|
||||
<ref name="nameValue"/>
|
||||
</attribute>
|
||||
<attribute name="value">
|
||||
<data type="string" datatypeLibrary=""/>
|
||||
</attribute>
|
||||
<choice>
|
||||
<attribute name="value">
|
||||
<data type="string" datatypeLibrary=""/>
|
||||
</attribute>
|
||||
<oneOrMore>
|
||||
<ref name="foreign-element"/>
|
||||
</oneOrMore>
|
||||
</choice>
|
||||
</element>
|
||||
</define>
|
||||
<define name="name">
|
||||
|
|
@ -257,6 +296,11 @@
|
|||
</define>
|
||||
<define name="pattern">
|
||||
<element name="pattern">
|
||||
<optional>
|
||||
<attribute name="documents">
|
||||
<ref name="pathValue"/>
|
||||
</attribute>
|
||||
</optional>
|
||||
<ref name="rich"/>
|
||||
<interleave>
|
||||
<ref name="foreign"/>
|
||||
|
|
@ -367,6 +411,41 @@
|
|||
</interleave>
|
||||
</element>
|
||||
</define>
|
||||
<define name="properties">
|
||||
<element name="properties">
|
||||
<zeroOrMore>
|
||||
<ref name="property"/>
|
||||
</zeroOrMore>
|
||||
</element>
|
||||
</define>
|
||||
<define name="property">
|
||||
<element name="property">
|
||||
<attribute name="id">
|
||||
<data type="ID"/>
|
||||
</attribute>
|
||||
<optional>
|
||||
<attribute name="role">
|
||||
<ref name="roleValue"/>
|
||||
</attribute>
|
||||
</optional>
|
||||
<optional>
|
||||
<attribute name="scheme"/>
|
||||
</optional>
|
||||
<interleave>
|
||||
<ref name="foreign"/>
|
||||
<zeroOrMore>
|
||||
<choice>
|
||||
<text/>
|
||||
<ref name="name"/>
|
||||
<ref name="value-of"/>
|
||||
<ref name="emph"/>
|
||||
<ref name="dir"/>
|
||||
<ref name="span"/>
|
||||
</choice>
|
||||
</zeroOrMore>
|
||||
</interleave>
|
||||
</element>
|
||||
</define>
|
||||
<define name="report">
|
||||
<element name="report">
|
||||
<attribute name="test">
|
||||
|
|
@ -387,6 +466,11 @@
|
|||
<data type="IDREFS"/>
|
||||
</attribute>
|
||||
</optional>
|
||||
<optional>
|
||||
<attribute name="properties">
|
||||
<data type="IDREFS"/>
|
||||
</attribute>
|
||||
</optional>
|
||||
<ref name="rich"/>
|
||||
<ref name="linkable"/>
|
||||
<interleave>
|
||||
|
|
@ -434,6 +518,7 @@
|
|||
<ref name="assert"/>
|
||||
<ref name="report"/>
|
||||
<ref name="extends"/>
|
||||
<ref name="p"/>
|
||||
</choice>
|
||||
</oneOrMore>
|
||||
</group>
|
||||
|
|
@ -459,6 +544,7 @@
|
|||
<ref name="assert"/>
|
||||
<ref name="report"/>
|
||||
<ref name="extends"/>
|
||||
<ref name="p"/>
|
||||
</choice>
|
||||
</oneOrMore>
|
||||
</group>
|
||||
|
|
@ -501,6 +587,7 @@
|
|||
<attribute name="href">
|
||||
<ref name="uriValue"/>
|
||||
</attribute>
|
||||
<ref name="foreign-empty"/>
|
||||
</element>
|
||||
</define>
|
||||
<define name="rich">
|
||||
|
|
|
|||
|
|
@ -6,10 +6,11 @@
|
|||
This is a preprocessor for ISO Schematron, which implements abstract patterns.
|
||||
It also
|
||||
* extracts a particular schema using an ID, where there are multiple
|
||||
schemas, such as when they are embedded in the same NVDL script
|
||||
* experimentally, allows parameter recognition and substitution inside
|
||||
text as well as @context, @test, & @select.
|
||||
|
||||
schemas, such as when they are embedded in the same NVDL script
|
||||
* allows parameter substitution inside @context, @test, @select, @path
|
||||
* experimentally, allows parameter recognition and substitution inside
|
||||
text (NOTE: to be removed, for compataibility with other implementations,
|
||||
please do not use this)
|
||||
|
||||
This should be used after iso-dsdl-include.xsl and before the skeleton or
|
||||
meta-stylesheet (e.g. iso-svrl.xsl) . It only requires XSLT 1.
|
||||
|
|
@ -17,8 +18,45 @@
|
|||
Each kind of inclusion can be turned off (or on) on the command line.
|
||||
|
||||
-->
|
||||
<!--
|
||||
VERSION INFORMATION
|
||||
|
||||
<!--
|
||||
Open Source Initiative OSI - The MIT License:Licensing
|
||||
[OSI Approved License]
|
||||
|
||||
This source code was previously available under the zlib/libpng license.
|
||||
Attribution is polite.
|
||||
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2004-2010 Rick Jellife and Academia Sinica Computing Centre, Taiwan
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
-->
|
||||
|
||||
<!--
|
||||
VERSION INFORMATION
|
||||
2013-09-19 RJ
|
||||
* Allow macro expansion in @path attributes, eg. for sch:name/@path
|
||||
|
||||
2010-07-10 RJ
|
||||
* Move to MIT license
|
||||
|
||||
2008-09-18 RJ
|
||||
* move out param test from iso:schema template to work with XSLT 1. (Noah Fontes)
|
||||
|
||||
|
|
@ -40,35 +78,11 @@
|
|||
* Original written for old namespace
|
||||
* http://www.topologi.com/resources/iso-pre-pro.xsl
|
||||
-->
|
||||
<!--
|
||||
LEGAL INFORMATION
|
||||
|
||||
Copyright (c) 2000-2008 Rick Jelliffe and Academia Sinica Computing Center, Taiwan
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from
|
||||
the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim
|
||||
that you wrote the original software. If you use this software in a product,
|
||||
an acknowledgment in the product documentation would be appreciated but is
|
||||
not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
-->
|
||||
<xslt:stylesheet version="1.0" xmlns:xslt="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:iso="http://purl.oclc.org/dsdl/schematron"
|
||||
xmlns:nvdl="http://purl.oclc.org/dsdl/nvdl"
|
||||
|
||||
|
||||
xmlns:iae="http://www.schematron.com/namespace/iae"
|
||||
|
||||
>
|
||||
|
|
@ -231,7 +245,7 @@
|
|||
<xslt:template mode="iae:do-pattern" match="*">
|
||||
<xslt:param name="caller"/>
|
||||
<xslt:copy>
|
||||
<xslt:for-each select="@*[name()='test' or name()='context' or name()='select']">
|
||||
<xslt:for-each select="@*[name()='test' or name()='context' or name()='select' or name()='path' ]">
|
||||
<xslt:attribute name="{name()}">
|
||||
<xslt:call-template name="iae:macro-expand">
|
||||
<xslt:with-param name="text"><xslt:value-of select="."/></xslt:with-param>
|
||||
|
|
@ -239,12 +253,13 @@
|
|||
</xslt:call-template>
|
||||
</xslt:attribute>
|
||||
</xslt:for-each>
|
||||
<xslt:copy-of select="@*[name()!='test'][name()!='context'][name()!='select']" />
|
||||
<xslt:copy-of select="@*[name()!='test'][name()!='context'][name()!='select'][name()!='path']" />
|
||||
<xsl:for-each select="node()">
|
||||
<xsl:choose>
|
||||
<!-- Experiment: replace macros in text as well, to allow parameterized assertions
|
||||
and so on, without having to have spurious <iso:value-of> calls and multiple
|
||||
delimiting -->
|
||||
delimiting.
|
||||
NOTE: THIS FUNCTIONALITY WILL BE REMOVED IN THE FUTURE -->
|
||||
<xsl:when test="self::text()">
|
||||
<xslt:call-template name="iae:macro-expand">
|
||||
<xslt:with-param name="text"><xslt:value-of select="."/></xslt:with-param>
|
||||
|
|
@ -293,4 +308,6 @@
|
|||
</xsl:choose>
|
||||
</xslt:template>
|
||||
|
||||
|
||||
|
||||
</xslt:stylesheet>
|
||||
|
|
@ -1,83 +1,84 @@
|
|||
ISO SCHEMATRON 2009
|
||||
|
||||
XSLT implementation by Rick Jelliffe with assistance from members of Schematron-love-in maillist.
|
||||
|
||||
2009-03-18
|
||||
|
||||
Two distributions are available. One is for XSLT1 engines.
|
||||
The other is for XSLT2 engines, such as SAXON 9.
|
||||
|
||||
|
||||
This version of Schematron splits the process into a pipeline of several different XSLT stages.
|
||||
|
||||
1) First, preprocess your Schematron schema with iso_dsdl_include.xsl.
|
||||
This is a macro processor to assemble the schema from various parts.
|
||||
If your schema is not in separate parts, you can skip this stage.
|
||||
|
||||
2) Second, preprocess the output from stage 1 with iso_abstract_expand.xsl.
|
||||
This is a macro processor to convert abstract patterns to real patterns.
|
||||
If your schema does not use abstract patterns, you can skip this
|
||||
stage.
|
||||
|
||||
3) Third, compile the Schematron schema into an XSLT script.
|
||||
This will typically use iso_svrl_for_xslt1.xsl or iso_svrl_for_xslt2.xsl
|
||||
(which in turn invoke iso_schematron_skeleton_for_xslt1.xsl or iso_schematron_skeleton_for_saxon.xsl)
|
||||
However, other "meta-styleseets" are also in common use; the principle of operation is the same.
|
||||
If your schema uses Schematron phases, supply these as command line/invocation parameters
|
||||
to this process.
|
||||
|
||||
4) Fourth, run the script generated by stage 3 against the document being validated.
|
||||
If you are using the SVRL script, then the output of validation will be an XML document.
|
||||
If your schema uses Schematron parameters, supply these as command line/invocation parameters
|
||||
to this process.
|
||||
|
||||
|
||||
The XSLT2 distribution also features several next generation features,
|
||||
such as validating multiple documents. See the source code for details.
|
||||
|
||||
Schematron assertions can be written in any language, of course; the file
|
||||
sch-messages-en.xhtml contains the diagnostics messages from the XSLT2 skeleton
|
||||
in English, and this can be used as template to localize the skeleton's
|
||||
error messages. Note that typically programming errors in Schematron are XPath
|
||||
errors, which requires localized messages from the XSLT engine.
|
||||
|
||||
ANT
|
||||
---
|
||||
To give an example of how to process a document, here is a sample ANT task.
|
||||
|
||||
<target name="schematron-compile-test" >
|
||||
|
||||
<!-- expand inclusions -->
|
||||
<xslt basedir="test/schematron"
|
||||
style="iso_dsdl_include.xsl" in="test.sch" out="test1.sch">
|
||||
<classpath>
|
||||
<pathelement location="${lib.dir}/saxon9.jar"/>
|
||||
</classpath>
|
||||
</xslt>
|
||||
|
||||
<!-- expand abstract patterns -->
|
||||
<xslt basedir="test/schematron"
|
||||
style="iso_abstract_expand.xsl" in="test1.sch" out="test2.sch">
|
||||
<classpath>
|
||||
<pathelement location="${lib.dir}/saxon9.jar"/>
|
||||
</classpath>
|
||||
</xslt>
|
||||
|
||||
|
||||
|
||||
<!-- compile it -->
|
||||
<xslt basedir="test/schematron"
|
||||
style="iso_svrl_for_xslt2.xsl" in="test2.sch" out="test.xsl">
|
||||
<classpath>
|
||||
<pathelement location="${lib.dir}/saxon9.jar"/>
|
||||
</classpath>
|
||||
</xslt>
|
||||
|
||||
<!-- validate -->
|
||||
<xslt basedir="test/schematron"
|
||||
style="test.xsl" in="instance.xml" out="instance.svrlt">
|
||||
<classpath>
|
||||
<pathelement location="${lib.dir}/saxon9.jar"/>
|
||||
</classpath>
|
||||
</xslt>
|
||||
</target>
|
||||
ISO SCHEMATRON 2010
|
||||
|
||||
XSLT implementation by Rick Jelliffe with assistance from members of Schematron-love-in maillist.
|
||||
|
||||
2010-04-21
|
||||
|
||||
Two distributions are available. One is for XSLT1 engines.
|
||||
The other is for XSLT2 engines, such as SAXON 9.
|
||||
|
||||
|
||||
This version of Schematron splits the process into a pipeline of several different XSLT stages.
|
||||
|
||||
1) First, preprocess your Schematron schema with iso_dsdl_include.xsl.
|
||||
This is a macro processor to assemble the schema from various parts.
|
||||
If your schema is not in separate parts, you can skip this stage.
|
||||
This stage also generates error messages for some common XPath syntax problems.
|
||||
|
||||
2) Second, preprocess the output from stage 1 with iso_abstract_expand.xsl.
|
||||
This is a macro processor to convert abstract patterns to real patterns.
|
||||
If your schema does not use abstract patterns, you can skip this
|
||||
stage.
|
||||
|
||||
3) Third, compile the Schematron schema into an XSLT script.
|
||||
This will typically use iso_svrl_for_xslt1.xsl or iso_svrl_for_xslt2.xsl
|
||||
(which in turn invoke iso_schematron_skeleton_for_xslt1.xsl or iso_schematron_skeleton_for_saxon.xsl)
|
||||
However, other "meta-stylesheets" are also in common use; the principle of operation is the same.
|
||||
If your schema uses Schematron phases, supply these as command line/invocation parameters
|
||||
to this process.
|
||||
|
||||
4) Fourth, run the script generated by stage 3 against the document being validated.
|
||||
If you are using the SVRL script, then the output of validation will be an XML document.
|
||||
If your schema uses Schematron parameters, supply these as command line/invocation parameters
|
||||
to this process.
|
||||
|
||||
|
||||
The XSLT2 distribution also features several next generation features,
|
||||
such as validating multiple documents. See the source code for details.
|
||||
|
||||
Schematron assertions can be written in any language, of course; the file
|
||||
sch-messages-en.xhtml contains the diagnostics messages from the XSLT2 skeleton
|
||||
in English, and this can be used as template to localize the skeleton's
|
||||
error messages. Note that typically programming errors in Schematron are XPath
|
||||
errors, which requires localized messages from the XSLT engine.
|
||||
|
||||
ANT
|
||||
---
|
||||
To give an example of how to process a document, here is a sample ANT task.
|
||||
|
||||
<target name="schematron-compile-test" >
|
||||
|
||||
<!-- expand inclusions -->
|
||||
<xslt basedir="test/schematron"
|
||||
style="iso_dsdl_include.xsl" in="test.sch" out="test1.sch">
|
||||
<classpath>
|
||||
<pathelement location="${lib.dir}/saxon9.jar"/>
|
||||
</classpath>
|
||||
</xslt>
|
||||
|
||||
<!-- expand abstract patterns -->
|
||||
<xslt basedir="test/schematron"
|
||||
style="iso_abstract_expand.xsl" in="test1.sch" out="test2.sch">
|
||||
<classpath>
|
||||
<pathelement location="${lib.dir}/saxon9.jar"/>
|
||||
</classpath>
|
||||
</xslt>
|
||||
|
||||
|
||||
|
||||
<!-- compile it -->
|
||||
<xslt basedir="test/schematron"
|
||||
style="iso_svrl_for_xslt2.xsl" in="test2.sch" out="test.xsl">
|
||||
<classpath>
|
||||
<pathelement location="${lib.dir}/saxon9.jar"/>
|
||||
</classpath>
|
||||
</xslt>
|
||||
|
||||
<!-- validate -->
|
||||
<xslt basedir="test/schematron"
|
||||
style="test.xsl" in="instance.xml" out="instance.svrlt">
|
||||
<classpath>
|
||||
<pathelement location="${lib.dir}/saxon9.jar"/>
|
||||
</classpath>
|
||||
</xslt>
|
||||
</target>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Generated by Cython 0.28.5 */
|
||||
/* Generated by Cython 0.29.2 */
|
||||
|
||||
#ifndef __PYX_HAVE__lxml__etree
|
||||
#define __PYX_HAVE__lxml__etree
|
||||
|
|
@ -12,7 +12,7 @@ struct LxmlElementBase;
|
|||
struct LxmlElementClassLookup;
|
||||
struct LxmlFallbackElementClassLookup;
|
||||
|
||||
/* "lxml/etree.pyx":320
|
||||
/* "lxml/etree.pyx":318
|
||||
*
|
||||
* # type of a function that steps from node to node
|
||||
* ctypedef public xmlNode* (*_node_to_node_function)(xmlNode*) # <<<<<<<<<<<<<<
|
||||
|
|
@ -21,7 +21,7 @@ struct LxmlFallbackElementClassLookup;
|
|||
*/
|
||||
typedef xmlNode *(*_node_to_node_function)(xmlNode *);
|
||||
|
||||
/* "lxml/etree.pyx":336
|
||||
/* "lxml/etree.pyx":334
|
||||
* @cython.final
|
||||
* @cython.freelist(8)
|
||||
* cdef public class _Document [ type LxmlDocumentType, object LxmlDocument ]: # <<<<<<<<<<<<<<
|
||||
|
|
@ -37,7 +37,7 @@ struct LxmlDocument {
|
|||
struct __pyx_obj_4lxml_5etree__BaseParser *_parser;
|
||||
};
|
||||
|
||||
/* "lxml/etree.pyx":685
|
||||
/* "lxml/etree.pyx":683
|
||||
*
|
||||
* @cython.no_gc_clear
|
||||
* cdef public class _Element [ type LxmlElementType, object LxmlElement ]: # <<<<<<<<<<<<<<
|
||||
|
|
@ -51,7 +51,7 @@ struct LxmlElement {
|
|||
PyObject *_tag;
|
||||
};
|
||||
|
||||
/* "lxml/etree.pyx":1849
|
||||
/* "lxml/etree.pyx":1847
|
||||
*
|
||||
*
|
||||
* cdef public class _ElementTree [ type LxmlElementTreeType, # <<<<<<<<<<<<<<
|
||||
|
|
@ -65,7 +65,7 @@ struct LxmlElementTree {
|
|||
struct LxmlElement *_context_node;
|
||||
};
|
||||
|
||||
/* "lxml/etree.pyx":2576
|
||||
/* "lxml/etree.pyx":2574
|
||||
*
|
||||
*
|
||||
* cdef public class _ElementTagMatcher [ object LxmlElementTagMatcher, # <<<<<<<<<<<<<<
|
||||
|
|
@ -81,7 +81,7 @@ struct LxmlElementTagMatcher {
|
|||
char *_name;
|
||||
};
|
||||
|
||||
/* "lxml/etree.pyx":2607
|
||||
/* "lxml/etree.pyx":2605
|
||||
* self._name = NULL
|
||||
*
|
||||
* cdef public class _ElementIterator(_ElementTagMatcher) [ # <<<<<<<<<<<<<<
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
/* Generated by Cython 0.28.5 */
|
||||
/* Generated by Cython 0.29.2 */
|
||||
|
||||
#ifndef __PYX_HAVE_API__lxml__etree
|
||||
#define __PYX_HAVE_API__lxml__etree
|
||||
#ifdef __MINGW64__
|
||||
#define MS_WIN64
|
||||
#endif
|
||||
#include "Python.h"
|
||||
#include "lxml.etree.h"
|
||||
|
||||
|
|
@ -103,23 +106,6 @@ static xmlNs *(*__pyx_api_f_4lxml_5etree_findOrBuildNodeNsPrefix)(struct LxmlDoc
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef __PYX_HAVE_RT_ImportModule
|
||||
#define __PYX_HAVE_RT_ImportModule
|
||||
static PyObject *__Pyx_ImportModule(const char *name) {
|
||||
PyObject *py_name = 0;
|
||||
PyObject *py_module = 0;
|
||||
py_name = __Pyx_PyIdentifier_FromString(name);
|
||||
if (!py_name)
|
||||
goto bad;
|
||||
py_module = PyImport_Import(py_name);
|
||||
Py_DECREF(py_name);
|
||||
return py_module;
|
||||
bad:
|
||||
Py_XDECREF(py_name);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef __PYX_HAVE_RT_ImportFunction
|
||||
#define __PYX_HAVE_RT_ImportFunction
|
||||
static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
|
||||
|
|
@ -176,7 +162,7 @@ bad:
|
|||
|
||||
static int import_lxml__etree(void) {
|
||||
PyObject *module = 0;
|
||||
module = __Pyx_ImportModule("lxml.etree");
|
||||
module = PyImport_ImportModule("lxml.etree");
|
||||
if (!module) goto bad;
|
||||
if (__Pyx_ImportFunction(module, "deepcopyNodeToDocument", (void (**)(void))&__pyx_api_f_4lxml_5etree_deepcopyNodeToDocument, "struct LxmlElement *(struct LxmlDocument *, xmlNode *)") < 0) goto bad;
|
||||
if (__Pyx_ImportFunction(module, "elementTreeFactory", (void (**)(void))&__pyx_api_f_4lxml_5etree_elementTreeFactory, "struct LxmlElementTree *(struct LxmlElement *)") < 0) goto bad;
|
||||
|
|
|
|||
BIN
lib/python3.7/site-packages/lxml/objectify.cpython-37m-darwin.so
Executable file → Normal file
BIN
lib/python3.7/site-packages/lxml/objectify.cpython-37m-darwin.so
Executable file → Normal file
Binary file not shown.
BIN
lib/python3.7/site-packages/lxml/sax.cpython-37m-darwin.so
Normal file
BIN
lib/python3.7/site-packages/lxml/sax.cpython-37m-darwin.so
Normal file
Binary file not shown.
|
|
@ -1,3 +1,5 @@
|
|||
# cython: language_level=2
|
||||
|
||||
"""
|
||||
SAX-based adapter to copy trees from/to the Python standard library.
|
||||
|
||||
|
|
@ -10,6 +12,8 @@ the SAX events of an ElementTree against a SAX ContentHandler.
|
|||
See http://codespeak.net/lxml/sax.html
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
from xml.sax.handler import ContentHandler
|
||||
from lxml import etree
|
||||
from lxml.etree import ElementTree, SubElement
|
||||
|
|
@ -25,7 +29,7 @@ def _getNsTag(tag):
|
|||
if tag[0] == '{':
|
||||
return tuple(tag[1:].split('}', 1))
|
||||
else:
|
||||
return (None, tag)
|
||||
return None, tag
|
||||
|
||||
|
||||
class ElementTreeContentHandler(ContentHandler):
|
||||
|
|
@ -189,19 +193,26 @@ class ElementTreeProducer(object):
|
|||
|
||||
self._content_handler.endDocument()
|
||||
|
||||
def _recursive_saxify(self, element, prefixes):
|
||||
def _recursive_saxify(self, element, parent_nsmap):
|
||||
content_handler = self._content_handler
|
||||
tag = element.tag
|
||||
if tag is Comment or tag is ProcessingInstruction:
|
||||
if tag is ProcessingInstruction:
|
||||
content_handler.processingInstruction(
|
||||
element.target, element.text)
|
||||
if element.tail:
|
||||
content_handler.characters(element.tail)
|
||||
tail = element.tail
|
||||
if tail:
|
||||
content_handler.characters(tail)
|
||||
return
|
||||
|
||||
element_nsmap = element.nsmap
|
||||
new_prefixes = []
|
||||
build_qname = self._build_qname
|
||||
if element_nsmap != parent_nsmap:
|
||||
# There have been updates to the namespace
|
||||
for prefix, ns_uri in element_nsmap.items():
|
||||
if parent_nsmap.get(prefix) != ns_uri:
|
||||
new_prefixes.append( (prefix, ns_uri) )
|
||||
|
||||
attribs = element.items()
|
||||
if attribs:
|
||||
attr_values = {}
|
||||
|
|
@ -209,39 +220,57 @@ class ElementTreeProducer(object):
|
|||
for attr_ns_name, value in attribs:
|
||||
attr_ns_tuple = _getNsTag(attr_ns_name)
|
||||
attr_values[attr_ns_tuple] = value
|
||||
attr_qnames[attr_ns_tuple] = build_qname(
|
||||
attr_ns_tuple[0], attr_ns_tuple[1], prefixes, new_prefixes)
|
||||
attr_qnames[attr_ns_tuple] = self._build_qname(
|
||||
attr_ns_tuple[0], attr_ns_tuple[1], element_nsmap,
|
||||
preferred_prefix=None, is_attribute=True)
|
||||
sax_attributes = self._attr_class(attr_values, attr_qnames)
|
||||
else:
|
||||
sax_attributes = self._empty_attributes
|
||||
|
||||
ns_uri, local_name = _getNsTag(tag)
|
||||
qname = build_qname(ns_uri, local_name, prefixes, new_prefixes)
|
||||
qname = self._build_qname(
|
||||
ns_uri, local_name, element_nsmap, element.prefix, is_attribute=False)
|
||||
|
||||
for prefix, uri in new_prefixes:
|
||||
content_handler.startPrefixMapping(prefix, uri)
|
||||
content_handler.startElementNS((ns_uri, local_name),
|
||||
qname, sax_attributes)
|
||||
if element.text:
|
||||
content_handler.characters(element.text)
|
||||
content_handler.startElementNS(
|
||||
(ns_uri, local_name), qname, sax_attributes)
|
||||
text = element.text
|
||||
if text:
|
||||
content_handler.characters(text)
|
||||
for child in element:
|
||||
self._recursive_saxify(child, prefixes)
|
||||
self._recursive_saxify(child, element_nsmap)
|
||||
content_handler.endElementNS((ns_uri, local_name), qname)
|
||||
for prefix, uri in new_prefixes:
|
||||
content_handler.endPrefixMapping(prefix)
|
||||
if element.tail:
|
||||
content_handler.characters(element.tail)
|
||||
tail = element.tail
|
||||
if tail:
|
||||
content_handler.characters(tail)
|
||||
|
||||
def _build_qname(self, ns_uri, local_name, prefixes, new_prefixes):
|
||||
def _build_qname(self, ns_uri, local_name, nsmap, preferred_prefix, is_attribute):
|
||||
if ns_uri is None:
|
||||
return local_name
|
||||
try:
|
||||
prefix = prefixes[ns_uri]
|
||||
except KeyError:
|
||||
prefix = prefixes[ns_uri] = 'ns%02d' % len(prefixes)
|
||||
new_prefixes.append( (prefix, ns_uri) )
|
||||
|
||||
if not is_attribute and nsmap.get(preferred_prefix) == ns_uri:
|
||||
prefix = preferred_prefix
|
||||
else:
|
||||
# Pick the first matching prefix, in alphabetical order.
|
||||
candidates = [
|
||||
pfx for (pfx, uri) in nsmap.items()
|
||||
if pfx is not None and uri == ns_uri
|
||||
]
|
||||
prefix = (
|
||||
candidates[0] if len(candidates) == 1
|
||||
else min(candidates) if candidates
|
||||
else None
|
||||
)
|
||||
|
||||
if prefix is None:
|
||||
# Default namespace
|
||||
return local_name
|
||||
return prefix + ':' + local_name
|
||||
|
||||
|
||||
def saxify(element_or_tree, content_handler):
|
||||
"""One-shot helper to generate SAX events from an XML tree and fire
|
||||
them against a SAX ContentHandler.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue