œ_#ÁÕ§TE NAŒ“KeÉ:”(åŽÖJÞùY’‚ñùž7; «]Û ý`8g“¯B© jdÖÖ¸ðzœ¸¦4Ç3Kó^(ÍÖ¼ Õ€pvìwšõB4df$Èü^0˜…åÌC$#2FŽÑ§±¦ÛZ/÷š&m£ñzÒÖ ’.Î]!Î;ƒ(Õ–¢d/—#Kª+tZyuÏB>NÛÖ†(¸ŒSà'³„Y˜´-_•¦¼´˜OlNK§¶ÒàŠˆTHµƒeTPå·fïM’…þuÏÍüp6دªE£åü‡ZØ'CKF#â«;‹eyO Qp„†l"ö1èíÙP ÏŒúl! BÝ2ñª•_VÁÉ÷3eu`–F¸ìI--ö<¿žë¯4õ캿¢)34Å{wMÉ2ÆÖFŸ¥`e9Ú¶¸P‡.”FÔï rY ‚²ÈTB,{ÛœéJ}«àQ4¹0Rû4D‚B§S‘ dO•v¾„™Sן¯3FeŸ™«+ÓâwH dÕÛÌì·P4ë&¥#rÜÉ Ù¦ê†ý·xòqk¯2,¹§™E\ék‚×Sá”ÚºÙ⺷ö£6…à ʾ qSá³Å|;àû}4Ÿ($â¹VY~óÍ!èÜÒŒËX½Ù1j‚VíÍŸš³+œ]«½g{_{/vµ½\¢¶vÉWKÿ:ñám½ ¥ S²x‘t ŽšÝÙÿÀÇ^ný PK IW™k‚½÷ á _rels/.relsUT dìd dìd dìd’ÏNÃ0‡ï{ŠÈ÷ÕÝ@¡¥» ¤Ý*`%îÑ&QâÁöö‚J£ì°cœŸ¿|¶²ÙÆA½rL½wVE Šñ¶w†çúay * 9Kƒw¬áÈ ¶ÕbóÄIîI]’Ê—4t"á1™ŽGJ…ìòMããH’±Å@æ…ZÆuYÞ`üÍ€jÂT;«!îì T}|Û7MoøÞ›ýÈNN<|v–í2ÄÜ¥ÏèšbË¢Ázó˜Ë )„"£OÏ7ú{ZYÈ’yÞç#1'tuÉM?6o>Z´_å9›ëKÚ˜}?þ³žÏÌ·N>fµx PK IWª½e ¢ U € word/document.xmlUT dìdPK IWþË3” z €J¢ word/settings.xmlUT dìdPK IWC‡{š' ƒ €¤ docProps/custom.xmlUT dìdPK IW츱=Œ €‡¥ [Content_Types].xmlUT dìdPK IWV%ë±" €U§ docProps/app.xmlUT dìdPK IW€RŒ 3 €¶¨ docProps/core.xmlUT dìdPK IWkòDn ô €ª word/_rels/document.xml.relsUT dìdPK IW;$î €Î« word/fontTable.xmlUT dìdPK IW+åäz] ÷. €ý¬ word/numbering.xmlUT dìdPK IW¤2×r- ¿ €›° word/styles.xmlUT dìdPK IWMFÒ ø €´ word/header1.xmlUT dìdPK IWF— T e €· word/media/image1.jpegUT dìdPK IW!Yéáå €°Ë word/media/image2.pngUT dìdPK IW°Àºë ú €ÙÌ word/media/image3.pngUT dìdPK IW$“†ª L €Î word/footer1.xmlUT dìdPK IWzaGôM €ñÑ word/footer2.xmlUT dìdPK IW–µâº P €}Õ word/theme/theme1.xmlUT dìdPK IW™k‚½÷ á €{Û _rels/.relsUT PK ! bîh^ [Content_Types].xml ¢( ¬”ËNÃ0E÷HüCä-Jܲ@5í‚Ç*Q>Àēƪc[žiiÿž‰ûB¡j7±ÏÜ{2ñÍh²nm¶‚ˆÆ»R‹ÈÀU^7/ÅÇì%¿’rZYï @1__f› ˜q·ÃR4DáAJ¬h>€ãÚÇV߯¹ªZ¨9ÈÛÁàNVÞ8Ê©ÓãÑÔji){^óã-I‹"{Üv^¥P!XS)bR¹rú—K¾s(¸3Õ`cÞ0†½ÝÎß»¾7M4²©ŠôªZÆk+¿|\|z¿(Ž‹ôPúº6h_-[ž@!‚ÒØ Pk‹´2nÏ}Ä?£LËð Ýû%áÄßdºždN"m,à¥ÇžDO97*‚~§Èɸ8ÀOíc|n¦Ñ äEøÿöéºóÀBÉÀ!$}‡íàÈé;{ìÐå[ƒîñ–é2þ ÿÿ PK ! µU0#ô L _rels/.rels ¢( ¬’MOÃ0†ïHü‡È÷ÕÝBKwAH»!T~€Iܵ£$Ý¿'TƒG½~üÊÛÝ<êÈ!öâ4¬‹;#¶w†—úqu *&r–Fq¬áÄvÕõÕö™GJy(v½*«¸¨¡KÉß#FÓñD±Ï.W ¥†=™ZÆMYÞbø®ÕBS톰·7 ê“Ï›×–¦é ?ˆ9LìÒ™ÈsbgÙ®|Èl!õùUSh9i°bžr:"y_dlÀóD›¿ý|-NœÈR"4ø2ÏGÇ% õZ´4ñËyÄ7 ëÈðÉ‚‹¨Þ ÿÿ PK ! Q48wÛ — xl/workbook.xml¤UÙnâ0}iþ!cñ‡ *–¢AšVU×$dC¬&vÆv UÕŸë@XÊK§/¹p|Žï¹N÷b“¥Ö •Š ÞC¸î"‹òHÄŒ¯zèá~b·‘¥4á1I§=ôJºèÿüÑ] ù¼âÙ ®z(Ñ:GE ͈ª‹œrˆ,…̈†©\9*—”Ä*¡Tg©ã¹nàd„q´Eåg0ÄrÉ":Q‘Q®· ’¦D}•°\UhYô¸ŒÈç"·#‘å ±`)Ó¯%(²²(œ®¸d‘‚ì nZ w v¡ñª• t¶TÆ")”Xê:@;[Ògú±ë`|²›ó=ø’ïHúÂL÷¬dðEVÁ+8€a÷Ûh¬Uz%„Íû"ZsÏÍCýî’¥ôqk]‹äù5ÉL¦Rd¥Dé˘i÷P ¦bM/|dÉ",…¨çãFNoçiûéë>aêiçsó#ðÄ ÕTr¢éHp ÜIú®ÝJìQ"ÀÜÖ-ý[0I¡¦ÀZ Z…d¡nˆN¬B¦=4 g %PDF-1.4 %âãÏÓ 3 0 obj << /Linearized 1 /L 422775 ÿØÿà JFIF ÿÛ C ÿÛ C ÿÀ X" ÿÄ ÿÄ H !1A"Qaq2‘¡#±ÁBRÑ3Cbrá$S‚¢²ð4ñ%6DTc’ÂsÿÄ ÿÄ = !1AQ"aq‘Á2R¡±BÑð#3br’²4á$‚¢ÂñÿÚ ? áHBßÝ`„! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! ! stream
# support for XMLSchema validation
from lxml.includes cimport xmlschema
cdef class XMLSchemaError(LxmlError):
"""Base class of all XML Schema errors
"""
cdef class XMLSchemaParseError(XMLSchemaError):
"""Error while parsing an XML document as XML Schema.
"""
cdef class XMLSchemaValidateError(XMLSchemaError):
"""Error while validating an XML document with an XML Schema.
"""
################################################################################
# XMLSchema
cdef XPath _check_for_default_attributes = XPath(
u"boolean(//xs:attribute[@default or @fixed][1])",
namespaces={u'xs': u'http://www.w3.org/2001/XMLSchema'})
cdef class XMLSchema(_Validator):
u"""XMLSchema(self, etree=None, file=None)
Turn a document into an XML Schema validator.
Either pass a schema as Element or ElementTree, or pass a file or
filename through the ``file`` keyword argument.
Passing the ``attribute_defaults`` boolean option will make the
schema insert default/fixed attributes into validated documents.
"""
cdef xmlschema.xmlSchema* _c_schema
cdef _Document _doc
cdef bint _has_default_attributes
cdef bint _add_attribute_defaults
def __cinit__(self):
self._has_default_attributes = True # play it safe
self._add_attribute_defaults = False
def __init__(self, etree=None, *, file=None, bint attribute_defaults=False):
cdef xmlschema.xmlSchemaParserCtxt* parser_ctxt
cdef xmlDoc* c_doc
self._add_attribute_defaults = attribute_defaults
_Validator.__init__(self)
c_doc = NULL
if etree is not None:
doc = _documentOrRaise(etree)
root_node = _rootNodeOrRaise(etree)
c_doc = _copyDocRoot(doc._c_doc, root_node._c_node)
self._doc = _documentFactory(c_doc, doc._parser)
parser_ctxt = xmlschema.xmlSchemaNewDocParserCtxt(c_doc)
elif file is not None:
file = _getFSPathOrObject(file)
if _isString(file):
filename = _encodeFilename(file)
parser_ctxt = xmlschema.xmlSchemaNewParserCtxt(_cstr(filename))
else:
self._doc = _parseDocument(file, None, None)
parser_ctxt = xmlschema.xmlSchemaNewDocParserCtxt(self._doc._c_doc)
else:
raise XMLSchemaParseError, u"No tree or file given"
if parser_ctxt is NULL:
raise MemoryError()
xmlschema.xmlSchemaSetParserStructuredErrors(
parser_ctxt, _receiveError, <void*>self._error_log)
if self._doc is not None:
# calling xmlSchemaParse on a schema with imports or
# includes will cause libxml2 to create an internal
# context for parsing, so push an implied context to route
# resolve requests to the document's parser
__GLOBAL_PARSER_CONTEXT.pushImpliedContextFromParser(self._doc._parser)
with nogil:
orig_loader = _register_document_loader()
self._c_schema = xmlschema.xmlSchemaParse(parser_ctxt)
_reset_document_loader(orig_loader)
if self._doc is not None:
__GLOBAL_PARSER_CONTEXT.popImpliedContext()
xmlschema.xmlSchemaFreeParserCtxt(parser_ctxt)
if self._c_schema is NULL:
raise XMLSchemaParseError(
self._error_log._buildExceptionMessage(
u"Document is not valid XML Schema"),
self._error_log)
if self._doc is not None:
self._has_default_attributes = _check_for_default_attributes(self._doc)
self._add_attribute_defaults = attribute_defaults and self._has_default_attributes
def __dealloc__(self):
xmlschema.xmlSchemaFree(self._c_schema)
def __call__(self, etree):
u"""__call__(self, etree)
Validate doc using XML Schema.
Returns true if document is valid, false if not.
"""
cdef xmlschema.xmlSchemaValidCtxt* valid_ctxt
cdef _Document doc
cdef _Element root_node
cdef xmlDoc* c_doc
cdef int ret
assert self._c_schema is not NULL, "Schema instance not initialised"
doc = _documentOrRaise(etree)
root_node = _rootNodeOrRaise(etree)
valid_ctxt = xmlschema.xmlSchemaNewValidCtxt(self._c_schema)
if valid_ctxt is NULL:
raise MemoryError()
try:
if self._add_attribute_defaults:
xmlschema.xmlSchemaSetValidOptions(
valid_ctxt, xmlschema.XML_SCHEMA_VAL_VC_I_CREATE)
self._error_log.clear()
xmlschema.xmlSchemaSetValidStructuredErrors(
valid_ctxt, _receiveError, <void*>self._error_log)
c_doc = _fakeRootDoc(doc._c_doc, root_node._c_node)
with nogil:
ret = xmlschema.xmlSchemaValidateDoc(valid_ctxt, c_doc)
_destroyFakeDoc(doc._c_doc, c_doc)
finally:
xmlschema.xmlSchemaFreeValidCtxt(valid_ctxt)
if ret == -1:
raise XMLSchemaValidateError(
u"Internal error in XML Schema validation.",
self._error_log)
if ret == 0:
return True
else:
return False
cdef _ParserSchemaValidationContext _newSaxValidator(
self, bint add_default_attributes):
cdef _ParserSchemaValidationContext context
context = _ParserSchemaValidationContext.__new__(_ParserSchemaValidationContext)
context._schema = self
context._add_default_attributes = (self._has_default_attributes and (
add_default_attributes or self._add_attribute_defaults))
return context
@cython.final
@cython.internal
cdef class _ParserSchemaValidationContext:
cdef XMLSchema _schema
cdef xmlschema.xmlSchemaValidCtxt* _valid_ctxt
cdef xmlschema.xmlSchemaSAXPlugStruct* _sax_plug
cdef bint _add_default_attributes
def __cinit__(self):
self._valid_ctxt = NULL
self._sax_plug = NULL
self._add_default_attributes = False
def __dealloc__(self):
self.disconnect()
if self._valid_ctxt:
xmlschema.xmlSchemaFreeValidCtxt(self._valid_ctxt)
cdef _ParserSchemaValidationContext copy(self):
assert self._schema is not None, "_ParserSchemaValidationContext not initialised"
return self._schema._newSaxValidator(
self._add_default_attributes)
cdef void inject_default_attributes(self, xmlDoc* c_doc):
# we currently need to insert default attributes manually
# after parsing, as libxml2 does not support this at parse
# time
if self._add_default_attributes:
with nogil:
xmlschema.xmlSchemaValidateDoc(self._valid_ctxt, c_doc)
cdef int connect(self, xmlparser.xmlParserCtxt* c_ctxt, _BaseErrorLog error_log) except -1:
if self._valid_ctxt is NULL:
self._valid_ctxt = xmlschema.xmlSchemaNewValidCtxt(
self._schema._c_schema)
if self._valid_ctxt is NULL:
raise MemoryError()
if self._add_default_attributes:
xmlschema.xmlSchemaSetValidOptions(
self._valid_ctxt, xmlschema.XML_SCHEMA_VAL_VC_I_CREATE)
if error_log is not None:
xmlschema.xmlSchemaSetValidStructuredErrors(
self._valid_ctxt, _receiveError, <void*>error_log)
self._sax_plug = xmlschema.xmlSchemaSAXPlug(
self._valid_ctxt, &c_ctxt.sax, &c_ctxt.userData)
cdef void disconnect(self):
if self._sax_plug is not NULL:
xmlschema.xmlSchemaSAXUnplug(self._sax_plug)
self._sax_plug = NULL
if self._valid_ctxt is not NULL:
xmlschema.xmlSchemaSetValidStructuredErrors(
self._valid_ctxt, NULL, NULL)
cdef bint isvalid(self):
if self._valid_ctxt is NULL:
return 1 # valid
return xmlschema.xmlSchemaIsValid(self._valid_ctxt)