Module libxml2
[hide private]
[frames] | no frames]

Source Code for Module libxml2

   1  import libxml2mod 
   2  import types 
   3  import sys 
   4   
   5  # The root of all libxml2 errors. 
6 -class libxmlError(Exception): pass
7 8 # 9 # id() is sometimes negative ... 10 #
11 -def pos_id(o):
12 i = id(o) 13 if (i < 0): 14 return (sys.maxint - i) 15 return i
16 17 # 18 # Errors raised by the wrappers when some tree handling failed. 19 #
20 -class treeError(libxmlError):
21 - def __init__(self, msg):
22 self.msg = msg
23 - def __str__(self):
24 return self.msg
25
26 -class parserError(libxmlError):
27 - def __init__(self, msg):
28 self.msg = msg
29 - def __str__(self):
30 return self.msg
31
32 -class uriError(libxmlError):
33 - def __init__(self, msg):
34 self.msg = msg
35 - def __str__(self):
36 return self.msg
37
38 -class xpathError(libxmlError):
39 - def __init__(self, msg):
40 self.msg = msg
41 - def __str__(self):
42 return self.msg
43
44 -class ioWrapper:
45 - def __init__(self, _obj):
46 self.__io = _obj 47 self._o = None
48
49 - def io_close(self):
50 if self.__io == None: 51 return(-1) 52 self.__io.close() 53 self.__io = None 54 return(0)
55
56 - def io_flush(self):
57 if self.__io == None: 58 return(-1) 59 self.__io.flush() 60 return(0)
61
62 - def io_read(self, len = -1):
63 if self.__io == None: 64 return(-1) 65 if len < 0: 66 return(self.__io.read()) 67 return(self.__io.read(len))
68
69 - def io_write(self, str, len = -1):
70 if self.__io == None: 71 return(-1) 72 if len < 0: 73 return(self.__io.write(str)) 74 return(self.__io.write(str, len))
75
76 -class ioReadWrapper(ioWrapper):
77 - def __init__(self, _obj, enc = ""):
78 ioWrapper.__init__(self, _obj) 79 self._o = libxml2mod.xmlCreateInputBuffer(self, enc)
80
81 - def __del__(self):
82 print "__del__" 83 self.io_close() 84 if self._o != None: 85 libxml2mod.xmlFreeParserInputBuffer(self._o) 86 self._o = None
87
88 - def close(self):
89 self.io_close() 90 if self._o != None: 91 libxml2mod.xmlFreeParserInputBuffer(self._o) 92 self._o = None
93
94 -class ioWriteWrapper(ioWrapper):
95 - def __init__(self, _obj, enc = ""):
96 # print "ioWriteWrapper.__init__", _obj 97 if type(_obj) == type(''): 98 print "write io from a string" 99 self.o = None 100 elif type(_obj) == types.InstanceType: 101 print "write io from instance of %s" % (_obj.__class__) 102 ioWrapper.__init__(self, _obj) 103 self._o = libxml2mod.xmlCreateOutputBuffer(self, enc) 104 else: 105 file = libxml2mod.outputBufferGetPythonFile(_obj) 106 if file != None: 107 ioWrapper.__init__(self, file) 108 else: 109 ioWrapper.__init__(self, _obj) 110 self._o = _obj
111
112 - def __del__(self):
113 # print "__del__" 114 self.io_close() 115 if self._o != None: 116 libxml2mod.xmlOutputBufferClose(self._o) 117 self._o = None
118
119 - def flush(self):
120 self.io_flush() 121 if self._o != None: 122 libxml2mod.xmlOutputBufferClose(self._o) 123 self._o = None
124
125 - def close(self):
126 self.io_flush() 127 if self._o != None: 128 libxml2mod.xmlOutputBufferClose(self._o) 129 self._o = None
130 131 # 132 # Example of a class to handle SAX events 133 #
134 -class SAXCallback:
135 """Base class for SAX handlers"""
136 - def startDocument(self):
137 """called at the start of the document""" 138 pass
139
140 - def endDocument(self):
141 """called at the end of the document""" 142 pass
143
144 - def startElement(self, tag, attrs):
145 """called at the start of every element, tag is the name of 146 the element, attrs is a dictionary of the element's attributes""" 147 pass
148
149 - def endElement(self, tag):
150 """called at the start of every element, tag is the name of 151 the element""" 152 pass
153
154 - def characters(self, data):
155 """called when character data have been read, data is the string 156 containing the data, multiple consecutive characters() callback 157 are possible.""" 158 pass
159
160 - def cdataBlock(self, data):
161 """called when CDATA section have been read, data is the string 162 containing the data, multiple consecutive cdataBlock() callback 163 are possible.""" 164 pass
165
166 - def reference(self, name):
167 """called when an entity reference has been found""" 168 pass
169
170 - def ignorableWhitespace(self, data):
171 """called when potentially ignorable white spaces have been found""" 172 pass
173
174 - def processingInstruction(self, target, data):
175 """called when a PI has been found, target contains the PI name and 176 data is the associated data in the PI""" 177 pass
178
179 - def comment(self, content):
180 """called when a comment has been found, content contains the comment""" 181 pass
182
183 - def externalSubset(self, name, externalID, systemID):
184 """called when a DOCTYPE declaration has been found, name is the 185 DTD name and externalID, systemID are the DTD public and system 186 identifier for that DTd if available""" 187 pass
188
189 - def internalSubset(self, name, externalID, systemID):
190 """called when a DOCTYPE declaration has been found, name is the 191 DTD name and externalID, systemID are the DTD public and system 192 identifier for that DTD if available""" 193 pass
194
195 - def entityDecl(self, name, type, externalID, systemID, content):
196 """called when an ENTITY declaration has been found, name is the 197 entity name and externalID, systemID are the entity public and 198 system identifier for that entity if available, type indicates 199 the entity type, and content reports it's string content""" 200 pass
201
202 - def notationDecl(self, name, externalID, systemID):
203 """called when an NOTATION declaration has been found, name is the 204 notation name and externalID, systemID are the notation public and 205 system identifier for that notation if available""" 206 pass
207
208 - def attributeDecl(self, elem, name, type, defi, defaultValue, nameList):
209 """called when an ATTRIBUTE definition has been found""" 210 pass
211
212 - def elementDecl(self, name, type, content):
213 """called when an ELEMENT definition has been found""" 214 pass
215
216 - def entityDecl(self, name, publicId, systemID, notationName):
217 """called when an unparsed ENTITY declaration has been found, 218 name is the entity name and publicId,, systemID are the entity 219 public and system identifier for that entity if available, 220 and notationName indicate the associated NOTATION""" 221 pass
222
223 - def warning(self, msg):
224 #print msg 225 pass
226
227 - def error(self, msg):
228 raise parserError(msg)
229
230 - def fatalError(self, msg):
231 raise parserError(msg)
232 233 # 234 # This class is the ancestor of all the Node classes. It provides 235 # the basic functionalities shared by all nodes (and handle 236 # gracefylly the exception), like name, navigation in the tree, 237 # doc reference, content access and serializing to a string or URI 238 #
239 -class xmlCore:
240 - def __init__(self, _obj=None):
241 if _obj != None: 242 self._o = _obj; 243 return 244 self._o = None
245
246 - def __eq__(self, other):
247 if other == None: 248 return False 249 ret = libxml2mod.compareNodesEqual(self._o, other._o) 250 if ret == None: 251 return False 252 return ret == True
253 - def __ne__(self, other):
254 if other == None: 255 return True 256 ret = libxml2mod.compareNodesEqual(self._o, other._o) 257 return not ret
258 - def __hash__(self):
259 ret = libxml2mod.nodeHash(self._o) 260 return ret
261
262 - def __str__(self):
263 return self.serialize()
264 - def get_parent(self):
265 ret = libxml2mod.parent(self._o) 266 if ret == None: 267 return None 268 return xmlNode(_obj=ret)
269 - def get_children(self):
270 ret = libxml2mod.children(self._o) 271 if ret == None: 272 return None 273 return xmlNode(_obj=ret)
274 - def get_last(self):
275 ret = libxml2mod.last(self._o) 276 if ret == None: 277 return None 278 return xmlNode(_obj=ret)
279 - def get_next(self):
280 ret = libxml2mod.next(self._o) 281 if ret == None: 282 return None 283 return xmlNode(_obj=ret)
284 - def get_properties(self):
285 ret = libxml2mod.properties(self._o) 286 if ret == None: 287 return None 288 return xmlAttr(_obj=ret)
289 - def get_prev(self):
290 ret = libxml2mod.prev(self._o) 291 if ret == None: 292 return None 293 return xmlNode(_obj=ret)
294 - def get_content(self):
295 return libxml2mod.xmlNodeGetContent(self._o)
296 getContent = get_content # why is this duplicate naming needed ?
297 - def get_name(self):
298 return libxml2mod.name(self._o)
299 - def get_type(self):
300 return libxml2mod.type(self._o)
301 - def get_doc(self):
302 ret = libxml2mod.doc(self._o) 303 if ret == None: 304 if self.type in ["document_xml", "document_html"]: 305 return xmlDoc(_obj=self._o) 306 else: 307 return None 308 return xmlDoc(_obj=ret)
309 # 310 # Those are common attributes to nearly all type of nodes 311 # defined as python2 properties 312 # 313 import sys 314 if float(sys.version[0:3]) < 2.2:
315 - def __getattr__(self, attr):
316 if attr == "parent": 317 ret = libxml2mod.parent(self._o) 318 if ret == None: 319 return None 320 return xmlNode(_obj=ret) 321 elif attr == "properties": 322 ret = libxml2mod.properties(self._o) 323 if ret == None: 324 return None 325 return xmlAttr(_obj=ret) 326 elif attr == "children": 327 ret = libxml2mod.children(self._o) 328 if ret == None: 329 return None 330 return xmlNode(_obj=ret) 331 elif attr == "last": 332 ret = libxml2mod.last(self._o) 333 if ret == None: 334 return None 335 return xmlNode(_obj=ret) 336 elif attr == "next": 337 ret = libxml2mod.next(self._o) 338 if ret == None: 339 return None 340 return xmlNode(_obj=ret) 341 elif attr == "prev": 342 ret = libxml2mod.prev(self._o) 343 if ret == None: 344 return None 345 return xmlNode(_obj=ret) 346 elif attr == "content": 347 return libxml2mod.xmlNodeGetContent(self._o) 348 elif attr == "name": 349 return libxml2mod.name(self._o) 350 elif attr == "type": 351 return libxml2mod.type(self._o) 352 elif attr == "doc": 353 ret = libxml2mod.doc(self._o) 354 if ret == None: 355 if self.type == "document_xml" or self.type == "document_html": 356 return xmlDoc(_obj=self._o) 357 else: 358 return None 359 return xmlDoc(_obj=ret) 360 raise AttributeError,attr
361 else: 362 parent = property(get_parent, None, None, "Parent node") 363 children = property(get_children, None, None, "First child node") 364 last = property(get_last, None, None, "Last sibling node") 365 next = property(get_next, None, None, "Next sibling node") 366 prev = property(get_prev, None, None, "Previous sibling node") 367 properties = property(get_properties, None, None, "List of properies") 368 content = property(get_content, None, None, "Content of this node") 369 name = property(get_name, None, None, "Node name") 370 type = property(get_type, None, None, "Node type") 371 doc = property(get_doc, None, None, "The document this node belongs to") 372 373 # 374 # Serialization routines, the optional arguments have the following 375 # meaning: 376 # encoding: string to ask saving in a specific encoding 377 # indent: if 1 the serializer is asked to indent the output 378 #
379 - def serialize(self, encoding = None, format = 0):
380 return libxml2mod.serializeNode(self._o, encoding, format)
381 - def saveTo(self, file, encoding = None, format = 0):
382 return libxml2mod.saveNodeTo(self._o, file, encoding, format)
383 384 # 385 # Canonicalization routines: 386 # 387 # nodes: the node set (tuple or list) to be included in the 388 # canonized image or None if all document nodes should be 389 # included. 390 # exclusive: the exclusive flag (0 - non-exclusive 391 # canonicalization; otherwise - exclusive canonicalization) 392 # prefixes: the list of inclusive namespace prefixes (strings), 393 # or None if there is no inclusive namespaces (only for 394 # exclusive canonicalization, ignored otherwise) 395 # with_comments: include comments in the result (!=0) or not 396 # (==0)
397 - def c14nMemory(self, 398 nodes=None, 399 exclusive=0, 400 prefixes=None, 401 with_comments=0):
402 if nodes: 403 nodes = map(lambda n: n._o, nodes) 404 return libxml2mod.xmlC14NDocDumpMemory( 405 self.get_doc()._o, 406 nodes, 407 exclusive != 0, 408 prefixes, 409 with_comments != 0)
410 - def c14nSaveTo(self, 411 file, 412 nodes=None, 413 exclusive=0, 414 prefixes=None, 415 with_comments=0):
416 if nodes: 417 nodes = map(lambda n: n._o, nodes) 418 return libxml2mod.xmlC14NDocSaveTo( 419 self.get_doc()._o, 420 nodes, 421 exclusive != 0, 422 prefixes, 423 with_comments != 0, 424 file)
425 426 # 427 # Selecting nodes using XPath, a bit slow because the context 428 # is allocated/freed every time but convenient. 429 #
430 - def xpathEval(self, expr):
431 doc = self.doc 432 if doc == None: 433 return None 434 ctxt = doc.xpathNewContext() 435 ctxt.setContextNode(self) 436 res = ctxt.xpathEval(expr) 437 ctxt.xpathFreeContext() 438 return res
439 440 # # 441 # # Selecting nodes using XPath, faster because the context 442 # # is allocated just once per xmlDoc. 443 # # 444 # # Removed: DV memleaks c.f. #126735 445 # # 446 # def xpathEval2(self, expr): 447 # doc = self.doc 448 # if doc == None: 449 # return None 450 # try: 451 # doc._ctxt.setContextNode(self) 452 # except: 453 # doc._ctxt = doc.xpathNewContext() 454 # doc._ctxt.setContextNode(self) 455 # res = doc._ctxt.xpathEval(expr) 456 # return res
457 - def xpathEval2(self, expr):
458 return self.xpathEval(expr)
459 460 # Remove namespaces
461 - def removeNsDef(self, href):
462 """ 463 Remove a namespace definition from a node. If href is None, 464 remove all of the ns definitions on that node. The removed 465 namespaces are returned as a linked list. 466 467 Note: If any child nodes referred to the removed namespaces, 468 they will be left with dangling links. You should call 469 renciliateNs() to fix those pointers. 470 471 Note: This method does not free memory taken by the ns 472 definitions. You will need to free it manually with the 473 freeNsList() method on the returns xmlNs object. 474 """ 475 476 ret = libxml2mod.xmlNodeRemoveNsDef(self._o, href) 477 if ret is None:return None 478 __tmp = xmlNs(_obj=ret) 479 return __tmp
480 481 # support for python2 iterators
482 - def walk_depth_first(self):
483 return xmlCoreDepthFirstItertor(self)
484 - def walk_breadth_first(self):
485 return xmlCoreBreadthFirstItertor(self)
486 __iter__ = walk_depth_first 487
488 - def free(self):
489 try: 490 self.doc._ctxt.xpathFreeContext() 491 except: 492 pass 493 libxml2mod.xmlFreeDoc(self._o)
494 495 496 # 497 # implements the depth-first iterator for libxml2 DOM tree 498 #
499 -class xmlCoreDepthFirstItertor:
500 - def __init__(self, node):
501 self.node = node 502 self.parents = []
503 - def __iter__(self):
504 return self
505 - def next(self):
506 while 1: 507 if self.node: 508 ret = self.node 509 self.parents.append(self.node) 510 self.node = self.node.children 511 return ret 512 try: 513 parent = self.parents.pop() 514 except IndexError: 515 raise StopIteration 516 self.node = parent.next
517 518 # 519 # implements the breadth-first iterator for libxml2 DOM tree 520 #
521 -class xmlCoreBreadthFirstItertor:
522 - def __init__(self, node):
523 self.node = node 524 self.parents = []
525 - def __iter__(self):
526 return self
527 - def next(self):
528 while 1: 529 if self.node: 530 ret = self.node 531 self.parents.append(self.node) 532 self.node = self.node.next 533 return ret 534 try: 535 parent = self.parents.pop() 536 except IndexError: 537 raise StopIteration 538 self.node = parent.children
539 540 # 541 # converters to present a nicer view of the XPath returns 542 #
543 -def nodeWrap(o):
544 # TODO try to cast to the most appropriate node class 545 name = libxml2mod.type(o) 546 if name == "element" or name == "text": 547 return xmlNode(_obj=o) 548 if name == "attribute": 549 return xmlAttr(_obj=o) 550 if name[0:8] == "document": 551 return xmlDoc(_obj=o) 552 if name == "namespace": 553 return xmlNs(_obj=o) 554 if name == "elem_decl": 555 return xmlElement(_obj=o) 556 if name == "attribute_decl": 557 return xmlAttribute(_obj=o) 558 if name == "entity_decl": 559 return xmlEntity(_obj=o) 560 if name == "dtd": 561 return xmlDtd(_obj=o) 562 return xmlNode(_obj=o)
563
564 -def xpathObjectRet(o):
565 otype = type(o) 566 if otype == type([]): 567 ret = map(xpathObjectRet, o) 568 return ret 569 elif otype == type(()): 570 ret = map(xpathObjectRet, o) 571 return tuple(ret) 572 elif otype == type('') or otype == type(0) or otype == type(0.0): 573 return o 574 else: 575 return nodeWrap(o)
576 577 # 578 # register an XPath function 579 #
580 -def registerXPathFunction(ctxt, name, ns_uri, f):
581 ret = libxml2mod.xmlRegisterXPathFunction(ctxt, name, ns_uri, f)
582 583 # 584 # For the xmlTextReader parser configuration 585 # 586 PARSER_LOADDTD=1 587 PARSER_DEFAULTATTRS=2 588 PARSER_VALIDATE=3 589 PARSER_SUBST_ENTITIES=4 590 591 # 592 # For the error callback severities 593 # 594 PARSER_SEVERITY_VALIDITY_WARNING=1 595 PARSER_SEVERITY_VALIDITY_ERROR=2 596 PARSER_SEVERITY_WARNING=3 597 PARSER_SEVERITY_ERROR=4 598 599 # 600 # register the libxml2 error handler 601 #
602 -def registerErrorHandler(f, ctx):
603 """Register a Python written function to for error reporting. 604 The function is called back as f(ctx, error). """ 605 import sys 606 if not sys.modules.has_key('libxslt'): 607 # normal behaviour when libxslt is not imported 608 ret = libxml2mod.xmlRegisterErrorHandler(f,ctx) 609 else: 610 # when libxslt is already imported, one must 611 # use libxst's error handler instead 612 import libxslt 613 ret = libxslt.registerErrorHandler(f,ctx) 614 return ret
615
616 -class parserCtxtCore:
617
618 - def __init__(self, _obj=None):
619 if _obj != None: 620 self._o = _obj; 621 return 622 self._o = None
623
624 - def __del__(self):
625 if self._o != None: 626 libxml2mod.xmlFreeParserCtxt(self._o) 627 self._o = None
628
629 - def setErrorHandler(self,f,arg):
630 """Register an error handler that will be called back as 631 f(arg,msg,severity,reserved). 632 633 @reserved is currently always None.""" 634 libxml2mod.xmlParserCtxtSetErrorHandler(self._o,f,arg)
635
636 - def getErrorHandler(self):
637 """Return (f,arg) as previously registered with setErrorHandler 638 or (None,None).""" 639 return libxml2mod.xmlParserCtxtGetErrorHandler(self._o)
640
641 - def addLocalCatalog(self, uri):
642 """Register a local catalog with the parser""" 643 return libxml2mod.addLocalCatalog(self._o, uri)
644 645
646 -class ValidCtxtCore:
647
648 - def __init__(self, *args, **kw):
649 pass
650
651 - def setValidityErrorHandler(self, err_func, warn_func, arg=None):
652 """ 653 Register error and warning handlers for DTD validation. 654 These will be called back as f(msg,arg) 655 """ 656 libxml2mod.xmlSetValidErrors(self._o, err_func, warn_func, arg)
657 658
659 -class SchemaValidCtxtCore:
660
661 - def __init__(self, *args, **kw):
662 pass
663
664 - def setValidityErrorHandler(self, err_func, warn_func, arg=None):
665 """ 666 Register error and warning handlers for Schema validation. 667 These will be called back as f(msg,arg) 668 """ 669 libxml2mod.xmlSchemaSetValidErrors(self._o, err_func, warn_func, arg)
670 671
672 -class relaxNgValidCtxtCore:
673
674 - def __init__(self, *args, **kw):
675 pass
676
677 - def setValidityErrorHandler(self, err_func, warn_func, arg=None):
678 """ 679 Register error and warning handlers for RelaxNG validation. 680 These will be called back as f(msg,arg) 681 """ 682 libxml2mod.xmlRelaxNGSetValidErrors(self._o, err_func, warn_func, arg)
683 684
685 -def _xmlTextReaderErrorFunc((f,arg),msg,severity,locator):
686 """Intermediate callback to wrap the locator""" 687 return f(arg,msg,severity,xmlTextReaderLocator(locator))
688
689 -class xmlTextReaderCore:
690
691 - def __init__(self, _obj=None):
692 self.input = None 693 if _obj != None:self._o = _obj;return 694 self._o = None
695
696 - def __del__(self):
697 if self._o != None: 698 libxml2mod.xmlFreeTextReader(self._o) 699 self._o = None
700
701 - def SetErrorHandler(self,f,arg):
702 """Register an error handler that will be called back as 703 f(arg,msg,severity,locator).""" 704 if f is None: 705 libxml2mod.xmlTextReaderSetErrorHandler(\ 706 self._o,None,None) 707 else: 708 libxml2mod.xmlTextReaderSetErrorHandler(\ 709 self._o,_xmlTextReaderErrorFunc,(f,arg))
710
711 - def GetErrorHandler(self):
712 """Return (f,arg) as previously registered with setErrorHandler 713 or (None,None).""" 714 f,arg = libxml2mod.xmlTextReaderGetErrorHandler(self._o) 715 if f is None: 716 return None,None 717 else: 718 # assert f is _xmlTextReaderErrorFunc 719 return arg
720 721 # 722 # The cleanup now goes though a wrappe in libxml.c 723 #
724 -def cleanupParser():
725 libxml2mod.xmlPythonCleanupParser()
726 727 # WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING 728 # 729 # Everything before this line comes from libxml.py 730 # Everything after this line is automatically generated 731 # 732 # WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING 733 734 # 735 # Functions from module HTMLparser 736 # 737
738 -def htmlCreateMemoryParserCtxt(buffer, size):
739 """Create a parser context for an HTML in-memory document. """ 740 ret = libxml2mod.htmlCreateMemoryParserCtxt(buffer, size) 741 if ret is None:raise parserError('htmlCreateMemoryParserCtxt() failed') 742 return parserCtxt(_obj=ret)
743
744 -def htmlHandleOmittedElem(val):
745 """Set and return the previous value for handling HTML omitted 746 tags. """ 747 ret = libxml2mod.htmlHandleOmittedElem(val) 748 return ret
749
750 -def htmlIsScriptAttribute(name):
751 """Check if an attribute is of content type Script """ 752 ret = libxml2mod.htmlIsScriptAttribute(name) 753 return ret
754
755 -def htmlNewParserCtxt():
756 """Allocate and initialize a new parser context. """ 757 ret = libxml2mod.htmlNewParserCtxt() 758 if ret is None:raise parserError('htmlNewParserCtxt() failed') 759 return parserCtxt(_obj=ret)
760
761 -def htmlParseDoc(cur, encoding):
762 """parse an HTML in-memory document and build a tree. """ 763 ret = libxml2mod.htmlParseDoc(cur, encoding) 764 if ret is None:raise parserError('htmlParseDoc() failed') 765 return xmlDoc(_obj=ret)
766
767 -def htmlParseFile(filename, encoding):
768 """parse an HTML file and build a tree. Automatic support for 769 ZLIB/Compress compressed document is provided by default 770 if found at compile-time. """ 771 ret = libxml2mod.htmlParseFile(filename, encoding) 772 if ret is None:raise parserError('htmlParseFile() failed') 773 return xmlDoc(_obj=ret)
774
775 -def htmlReadDoc(cur, URL, encoding, options):
776 """parse an XML in-memory document and build a tree. """ 777 ret = libxml2mod.htmlReadDoc(cur, URL, encoding, options) 778 if ret is None:raise treeError('htmlReadDoc() failed') 779 return xmlDoc(_obj=ret)
780
781 -def htmlReadFd(fd, URL, encoding, options):
782 """parse an XML from a file descriptor and build a tree. """ 783 ret = libxml2mod.htmlReadFd(fd, URL, encoding, options) 784 if ret is None:raise treeError('htmlReadFd() failed') 785 return xmlDoc(_obj=ret)
786
787 -def htmlReadFile(filename, encoding, options):
788 """parse an XML file from the filesystem or the network. """ 789 ret = libxml2mod.htmlReadFile(filename, encoding, options) 790 if ret is None:raise treeError('htmlReadFile() failed') 791 return xmlDoc(_obj=ret)
792
793 -def htmlReadMemory(buffer, size, URL, encoding, options):
794 """parse an XML in-memory document and build a tree. """ 795 ret = libxml2mod.htmlReadMemory(buffer, size, URL, encoding, options) 796 if ret is None:raise treeError('htmlReadMemory() failed') 797 return xmlDoc(_obj=ret)
798 799 # 800 # Functions from module HTMLtree 801 # 802
803 -def htmlIsBooleanAttr(name):
804 """Determine if a given attribute is a boolean attribute. """ 805 ret = libxml2mod.htmlIsBooleanAttr(name) 806 return ret
807
808 -def htmlNewDoc(URI, ExternalID):
809 """Creates a new HTML document """ 810 ret = libxml2mod.htmlNewDoc(URI, ExternalID) 811 if ret is None:raise treeError('htmlNewDoc() failed') 812 return xmlDoc(_obj=ret)
813
814 -def htmlNewDocNoDtD(URI, ExternalID):
815 """Creates a new HTML document without a DTD node if @URI and 816 @ExternalID are None """ 817 ret = libxml2mod.htmlNewDocNoDtD(URI, ExternalID) 818 if ret is None:raise treeError('htmlNewDocNoDtD() failed') 819 return xmlDoc(_obj=ret)
820 821 # 822 # Functions from module SAX2 823 # 824
825 -def SAXDefaultVersion(version):
826 """Set the default version of SAX used globally by the 827 library. By default, during initialization the default is 828 set to 2. Note that it is generally a better coding style 829 to use xmlSAXVersion() to set up the version explicitly 830 for a given parsing context. """ 831 ret = libxml2mod.xmlSAXDefaultVersion(version) 832 return ret
833
834 -def defaultSAXHandlerInit():
835 """Initialize the default SAX2 handler """ 836 libxml2mod.xmlDefaultSAXHandlerInit()
837
838 -def docbDefaultSAXHandlerInit():
839 """Initialize the default SAX handler """ 840 libxml2mod.docbDefaultSAXHandlerInit()
841
842 -def htmlDefaultSAXHandlerInit():
843 """Initialize the default SAX handler """ 844 libxml2mod.htmlDefaultSAXHandlerInit()
845 846 # 847 # Functions from module catalog 848 # 849
850 -def catalogAdd(type, orig, replace):
851 """Add an entry in the catalog, it may overwrite existing but 852 different entries. If called before any other catalog 853 routine, allows to override the default shared catalog put 854 in place by xmlInitializeCatalog(); """ 855 ret = libxml2mod.xmlCatalogAdd(type, orig, replace) 856 return ret
857
858 -def catalogCleanup():
859 """Free up all the memory associated with catalogs """ 860 libxml2mod.xmlCatalogCleanup()
861
862 -def catalogConvert():
863 """Convert all the SGML catalog entries as XML ones """ 864 ret = libxml2mod.xmlCatalogConvert() 865 return ret
866
867 -def catalogDump(out):
868 """Dump all the global catalog content to the given file. """ 869 libxml2mod.xmlCatalogDump(out)
870
871 -def catalogGetPublic(pubID):
872 """Try to lookup the catalog reference associated to a public 873 ID DEPRECATED, use xmlCatalogResolvePublic() """ 874 ret = libxml2mod.xmlCatalogGetPublic(pubID) 875 return ret
876
877 -def catalogGetSystem(sysID):
878 """Try to lookup the catalog reference associated to a system 879 ID DEPRECATED, use xmlCatalogResolveSystem() """ 880 ret = libxml2mod.xmlCatalogGetSystem(sysID) 881 return ret
882
883 -def catalogRemove(value):
884 """Remove an entry from the catalog """ 885 ret = libxml2mod.xmlCatalogRemove(value) 886 return ret
887
888 -def catalogResolve(pubID, sysID):
889 """Do a complete resolution lookup of an External Identifier """ 890 ret = libxml2mod.xmlCatalogResolve(pubID, sysID) 891 return ret
892
893 -def catalogResolvePublic(pubID):
894 """Try to lookup the catalog reference associated to a public 895 ID """ 896 ret = libxml2mod.xmlCatalogResolvePublic(pubID) 897 return ret
898
899 -def catalogResolveSystem(sysID):
900 """Try to lookup the catalog resource for a system ID """ 901 ret = libxml2mod.xmlCatalogResolveSystem(sysID) 902 return ret
903
904 -def catalogResolveURI(URI):
905 """Do a complete resolution lookup of an URI """ 906 ret = libxml2mod.xmlCatalogResolveURI(URI) 907 return ret
908
909 -def catalogSetDebug(level):
910 """Used to set the debug level for catalog operation, 0 911 disable debugging, 1 enable it """ 912 ret = libxml2mod.xmlCatalogSetDebug(level) 913 return ret
914
915 -def initializeCatalog():
916 """Do the catalog initialization. this function is not thread 917 safe, catalog initialization should preferably be done 918 once at startup """ 919 libxml2mod.xmlInitializeCatalog()
920
921 -def loadACatalog(filename):
922 """Load the catalog and build the associated data structures. 923 This can be either an XML Catalog or an SGML Catalog It 924 will recurse in SGML CATALOG entries. On the other hand 925 XML Catalogs are not handled recursively. """ 926 ret = libxml2mod.xmlLoadACatalog(filename) 927 if ret is None:raise treeError('xmlLoadACatalog() failed') 928 return catalog(_obj=ret)
929
930 -def loadCatalog(filename):
931 """Load the catalog and makes its definitions effective for 932 the default external entity loader. It will recurse in 933 SGML CATALOG entries. this function is not thread safe, 934 catalog initialization should preferably be done once at 935 startup """ 936 ret = libxml2mod.xmlLoadCatalog(filename) 937 return ret
938
939 -def loadCatalogs(pathss):
940 """Load the catalogs and makes their definitions effective for 941 the default external entity loader. this function is not 942 thread safe, catalog initialization should preferably be 943 done once at startup """ 944 libxml2mod.xmlLoadCatalogs(pathss)
945
946 -def loadSGMLSuperCatalog(filename):
947 """Load an SGML super catalog. It won't expand CATALOG or 948 DELEGATE references. This is only needed for manipulating 949 SGML Super Catalogs like adding and removing CATALOG or 950 DELEGATE entries. """ 951 ret = libxml2mod.xmlLoadSGMLSuperCatalog(filename) 952 if ret is None:raise treeError('xmlLoadSGMLSuperCatalog() failed') 953 return catalog(_obj=ret)
954
955 -def newCatalog(sgml):
956 """create a new Catalog. """ 957 ret = libxml2mod.xmlNewCatalog(sgml) 958 if ret is None:raise treeError('xmlNewCatalog() failed') 959 return catalog(_obj=ret)
960
961 -def parseCatalogFile(filename):
962 """parse an XML file and build a tree. It's like 963 xmlParseFile() except it bypass all catalog lookups. """ 964 ret = libxml2mod.xmlParseCatalogFile(filename) 965 if ret is None:raise parserError('xmlParseCatalogFile() failed') 966 return xmlDoc(_obj=ret)
967 968 # 969 # Functions from module chvalid 970 # 971
972 -def isBaseChar(ch):
973 """This function is DEPRECATED. Use xmlIsBaseChar_ch or 974 xmlIsBaseCharQ instead """ 975 ret = libxml2mod.xmlIsBaseChar(ch) 976 return ret
977
978 -def isBlank(ch):
979 """This function is DEPRECATED. Use xmlIsBlank_ch or 980 xmlIsBlankQ instead """ 981 ret = libxml2mod.xmlIsBlank(ch) 982 return ret
983
984 -def isChar(ch):
985 """This function is DEPRECATED. Use xmlIsChar_ch or xmlIsCharQ 986 instead """ 987 ret = libxml2mod.xmlIsChar(ch) 988 return ret
989
990 -def isCombining(ch):
991 """This function is DEPRECATED. Use xmlIsCombiningQ instead """ 992 ret = libxml2mod.xmlIsCombining(ch) 993 return ret
994
995 -def isDigit(ch):
996 """This function is DEPRECATED. Use xmlIsDigit_ch or 997 xmlIsDigitQ instead """ 998 ret = libxml2mod.xmlIsDigit(ch) 999 return ret
1000
1001 -def isExtender(ch):
1002 """This function is DEPRECATED. Use xmlIsExtender_ch or 1003 xmlIsExtenderQ instead """ 1004 ret = libxml2mod.xmlIsExtender(ch) 1005 return ret
1006
1007 -def isIdeographic(ch):
1008 """This function is DEPRECATED. Use xmlIsIdeographicQ instead """ 1009 ret = libxml2mod.xmlIsIdeographic(ch) 1010 return ret
1011
1012 -def isPubidChar(ch):
1013 """This function is DEPRECATED. Use xmlIsPubidChar_ch or 1014 xmlIsPubidCharQ instead """ 1015 ret = libxml2mod.xmlIsPubidChar(ch) 1016 return ret
1017 1018 # 1019 # Functions from module debugXML 1020 # 1021
1022 -def boolToText(boolval):
1023 """Convenient way to turn bool into text """ 1024 ret = libxml2mod.xmlBoolToText(boolval) 1025 return ret
1026
1027 -def debugDumpString(output, str):
1028 """Dumps informations about the string, shorten it if necessary """ 1029 libxml2mod.xmlDebugDumpString(output, str)
1030
1031 -def shellPrintXPathError(errorType, arg):
1032 """Print the xpath error to libxml default error channel """ 1033 libxml2mod.xmlShellPrintXPathError(errorType, arg)
1034 1035 # 1036 # Functions from module dict 1037 # 1038
1039 -def dictCleanup():
1040 """Free the dictionary mutex. """ 1041 libxml2mod.xmlDictCleanup()
1042 1043 # 1044 # Functions from module encoding 1045 # 1046
1047 -def addEncodingAlias(name, alias):
1048 """Registers an alias @alias for an encoding named @name. 1049 Existing alias will be overwritten. """ 1050 ret = libxml2mod.xmlAddEncodingAlias(name, alias) 1051 return ret
1052
1053 -def cleanupCharEncodingHandlers():
1054 """Cleanup the memory allocated for the char encoding support, 1055 it unregisters all the encoding handlers and the aliases. """ 1056 libxml2mod.xmlCleanupCharEncodingHandlers()
1057
1058 -def cleanupEncodingAliases():
1059 """Unregisters all aliases """ 1060 libxml2mod.xmlCleanupEncodingAliases()
1061
1062 -def delEncodingAlias(alias):
1063 """Unregisters an encoding alias @alias """ 1064 ret = libxml2mod.xmlDelEncodingAlias(alias) 1065 return ret
1066
1067 -def encodingAlias(alias):
1068 """Lookup an encoding name for the given alias. """ 1069 ret = libxml2mod.xmlGetEncodingAlias(alias) 1070 return ret
1071
1072 -def initCharEncodingHandlers():
1073 """Initialize the char encoding support, it registers the 1074 default encoding supported. NOTE: while public, this 1075 function usually doesn't need to be called in normal 1076 processing. """ 1077 libxml2mod.xmlInitCharEncodingHandlers()
1078 1079 # 1080 # Functions from module entities 1081 # 1082
1083 -def cleanupPredefinedEntities():
1084 """Cleanup up the predefined entities table. Deprecated call """ 1085 libxml2mod.xmlCleanupPredefinedEntities()
1086
1087 -def initializePredefinedEntities():
1088 """Set up the predefined entities. Deprecated call """ 1089 libxml2mod.xmlInitializePredefinedEntities()
1090
1091 -def predefinedEntity(name):
1092 """Check whether this name is an predefined entity. """ 1093 ret = libxml2mod.xmlGetPredefinedEntity(name) 1094 if ret is None:raise treeError('xmlGetPredefinedEntity() failed') 1095 return xmlEntity(_obj=ret)
1096 1097 # 1098 # Functions from module globals 1099 # 1100
1101 -def cleanupGlobals():
1102 """Additional cleanup for multi-threading """ 1103 libxml2mod.xmlCleanupGlobals()
1104
1105 -def initGlobals():
1106 """Additional initialisation for multi-threading """ 1107 libxml2mod.xmlInitGlobals()
1108
1109 -def thrDefDefaultBufferSize(v):
1110 ret = libxml2mod.xmlThrDefDefaultBufferSize(v) 1111 return ret
1112
1113 -def thrDefDoValidityCheckingDefaultValue(v):
1114 ret = libxml2mod.xmlThrDefDoValidityCheckingDefaultValue(v) 1115 return ret
1116
1117 -def thrDefGetWarningsDefaultValue(v):
1118 ret = libxml2mod.xmlThrDefGetWarningsDefaultValue(v) 1119 return ret
1120
1121 -def thrDefIndentTreeOutput(v):
1122 ret = libxml2mod.xmlThrDefIndentTreeOutput(v) 1123 return ret
1124
1125 -def thrDefKeepBlanksDefaultValue(v):
1126 ret = libxml2mod.xmlThrDefKeepBlanksDefaultValue(v) 1127 return ret
1128
1129 -def thrDefLineNumbersDefaultValue(v):
1130 ret = libxml2mod.xmlThrDefLineNumbersDefaultValue(v) 1131 return ret
1132
1133 -def thrDefLoadExtDtdDefaultValue(v):
1134 ret = libxml2mod.xmlThrDefLoadExtDtdDefaultValue(v) 1135 return ret
1136
1137 -def thrDefParserDebugEntities(v):
1138 ret = libxml2mod.xmlThrDefParserDebugEntities(v) 1139 return ret
1140
1141 -def thrDefPedanticParserDefaultValue(v):
1142 ret = libxml2mod.xmlThrDefPedanticParserDefaultValue(v) 1143 return ret
1144
1145 -def thrDefSaveNoEmptyTags(v):
1146 ret = libxml2mod.xmlThrDefSaveNoEmptyTags(v) 1147 return ret
1148
1149 -def thrDefSubstituteEntitiesDefaultValue(v):
1150 ret = libxml2mod.xmlThrDefSubstituteEntitiesDefaultValue(v) 1151 return ret
1152
1153 -def thrDefTreeIndentString(v):
1154 ret = libxml2mod.xmlThrDefTreeIndentString(v) 1155 return ret
1156 1157 # 1158 # Functions from module nanoftp 1159 # 1160
1161 -def nanoFTPCleanup():
1162 """Cleanup the FTP protocol layer. This cleanup proxy 1163 informations. """ 1164 libxml2mod.xmlNanoFTPCleanup()
1165
1166 -def nanoFTPInit():
1167 """Initialize the FTP protocol layer. Currently it just checks 1168 for proxy informations, and get the hostname """ 1169 libxml2mod.xmlNanoFTPInit()
1170
1171 -def nanoFTPProxy(host, port, user, passwd, type):
1172 """Setup the FTP proxy informations. This can also be done by 1173 using ftp_proxy ftp_proxy_user and ftp_proxy_password 1174 environment variables. """ 1175 libxml2mod.xmlNanoFTPProxy(host, port, user, passwd, type)
1176
1177 -def nanoFTPScanProxy(URL):
1178 """(Re)Initialize the FTP Proxy context by parsing the URL and 1179 finding the protocol host port it indicates. Should be 1180 like ftp://myproxy/ or ftp://myproxy:3128/ A None URL 1181 cleans up proxy informations. """ 1182 libxml2mod.xmlNanoFTPScanProxy(URL)
1183 1184 # 1185 # Functions from module nanohttp 1186 # 1187
1188 -def nanoHTTPCleanup():
1189 """Cleanup the HTTP protocol layer. """ 1190 libxml2mod.xmlNanoHTTPCleanup()
1191
1192 -def nanoHTTPInit():
1193 """Initialize the HTTP protocol layer. Currently it just 1194 checks for proxy informations """ 1195 libxml2mod.xmlNanoHTTPInit()
1196
1197 -def nanoHTTPScanProxy(URL):
1198 """(Re)Initialize the HTTP Proxy context by parsing the URL 1199 and finding the protocol host port it indicates. Should be 1200 like http://myproxy/ or http://myproxy:3128/ A None URL 1201 cleans up proxy informations. """ 1202 libxml2mod.xmlNanoHTTPScanProxy(URL)
1203 1204 # 1205 # Functions from module parser 1206 # 1207
1208 -def createDocParserCtxt(cur):
1209 """Creates a parser context for an XML in-memory document. """ 1210 ret = libxml2mod.xmlCreateDocParserCtxt(cur) 1211 if ret is None:raise parserError('xmlCreateDocParserCtxt() failed') 1212 return parserCtxt(_obj=ret)
1213
1214 -def initParser():
1215 """Initialization function for the XML parser. This is not 1216 reentrant. Call once before processing in case of use in 1217 multithreaded programs. """ 1218 libxml2mod.xmlInitParser()
1219
1220 -def keepBlanksDefault(val):
1221 """Set and return the previous value for default blanks text 1222 nodes support. The 1.x version of the parser used an 1223 heuristic to try to detect ignorable white spaces. As a 1224 result the SAX callback was generating 1225 xmlSAX2IgnorableWhitespace() callbacks instead of 1226 characters() one, and when using the DOM output text nodes 1227 containing those blanks were not generated. The 2.x and 1228 later version will switch to the XML standard way and 1229 ignorableWhitespace() are only generated when running the 1230 parser in validating mode and when the current element 1231 doesn't allow CDATA or mixed content. This function is 1232 provided as a way to force the standard behavior on 1.X 1233 libs and to switch back to the old mode for compatibility 1234 when running 1.X client code on 2.X . Upgrade of 1.X code 1235 should be done by using xmlIsBlankNode() commodity 1236 function to detect the "empty" nodes generated. This value 1237 also affect autogeneration of indentation when saving code 1238 if blanks sections are kept, indentation is not generated. """ 1239 ret = libxml2mod.xmlKeepBlanksDefault(val) 1240 return ret
1241
1242 -def lineNumbersDefault(val):
1243 """Set and return the previous value for enabling line numbers 1244 in elements contents. This may break on old application 1245 and is turned off by default. """ 1246 ret = libxml2mod.xmlLineNumbersDefault(val) 1247 return ret
1248
1249 -def newParserCtxt():
1250 """Allocate and initialize a new parser context. """ 1251 ret = libxml2mod.xmlNewParserCtxt() 1252 if ret is None:raise parserError('xmlNewParserCtxt() failed') 1253 return parserCtxt(_obj=ret)
1254
1255 -def parseDTD(ExternalID, SystemID):
1256 """Load and parse an external subset. """ 1257 ret = libxml2mod.xmlParseDTD(ExternalID, SystemID) 1258 if ret is None:raise parserError('xmlParseDTD() failed') 1259 return xmlDtd(_obj=ret)
1260
1261 -def parseDoc(cur):
1262 """parse an XML in-memory document and build a tree. """ 1263 ret = libxml2mod.xmlParseDoc(cur) 1264 if ret is None:raise parserError('xmlParseDoc() failed') 1265 return xmlDoc(_obj=ret)
1266
1267 -def parseEntity(filename):
1268 """parse an XML external entity out of context and build a 1269 tree. [78] extParsedEnt ::= TextDecl? content This 1270 correspond to a "Well Balanced" chunk """ 1271 ret = libxml2mod.xmlParseEntity(filename) 1272 if ret is None:raise parserError('xmlParseEntity() failed') 1273 return xmlDoc(_obj=ret)
1274
1275 -def parseFile(filename):
1276 """parse an XML file and build a tree. Automatic support for 1277 ZLIB/Compress compressed document is provided by default 1278 if found at compile-time. """ 1279 ret = libxml2mod.xmlParseFile(filename) 1280 if ret is None:raise parserError('xmlParseFile() failed') 1281 return xmlDoc(_obj=ret)
1282
1283 -def parseMemory(buffer, size):
1284 """parse an XML in-memory block and build a tree. """ 1285 ret = libxml2mod.xmlParseMemory(buffer, size) 1286 if ret is None:raise parserError('xmlParseMemory() failed') 1287 return xmlDoc(_obj=ret)
1288
1289 -def pedanticParserDefault(val):
1290 """Set and return the previous value for enabling pedantic 1291 warnings. """ 1292 ret = libxml2mod.xmlPedanticParserDefault(val) 1293 return ret
1294
1295 -def readDoc(cur, URL, encoding, options):
1296 """parse an XML in-memory document and build a tree. """ 1297 ret = libxml2mod.xmlReadDoc(cur, URL, encoding, options) 1298 if ret is None:raise treeError('xmlReadDoc() failed') 1299 return xmlDoc(_obj=ret)
1300
1301 -def readFd(fd, URL, encoding, options):
1302 """parse an XML from a file descriptor and build a tree. NOTE 1303 that the file descriptor will not be closed when the 1304 reader is closed or reset. """ 1305 ret = libxml2mod.xmlReadFd(fd, URL, encoding, options) 1306 if ret is None:raise treeError('xmlReadFd() failed') 1307 return xmlDoc(_obj=ret)
1308
1309 -def readFile(filename, encoding, options):
1310 """parse an XML file from the filesystem or the network. """ 1311 ret = libxml2mod.xmlReadFile(filename, encoding, options) 1312 if ret is None:raise treeError('xmlReadFile() failed') 1313 return xmlDoc(_obj=ret)
1314
1315 -def readMemory(buffer, size, URL, encoding, options):
1316 """parse an XML in-memory document and build a tree. """ 1317 ret = libxml2mod.xmlReadMemory(buffer, size, URL, encoding, options) 1318 if ret is None:raise treeError('xmlReadMemory() failed') 1319 return xmlDoc(_obj=ret)
1320
1321 -def recoverDoc(cur):
1322 """parse an XML in-memory document and build a tree. In the 1323 case the document is not Well Formed, a tree is built 1324 anyway """ 1325 ret = libxml2mod.xmlRecoverDoc(cur) 1326 if ret is None:raise treeError('xmlRecoverDoc() failed') 1327 return xmlDoc(_obj=ret)
1328
1329 -def recoverFile(filename):
1330 """parse an XML file and build a tree. Automatic support for 1331 ZLIB/Compress compressed document is provided by default 1332 if found at compile-time. In the case the document is not 1333 Well Formed, a tree is built anyway """ 1334 ret = libxml2mod.xmlRecoverFile(filename) 1335 if ret is None:raise treeError('xmlRecoverFile() failed') 1336 return xmlDoc(_obj=ret)
1337
1338 -def recoverMemory(buffer, size):
1339 """parse an XML in-memory block and build a tree. In the case 1340 the document is not Well Formed, a tree is built anyway """ 1341 ret = libxml2mod.xmlRecoverMemory(buffer, size) 1342 if ret is None:raise treeError('xmlRecoverMemory() failed') 1343 return xmlDoc(_obj=ret)
1344
1345 -def substituteEntitiesDefault(val):
1346 """Set and return the previous value for default entity 1347 support. Initially the parser always keep entity 1348 references instead of substituting entity values in the 1349 output. This function has to be used to change the default 1350 parser behavior SAX::substituteEntities() has to be used 1351 for changing that on a file by file basis. """ 1352 ret = libxml2mod.xmlSubstituteEntitiesDefault(val) 1353 return ret
1354 1355 # 1356 # Functions from module parserInternals 1357 # 1358
1359 -def checkLanguageID(lang):
1360 """Checks that the value conforms to the LanguageID 1361 production: NOTE: this is somewhat deprecated, those 1362 productions were removed from the XML Second edition. 1363 [33] LanguageID ::= Langcode ('-' Subcode)* [34] Langcode 1364 ::= ISO639Code | IanaCode | UserCode [35] ISO639Code ::= 1365 ([a-z] | [A-Z]) ([a-z] | [A-Z]) [36] IanaCode ::= ('i' | 1366 'I') '-' ([a-z] | [A-Z])+ [37] UserCode ::= ('x' | 'X') 1367 '-' ([a-z] | [A-Z])+ [38] Subcode ::= ([a-z] | [A-Z])+ """ 1368 ret = libxml2mod.xmlCheckLanguageID(lang) 1369 return ret
1370
1371 -def copyChar(len, out, val):
1372 """append the char value in the array """ 1373 ret = libxml2mod.xmlCopyChar(len, out, val) 1374 return ret
1375
1376 -def copyCharMultiByte(out, val):
1377 """append the char value in the array """ 1378 ret = libxml2mod.xmlCopyCharMultiByte(out, val) 1379 return ret
1380
1381 -def createEntityParserCtxt(URL, ID, base):
1382 """Create a parser context for an external entity Automatic 1383 support for ZLIB/Compress compressed document is provided 1384 by default if found at compile-time. """ 1385 ret = libxml2mod.xmlCreateEntityParserCtxt(URL, ID, base) 1386 if ret is None:raise parserError('xmlCreateEntityParserCtxt() failed') 1387 return parserCtxt(_obj=ret)
1388
1389 -def createFileParserCtxt(filename):
1390 """Create a parser context for a file content. Automatic 1391 support for ZLIB/Compress compressed document is provided 1392 by default if found at compile-time. """ 1393 ret = libxml2mod.xmlCreateFileParserCtxt(filename) 1394 if ret is None:raise parserError('xmlCreateFileParserCtxt() failed') 1395 return parserCtxt(_obj=ret)
1396
1397 -def createMemoryParserCtxt(buffer, size):
1398 """Create a parser context for an XML in-memory document. """ 1399 ret = libxml2mod.xmlCreateMemoryParserCtxt(buffer, size) 1400 if ret is None:raise parserError('xmlCreateMemoryParserCtxt() failed') 1401 return parserCtxt(_obj=ret)
1402
1403 -def createURLParserCtxt(filename, options):
1404 """Create a parser context for a file or URL content. 1405 Automatic support for ZLIB/Compress compressed document is 1406 provided by default if found at compile-time and for file 1407 accesses """ 1408 ret = libxml2mod.xmlCreateURLParserCtxt(filename, options) 1409 if ret is None:raise parserError('xmlCreateURLParserCtxt() failed') 1410 return parserCtxt(_obj=ret)
1411
1412 -def htmlCreateFileParserCtxt(filename, encoding):
1413 """Create a parser context for a file content. Automatic 1414 support for ZLIB/Compress compressed document is provided 1415 by default if found at compile-time. """ 1416 ret = libxml2mod.htmlCreateFileParserCtxt(filename, encoding) 1417 if ret is None:raise parserError('htmlCreateFileParserCtxt() failed') 1418 return parserCtxt(_obj=ret)
1419
1420 -def htmlInitAutoClose():
1421 """Initialize the htmlStartCloseIndex for fast lookup of 1422 closing tags names. This is not reentrant. Call 1423 xmlInitParser() once before processing in case of use in 1424 multithreaded programs. """ 1425 libxml2mod.htmlInitAutoClose()
1426
1427 -def isLetter(c):
1428 """Check whether the character is allowed by the production 1429 [84] Letter ::= BaseChar | Ideographic """ 1430 ret = libxml2mod.xmlIsLetter(c) 1431 return ret
1432
1433 -def namePop(ctxt):
1434 """Pops the top element name from the name stack """ 1435 if ctxt is None: ctxt__o = None 1436 else: ctxt__o = ctxt._o 1437 ret = libxml2mod.namePop(ctxt__o) 1438 return ret
1439
1440 -def namePush(ctxt, value):
1441 """Pushes a new element name on top of the name stack """ 1442 if ctxt is None: ctxt__o = None 1443 else: ctxt__o = ctxt._o 1444 ret = libxml2mod.namePush(ctxt__o, value) 1445 return ret
1446
1447 -def nodePop(ctxt):
1448 """Pops the top element node from the node stack """ 1449 if ctxt is None: ctxt__o = None 1450 else: ctxt__o = ctxt._o 1451 ret = libxml2mod.nodePop(ctxt__o) 1452 if ret is None:raise treeError('nodePop() failed') 1453 return xmlNode(_obj=ret)
1454
1455 -def nodePush(ctxt, value):
1456 """Pushes a new element node on top of the node stack """ 1457 if ctxt is None: ctxt__o = None 1458 else: ctxt__o = ctxt._o 1459 if value is None: value__o = None 1460 else: value__o = value._o 1461 ret = libxml2mod.nodePush(ctxt__o, value__o) 1462 return ret
1463 1464 # 1465 # Functions from module python 1466 # 1467
1468 -def SAXParseFile(SAX, URI, recover):
1469 """Interface to parse an XML file or resource pointed by an 1470 URI to build an event flow to the SAX object """ 1471 libxml2mod.xmlSAXParseFile(SAX, URI, recover)
1472
1473 -def createInputBuffer(file, encoding):
1474 """Create a libxml2 input buffer from a Python file """ 1475 ret = libxml2mod.xmlCreateInputBuffer(file, encoding) 1476 if ret is None:raise treeError('xmlCreateInputBuffer() failed') 1477 return inputBuffer(_obj=ret)
1478
1479 -def createOutputBuffer(file, encoding):
1480 """Create a libxml2 output buffer from a Python file """ 1481 ret = libxml2mod.xmlCreateOutputBuffer(file, encoding) 1482 if ret is None:raise treeError('xmlCreateOutputBuffer() failed') 1483 return outputBuffer(_obj=ret)
1484
1485 -def createPushParser(SAX, chunk, size, URI):
1486 """Create a progressive XML parser context to build either an 1487 event flow if the SAX object is not None, or a DOM tree 1488 otherwise. """ 1489 ret = libxml2mod.xmlCreatePushParser(SAX, chunk, size, URI) 1490 if ret is None:raise parserError('xmlCreatePushParser() failed') 1491 return parserCtxt(_obj=ret)
1492
1493 -def debugMemory(activate):
1494 """Switch on the generation of line number for elements nodes. 1495 Also returns the number of bytes allocated and not freed 1496 by libxml2 since memory debugging was switched on. """ 1497 ret = libxml2mod.xmlDebugMemory(activate) 1498 return ret
1499
1500 -def dumpMemory():
1501 """dump the memory allocated in the file .memdump """ 1502 libxml2mod.xmlDumpMemory()
1503
1504 -def htmlCreatePushParser(SAX, chunk, size, URI):
1505 """Create a progressive HTML parser context to build either an 1506 event flow if the SAX object is not None, or a DOM tree 1507 otherwise. """ 1508 ret = libxml2mod.htmlCreatePushParser(SAX, chunk, size, URI) 1509 if ret is None:raise parserError('htmlCreatePushParser() failed') 1510 return parserCtxt(_obj=ret)
1511
1512 -def htmlSAXParseFile(SAX, URI, encoding):
1513 """Interface to parse an HTML file or resource pointed by an 1514 URI to build an event flow to the SAX object """ 1515 libxml2mod.htmlSAXParseFile(SAX, URI, encoding)
1516
1517 -def memoryUsed():
1518 """Returns the total amount of memory allocated by libxml2 """ 1519 ret = libxml2mod.xmlMemoryUsed() 1520 return ret
1521
1522 -def newNode(name):
1523 """Create a new Node """ 1524 ret = libxml2mod.xmlNewNode(name) 1525 if ret is None:raise treeError('xmlNewNode() failed') 1526 return xmlNode(_obj=ret)
1527
1528 -def pythonCleanupParser():
1529 """Cleanup function for the XML library. It tries to reclaim 1530 all parsing related global memory allocated for the 1531 library processing. It doesn't deallocate any document 1532 related memory. Calling this function should not prevent 1533 reusing the library but one should call xmlCleanupParser() 1534 only when the process has finished using the library or 1535 XML document built with it. """ 1536 libxml2mod.xmlPythonCleanupParser()
1537
1538 -def setEntityLoader(resolver):
1539 """Set the entity resolver as a python function """ 1540 ret = libxml2mod.xmlSetEntityLoader(resolver) 1541 return ret
1542 1543 # 1544 # Functions from module relaxng 1545 # 1546
1547 -def relaxNGCleanupTypes():
1548 """Cleanup the default Schemas type library associated to 1549 RelaxNG """ 1550 libxml2mod.xmlRelaxNGCleanupTypes()
1551
1552 -def relaxNGInitTypes():
1553 """Initilize the default type libraries. """ 1554 ret = libxml2mod.xmlRelaxNGInitTypes() 1555 return ret
1556
1557 -def relaxNGNewMemParserCtxt(buffer, size):
1558 """Create an XML RelaxNGs parse context for that memory buffer 1559 expected to contain an XML RelaxNGs file. """ 1560 ret = libxml2mod.xmlRelaxNGNewMemParserCtxt(buffer, size) 1561 if ret is None:raise parserError('xmlRelaxNGNewMemParserCtxt() failed') 1562 return relaxNgParserCtxt(_obj=ret)
1563
1564 -def relaxNGNewParserCtxt(URL):
1565 """Create an XML RelaxNGs parse context for that file/resource 1566 expected to contain an XML RelaxNGs file. """ 1567 ret = libxml2mod.xmlRelaxNGNewParserCtxt(URL) 1568 if ret is None:raise parserError('xmlRelaxNGNewParserCtxt() failed') 1569 return relaxNgParserCtxt(_obj=ret)
1570 1571 # 1572 # Functions from module tree 1573 # 1574
1575 -def buildQName(ncname, prefix, memory, len):
1576 """Builds the QName @prefix:@ncname in @memory if there is 1577 enough space and prefix is not None nor empty, otherwise 1578 allocate a new string. If prefix is None or empty it 1579 returns ncname. """ 1580 ret = libxml2mod.xmlBuildQName(ncname, prefix, memory, len) 1581 return ret
1582
1583 -def compressMode():
1584 """get the default compression mode used, ZLIB based. """ 1585 ret = libxml2mod.xmlGetCompressMode() 1586 return ret
1587
1588 -def isXHTML(systemID, publicID):
1589 """Try to find if the document correspond to an XHTML DTD """ 1590 ret = libxml2mod.xmlIsXHTML(systemID, publicID) 1591 return ret
1592
1593 -def newComment(content):
1594 """Creation of a new node containing a comment. """ 1595 ret = libxml2mod.xmlNewComment(content) 1596 if ret is None:raise treeError('xmlNewComment() failed') 1597 return xmlNode(_obj=ret)
1598
1599 -def newDoc(version):
1600 """Creates a new XML document """ 1601 ret = libxml2mod.xmlNewDoc(version) 1602 if ret is None:raise treeError('xmlNewDoc() failed') 1603 return xmlDoc(_obj=ret)
1604
1605 -def newPI(name, content):
1606 """Creation of a processing instruction element. Use 1607 xmlDocNewPI preferably to get string interning """ 1608 ret = libxml2mod.xmlNewPI(name, content) 1609 if ret is None:raise treeError('xmlNewPI() failed') 1610 return xmlNode(_obj=ret)
1611
1612 -def newText(content):
1613 """Creation of a new text node. """ 1614 ret = libxml2mod.xmlNewText(content) 1615 if ret is None:raise treeError('xmlNewText() failed') 1616 return xmlNode(_obj=ret)
1617
1618 -def newTextLen(content, len):
1619 """Creation of a new text node with an extra parameter for the 1620 content's length """ 1621 ret = libxml2mod.xmlNewTextLen(content, len) 1622 if ret is None:raise treeError('xmlNewTextLen() failed') 1623 return xmlNode(_obj=ret)
1624
1625 -def setCompressMode(mode):
1626 """set the default compression mode used, ZLIB based Correct 1627 values: 0 (uncompressed) to 9 (max compression) """ 1628 libxml2mod.xmlSetCompressMode(mode)
1629
1630 -def validateNCName(value, space):
1631 """Check that a value conforms to the lexical space of NCName """ 1632 ret = libxml2mod.xmlValidateNCName(value, space) 1633 return ret
1634
1635 -def validateNMToken(value, space):
1636 """Check that a value conforms to the lexical space of NMToken """ 1637 ret = libxml2mod.xmlValidateNMToken(value, space) 1638 return ret
1639
1640 -def validateName(value, space):
1641 """Check that a value conforms to the lexical space of Name """ 1642 ret = libxml2mod.xmlValidateName(value, space) 1643 return ret
1644
1645 -def validateQName(value, space):
1646 """Check that a value conforms to the lexical space of QName """ 1647 ret = libxml2mod.xmlValidateQName(value, space) 1648 return ret
1649 1650 # 1651 # Functions from module uri 1652 # 1653
1654 -def URIEscape(str):
1655 """Escaping routine, does not do validity checks ! It will try 1656 to escape the chars needing this, but this is heuristic 1657 based it's impossible to be sure. """ 1658 ret = libxml2mod.xmlURIEscape(str) 1659 return ret
1660
1661 -def URIEscapeStr(str, list):
1662 """This routine escapes a string to hex, ignoring reserved 1663 characters (a-z) and the characters in the exception list. """ 1664 ret = libxml2mod.xmlURIEscapeStr(str, list) 1665 return ret
1666
1667 -def URIUnescapeString(str, len, target):
1668 """Unescaping routine, but does not check that the string is 1669 an URI. The output is a direct unsigned char translation 1670 of %XX values (no encoding) Note that the length of the 1671 result can only be smaller or same size as the input 1672 string. """ 1673 ret = libxml2mod.xmlURIUnescapeString(str, len, target) 1674 return ret
1675
1676 -def buildRelativeURI(URI, base):
1677 """Expresses the URI of the reference in terms relative to the 1678 base. Some examples of this operation include: base = 1679 "http://site1.com/docs/book1.html" URI input 1680 URI returned docs/pic1.gif 1681 pic1.gif docs/img/pic1.gif img/pic1.gif 1682 img/pic1.gif ../img/pic1.gif 1683 http://site1.com/docs/pic1.gif pic1.gif 1684 http://site2.com/docs/pic1.gif 1685 http://site2.com/docs/pic1.gif base = "docs/book1.html" 1686 URI input URI returned 1687 docs/pic1.gif pic1.gif 1688 docs/img/pic1.gif img/pic1.gif img/pic1.gif 1689 ../img/pic1.gif 1690 http://site1.com/docs/pic1.gif 1691 http://site1.com/docs/pic1.gif Note: if the URI 1692 reference is really wierd or complicated, it may be 1693 worthwhile to first convert it into a "nice" one by 1694 calling xmlBuildURI (using 'base') before calling this 1695 routine, since this routine (for reasonable efficiency) 1696 assumes URI has already been through some validation. """ 1697 ret = libxml2mod.xmlBuildRelativeURI(URI, base) 1698 return ret
1699
1700 -def buildURI(URI, base):
1701 """Computes he final URI of the reference done by checking 1702 that the given URI is valid, and building the final URI 1703 using the base URI. This is processed according to section 1704 5.2 of the RFC 2396 5.2. Resolving Relative References to 1705 Absolute Form """ 1706 ret = libxml2mod.xmlBuildURI(URI, base) 1707 return ret
1708
1709 -def canonicPath(path):
1710 """Constructs a canonic path from the specified path. """ 1711 ret = libxml2mod.xmlCanonicPath(path) 1712 return ret
1713
1714 -def createURI():
1715 """Simply creates an empty xmlURI """ 1716 ret = libxml2mod.xmlCreateURI() 1717 if ret is None:raise uriError('xmlCreateURI() failed') 1718 return URI(_obj=ret)
1719
1720 -def normalizeURIPath(path):
1721 """Applies the 5 normalization steps to a path string--that 1722 is, RFC 2396 Section 5.2, steps 6.c through 6.g. 1723 Normalization occurs directly on the string, no new 1724 allocation is done """ 1725 ret = libxml2mod.xmlNormalizeURIPath(path) 1726 return ret
1727
1728 -def parseURI(str):
1729 """Parse an URI URI-reference = [ absoluteURI | relativeURI ] 1730 [ "#" fragment ] """ 1731 ret = libxml2mod.xmlParseURI(str) 1732 if ret is None:raise uriError('xmlParseURI() failed') 1733 return URI(_obj=ret)
1734
1735 -def parseURIRaw(str, raw):
1736 """Parse an URI but allows to keep intact the original 1737 fragments. URI-reference = [ absoluteURI | relativeURI ] 1738 [ "#" fragment ] """ 1739 ret = libxml2mod.xmlParseURIRaw(str, raw) 1740 if ret is None:raise uriError('xmlParseURIRaw() failed') 1741 return URI(_obj=ret)
1742
1743 -def pathToURI(path):
1744 """Constructs an URI expressing the existing path """ 1745 ret = libxml2mod.xmlPathToURI(path) 1746 return ret
1747 1748 # 1749 # Functions from module valid 1750 # 1751
1752 -def newValidCtxt():
1753 """Allocate a validation context structure. """ 1754 ret = libxml2mod.xmlNewValidCtxt() 1755 if ret is None:raise treeError('xmlNewValidCtxt() failed') 1756 return ValidCtxt(_obj=ret)
1757
1758 -def validateNameValue(value):
1759 """Validate that the given value match Name production """ 1760 ret = libxml2mod.xmlValidateNameValue(value) 1761 return ret
1762
1763 -def validateNamesValue(value):
1764 """Validate that the given value match Names production """ 1765 ret = libxml2mod.xmlValidateNamesValue(value) 1766 return ret
1767
1768 -def validateNmtokenValue(value):
1769 """Validate that the given value match Nmtoken production [ 1770 VC: Name Token ] """ 1771 ret = libxml2mod.xmlValidateNmtokenValue(value) 1772 return ret
1773
1774 -def validateNmtokensValue(value):
1775 """Validate that the given value match Nmtokens production [ 1776 VC: Name Token ] """ 1777 ret = libxml2mod.xmlValidateNmtokensValue(value) 1778 return ret
1779 1780 # 1781 # Functions from module xmlIO 1782 # 1783
1784 -def checkFilename(path):
1785 """function checks to see if @path is a valid source (file, 1786 socket...) for XML. if stat is not available on the 1787 target machine, """ 1788 ret = libxml2mod.xmlCheckFilename(path) 1789 return ret
1790
1791 -def cleanupInputCallbacks():
1792 """clears the entire input callback table. this includes the 1793 compiled-in I/O. """ 1794 libxml2mod.xmlCleanupInputCallbacks()
1795
1796 -def cleanupOutputCallbacks():
1797 """clears the entire output callback table. this includes the 1798 compiled-in I/O callbacks. """ 1799 libxml2mod.xmlCleanupOutputCallbacks()
1800
1801 -def fileMatch(filename):
1802 """input from FILE * """ 1803 ret = libxml2mod.xmlFileMatch(filename) 1804 return ret
1805
1806 -def iOFTPMatch(filename):
1807 """check if the URI matches an FTP one """ 1808 ret = libxml2mod.xmlIOFTPMatch(filename) 1809 return ret
1810
1811 -def iOHTTPMatch(filename):
1812 """check if the URI matches an HTTP one """ 1813 ret = libxml2mod.xmlIOHTTPMatch(filename) 1814 return ret
1815
1816 -def normalizeWindowsPath(path):
1817 """This function is obsolete. Please see xmlURIFromPath in 1818 uri.c for a better solution. """ 1819 ret = libxml2mod.xmlNormalizeWindowsPath(path) 1820 return ret
1821
1822 -def parserGetDirectory(filename):
1823 """lookup the directory for that file """ 1824 ret = libxml2mod.xmlParserGetDirectory(filename) 1825 return ret
1826
1827 -def popInputCallbacks():
1828 """Clear the top input callback from the input stack. this 1829 includes the compiled-in I/O. """ 1830 ret = libxml2mod.xmlPopInputCallbacks() 1831 return ret
1832
1833 -def registerDefaultInputCallbacks():
1834 """Registers the default compiled-in I/O handlers. """ 1835 libxml2mod.xmlRegisterDefaultInputCallbacks()
1836
1837 -def registerDefaultOutputCallbacks():
1838 """Registers the default compiled-in I/O handlers. """ 1839 libxml2mod.xmlRegisterDefaultOutputCallbacks()
1840
1841 -def registerHTTPPostCallbacks():
1842 """By default, libxml submits HTTP output requests using the 1843 "PUT" method. Calling this method changes the HTTP output 1844 method to use the "POST" method instead. """ 1845 libxml2mod.xmlRegisterHTTPPostCallbacks()
1846 1847 # 1848 # Functions from module xmlerror 1849 # 1850
1851 -def lastError():
1852 """Get the last global error registered. This is per thread if 1853 compiled with thread support. """ 1854 ret = libxml2mod.xmlGetLastError() 1855 if ret is None:raise treeError('xmlGetLastError() failed') 1856 return Error(_obj=ret)
1857
1858 -def resetLastError():
1859 """Cleanup the last global error registered. For parsing error 1860 this does not change the well-formedness result. """ 1861 libxml2mod.xmlResetLastError()
1862 1863 # 1864 # Functions from module xmlreader 1865 # 1866
1867 -def newTextReaderFilename(URI):
1868 """Create an xmlTextReader structure fed with the resource at 1869 @URI """ 1870 ret = libxml2mod.xmlNewTextReaderFilename(URI) 1871 if ret is None:raise treeError('xmlNewTextReaderFilename() failed') 1872 return xmlTextReader(_obj=ret)
1873
1874 -def readerForDoc(cur, URL, encoding, options):
1875 """Create an xmltextReader for an XML in-memory document. The 1876 parsing flags @options are a combination of 1877 xmlParserOption. """ 1878 ret = libxml2mod.xmlReaderForDoc(cur, URL, encoding, options) 1879 if ret is None:raise treeError('xmlReaderForDoc() failed') 1880 return xmlTextReader(_obj=ret)
1881
1882 -def readerForFd(fd, URL, encoding, options):
1883 """Create an xmltextReader for an XML from a file descriptor. 1884 The parsing flags @options are a combination of 1885 xmlParserOption. NOTE that the file descriptor will not be 1886 closed when the reader is closed or reset. """ 1887 ret = libxml2mod.xmlReaderForFd(fd, URL, encoding, options) 1888 if ret is None:raise treeError('xmlReaderForFd() failed') 1889 return xmlTextReader(_obj=ret)
1890
1891 -def readerForFile(filename, encoding, options):
1892 """parse an XML file from the filesystem or the network. The 1893 parsing flags @options are a combination of 1894 xmlParserOption. """ 1895 ret = libxml2mod.xmlReaderForFile(filename, encoding, options) 1896 if ret is None:raise treeError('xmlReaderForFile() failed') 1897 return xmlTextReader(_obj=ret)
1898
1899 -def readerForMemory(buffer, size, URL, encoding, options):
1900 """Create an xmltextReader for an XML in-memory document. The 1901 parsing flags @options are a combination of 1902 xmlParserOption. """ 1903 ret = libxml2mod.xmlReaderForMemory(buffer, size, URL, encoding, options) 1904 if ret is None:raise treeError('xmlReaderForMemory() failed') 1905 return xmlTextReader(_obj=ret)
1906 1907 # 1908 # Functions from module xmlregexp 1909 # 1910
1911 -def regexpCompile(regexp):
1912 """Parses a regular expression conforming to XML Schemas Part 1913 2 Datatype Appendix F and builds an automata suitable for 1914 testing strings against that regular expression """ 1915 ret = libxml2mod.xmlRegexpCompile(regexp) 1916 if ret is None:raise treeError('xmlRegexpCompile() failed') 1917 return xmlReg(_obj=ret)
1918 1919 # 1920 # Functions from module xmlschemas 1921 # 1922
1923 -def schemaNewMemParserCtxt(buffer, size):
1924 """Create an XML Schemas parse context for that memory buffer 1925 expected to contain an XML Schemas file. """ 1926 ret = libxml2mod.xmlSchemaNewMemParserCtxt(buffer, size) 1927 if ret is None:raise parserError('xmlSchemaNewMemParserCtxt() failed') 1928 return SchemaParserCtxt(_obj=ret)
1929
1930 -def schemaNewParserCtxt(URL):
1931 """Create an XML Schemas parse context for that file/resource 1932 expected to contain an XML Schemas file. """ 1933 ret = libxml2mod.xmlSchemaNewParserCtxt(URL) 1934 if ret is None:raise parserError('xmlSchemaNewParserCtxt() failed') 1935 return SchemaParserCtxt(_obj=ret)
1936 1937 # 1938 # Functions from module xmlschemastypes 1939 # 1940
1941 -def schemaCleanupTypes():
1942 """Cleanup the default XML Schemas type library """ 1943 libxml2mod.xmlSchemaCleanupTypes()
1944
1945 -def schemaCollapseString(value):
1946 """Removes and normalize white spaces in the string """ 1947 ret = libxml2mod.xmlSchemaCollapseString(value) 1948 return ret
1949
1950 -def schemaInitTypes():
1951 """Initialize the default XML Schemas type library """ 1952 libxml2mod.xmlSchemaInitTypes()
1953
1954 -def schemaWhiteSpaceReplace(value):
1955 """Replaces 0xd, 0x9 and 0xa with a space. """ 1956 ret = libxml2mod.xmlSchemaWhiteSpaceReplace(value) 1957 return ret
1958 1959 # 1960 # Functions from module xmlstring 1961 # 1962
1963 -def UTF8Charcmp(utf1, utf2):
1964 """compares the two UCS4 values """ 1965 ret = libxml2mod.xmlUTF8Charcmp(utf1, utf2) 1966 return ret
1967
1968 -def UTF8Size(utf):
1969 """calculates the internal size of a UTF8 character """ 1970 ret = libxml2mod.xmlUTF8Size(utf) 1971 return ret
1972
1973 -def UTF8Strlen(utf):
1974 """compute the length of an UTF8 string, it doesn't do a full 1975 UTF8 checking of the content of the string. """ 1976 ret = libxml2mod.xmlUTF8Strlen(utf) 1977 return ret
1978
1979 -def UTF8Strloc(utf, utfchar):
1980 """a function to provide the relative location of a UTF8 char """ 1981 ret = libxml2mod.xmlUTF8Strloc(utf, utfchar) 1982 return ret
1983
1984 -def UTF8Strndup(utf, len):
1985 """a strndup for array of UTF8's """ 1986 ret = libxml2mod.xmlUTF8Strndup(utf, len) 1987 return ret
1988
1989 -def UTF8Strpos(utf, pos):
1990 """a function to provide the equivalent of fetching a 1991 character from a string array """ 1992 ret = libxml2mod.xmlUTF8Strpos(utf, pos) 1993 return ret
1994
1995 -def UTF8Strsize(utf, len):
1996 """storage size of an UTF8 string the behaviour is not 1997 garanteed if the input string is not UTF-8 """ 1998 ret = libxml2mod.xmlUTF8Strsize(utf, len) 1999 return ret
2000
2001 -def UTF8Strsub(utf, start, len):
2002 """Create a substring from a given UTF-8 string Note: 2003 positions are given in units of UTF-8 chars """ 2004 ret = libxml2mod.xmlUTF8Strsub(utf, start, len) 2005 return ret
2006
2007 -def checkUTF8(utf):
2008 """Checks @utf for being valid UTF-8. @utf is assumed to be 2009 null-terminated. This function is not super-strict, as it 2010 will allow longer UTF-8 sequences than necessary. Note 2011 that Java is capable of producing these sequences if 2012 provoked. Also note, this routine checks for the 4-byte 2013 maximum size, but does not check for 0x10ffff maximum 2014 value. """ 2015 ret = libxml2mod.xmlCheckUTF8(utf) 2016 return ret
2017 2018 # 2019 # Functions from module xmlunicode 2020 # 2021
2022 -def uCSIsAegeanNumbers(code):
2023 """Check whether the character is part of AegeanNumbers UCS 2024 Block """ 2025 ret = libxml2mod.xmlUCSIsAegeanNumbers(code) 2026 return ret
2027
2028 -def uCSIsAlphabeticPresentationForms(code):
2029 """Check whether the character is part of 2030 AlphabeticPresentationForms UCS Block """ 2031 ret = libxml2mod.xmlUCSIsAlphabeticPresentationForms(code) 2032 return ret
2033
2034 -def uCSIsArabic(code):
2035 """Check whether the character is part of Arabic UCS Block """ 2036 ret = libxml2mod.xmlUCSIsArabic(code) 2037 return ret
2038
2039 -def uCSIsArabicPresentationFormsA(code):
2040 """Check whether the character is part of 2041 ArabicPresentationForms-A UCS Block """ 2042 ret = libxml2mod.xmlUCSIsArabicPresentationFormsA(code) 2043 return ret
2044
2045 -def uCSIsArabicPresentationFormsB(code):
2046 """Check whether the character is part of 2047 ArabicPresentationForms-B UCS Block """ 2048 ret = libxml2mod.xmlUCSIsArabicPresentationFormsB(code) 2049 return ret
2050
2051 -def uCSIsArmenian(code):
2052 """Check whether the character is part of Armenian UCS Block """ 2053 ret = libxml2mod.xmlUCSIsArmenian(code) 2054 return ret
2055
2056 -def uCSIsArrows(code):
2057 """Check whether the character is part of Arrows UCS Block """ 2058 ret = libxml2mod.xmlUCSIsArrows(code) 2059 return ret
2060
2061 -def uCSIsBasicLatin(code):
2062 """Check whether the character is part of BasicLatin UCS Block """ 2063 ret = libxml2mod.xmlUCSIsBasicLatin(code) 2064 return ret
2065
2066 -def uCSIsBengali(code):
2067 """Check whether the character is part of Bengali UCS Block """ 2068 ret = libxml2mod.xmlUCSIsBengali(code) 2069 return ret
2070
2071 -def uCSIsBlock(code, block):
2072 """Check whether the character is part of the UCS Block """ 2073 ret = libxml2mod.xmlUCSIsBlock(code, block) 2074 return ret
2075
2076 -def uCSIsBlockElements(code):
2077 """Check whether the character is part of BlockElements UCS 2078 Block """ 2079 ret = libxml2mod.xmlUCSIsBlockElements(code) 2080 return ret
2081
2082 -def uCSIsBopomofo(code):
2083 """Check whether the character is part of Bopomofo UCS Block """ 2084 ret = libxml2mod.xmlUCSIsBopomofo(code) 2085 return ret
2086
2087 -def uCSIsBopomofoExtended(code):
2088 """Check whether the character is part of BopomofoExtended UCS 2089 Block """ 2090 ret = libxml2mod.xmlUCSIsBopomofoExtended(code) 2091 return ret
2092
2093 -def uCSIsBoxDrawing(code):
2094 """Check whether the character is part of BoxDrawing UCS Block """ 2095 ret = libxml2mod.xmlUCSIsBoxDrawing(code) 2096 return ret
2097
2098 -def uCSIsBraillePatterns(code):
2099 """Check whether the character is part of BraillePatterns UCS 2100 Block """ 2101 ret = libxml2mod.xmlUCSIsBraillePatterns(code) 2102 return ret
2103
2104 -def uCSIsBuhid(code):
2105 """Check whether the character is part of Buhid UCS Block """ 2106 ret = libxml2mod.xmlUCSIsBuhid(code) 2107 return ret
2108
2109 -def uCSIsByzantineMusicalSymbols(code):
2110 """Check whether the character is part of 2111 ByzantineMusicalSymbols UCS Block """ 2112 ret = libxml2mod.xmlUCSIsByzantineMusicalSymbols(code) 2113 return ret
2114
2115 -def uCSIsCJKCompatibility(code):
2116 """Check whether the character is part of CJKCompatibility UCS 2117 Block """ 2118 ret = libxml2mod.xmlUCSIsCJKCompatibility(code) 2119 return ret
2120
2121 -def uCSIsCJKCompatibilityForms(code):
2122 """Check whether the character is part of 2123 CJKCompatibilityForms UCS Block """ 2124 ret = libxml2mod.xmlUCSIsCJKCompatibilityForms(code) 2125 return ret
2126
2127 -def uCSIsCJKCompatibilityIdeographs(code):
2128 """Check whether the character is part of 2129 CJKCompatibilityIdeographs UCS Block """ 2130 ret = libxml2mod.xmlUCSIsCJKCompatibilityIdeographs(code) 2131 return ret
2132
2133 -def uCSIsCJKCompatibilityIdeographsSupplement(code):
2134 """Check whether the character is part of 2135 CJKCompatibilityIdeographsSupplement UCS Block """ 2136 ret = libxml2mod.xmlUCSIsCJKCompatibilityIdeographsSupplement(code) 2137 return ret
2138
2139 -def uCSIsCJKRadicalsSupplement(code):
2140 """Check whether the character is part of 2141 CJKRadicalsSupplement UCS Block """ 2142 ret = libxml2mod.xmlUCSIsCJKRadicalsSupplement(code) 2143 return ret
2144
2145 -def uCSIsCJKSymbolsandPunctuation(code):
2146 """Check whether the character is part of 2147 CJKSymbolsandPunctuation UCS Block """ 2148 ret = libxml2mod.xmlUCSIsCJKSymbolsandPunctuation(code) 2149 return ret
2150
2151 -def uCSIsCJKUnifiedIdeographs(code):
2152 """Check whether the character is part of CJKUnifiedIdeographs 2153 UCS Block """ 2154 ret = libxml2mod.xmlUCSIsCJKUnifiedIdeographs(code) 2155 return ret
2156
2157 -def uCSIsCJKUnifiedIdeographsExtensionA(code):
2158 """Check whether the character is part of 2159 CJKUnifiedIdeographsExtensionA UCS Block """ 2160 ret = libxml2mod.xmlUCSIsCJKUnifiedIdeographsExtensionA(code) 2161 return ret
2162
2163 -def uCSIsCJKUnifiedIdeographsExtensionB(code):
2164 """Check whether the character is part of 2165 CJKUnifiedIdeographsExtensionB UCS Block """ 2166 ret = libxml2mod.xmlUCSIsCJKUnifiedIdeographsExtensionB(code) 2167 return ret
2168
2169 -def uCSIsCat(code, cat):
2170 """Check whether the character is part of the UCS Category """ 2171 ret = libxml2mod.xmlUCSIsCat(code, cat) 2172 return ret
2173
2174 -def uCSIsCatC(code):
2175 """Check whether the character is part of C UCS Category """ 2176 ret = libxml2mod.xmlUCSIsCatC(code) 2177 return ret
2178
2179 -def uCSIsCatCc(code):
2180 """Check whether the character is part of Cc UCS Category """ 2181 ret = libxml2mod.xmlUCSIsCatCc(code) 2182 return ret
2183
2184 -def uCSIsCatCf(code):
2185 """Check whether the character is part of Cf UCS Category """ 2186 ret = libxml2mod.xmlUCSIsCatCf(code) 2187 return ret
2188
2189 -def uCSIsCatCo(code):
2190 """Check whether the character is part of Co UCS Category """ 2191 ret = libxml2mod.xmlUCSIsCatCo(code) 2192 return ret
2193
2194 -def uCSIsCatCs(code):
2195 """Check whether the character is part of Cs UCS Category """ 2196 ret = libxml2mod.xmlUCSIsCatCs(code) 2197 return ret
2198
2199 -def uCSIsCatL(code):
2200 """Check whether the character is part of L UCS Category """ 2201 ret = libxml2mod.xmlUCSIsCatL(code) 2202 return ret
2203
2204 -def uCSIsCatLl(code):
2205 """Check whether the character is part of Ll UCS Category """ 2206 ret = libxml2mod.xmlUCSIsCatLl(code) 2207 return ret
2208
2209 -def uCSIsCatLm(code):
2210 """Check whether the character is part of Lm UCS Category """ 2211 ret = libxml2mod.xmlUCSIsCatLm(code) 2212 return ret
2213
2214 -def uCSIsCatLo(code):
2215 """Check whether the character is part of Lo UCS Category """ 2216 ret = libxml2mod.xmlUCSIsCatLo(code) 2217 return ret
2218
2219 -def uCSIsCatLt(code):
2220 """Check whether the character is part of Lt UCS Category """ 2221 ret = libxml2mod.xmlUCSIsCatLt(code) 2222 return ret
2223
2224 -def uCSIsCatLu(code):
2225 """Check whether the character is part of Lu UCS Category """ 2226 ret = libxml2mod.xmlUCSIsCatLu(code) 2227 return ret
2228
2229 -def uCSIsCatM(code):
2230 """Check whether the character is part of M UCS Category """ 2231 ret = libxml2mod.xmlUCSIsCatM(code) 2232 return ret
2233
2234 -def uCSIsCatMc(code):
2235 """Check whether the character is part of Mc UCS Category """ 2236 ret = libxml2mod.xmlUCSIsCatMc(code) 2237 return ret
2238
2239 -def uCSIsCatMe(code):
2240 """Check whether the character is part of Me UCS Category """ 2241 ret = libxml2mod.xmlUCSIsCatMe(code) 2242 return ret
2243
2244 -def uCSIsCatMn(code):
2245 """Check whether the character is part of Mn UCS Category """ 2246 ret = libxml2mod.xmlUCSIsCatMn(code) 2247 return ret
2248
2249 -def uCSIsCatN(code):
2250 """Check whether the character is part of N UCS Category """ 2251 ret = libxml2mod.xmlUCSIsCatN(code) 2252 return ret
2253
2254 -def uCSIsCatNd(code):
2255 """Check whether the character is part of Nd UCS Category """ 2256 ret = libxml2mod.xmlUCSIsCatNd(code) 2257 return ret
2258
2259 -def uCSIsCatNl(code):
2260 """Check whether the character is part of Nl UCS Category """ 2261 ret = libxml2mod.xmlUCSIsCatNl(code) 2262 return ret
2263
2264 -def uCSIsCatNo(code):
2265 """Check whether the character is part of No UCS Category """ 2266 ret = libxml2mod.xmlUCSIsCatNo(code) 2267 return ret
2268
2269 -def uCSIsCatP(code):
2270 """Check whether the character is part of P UCS Category """ 2271 ret = libxml2mod.xmlUCSIsCatP(code) 2272 return ret
2273
2274 -def uCSIsCatPc(code):
2275 """Check whether the character is part of Pc UCS Category """ 2276 ret = libxml2mod.xmlUCSIsCatPc(code) 2277 return ret
2278
2279 -def uCSIsCatPd(code):
2280 """Check whether the character is part of Pd UCS Category """ 2281 ret = libxml2mod.xmlUCSIsCatPd(code) 2282 return ret
2283
2284 -def uCSIsCatPe(code):
2285 """Check whether the character is part of Pe UCS Category """ 2286 ret = libxml2mod.xmlUCSIsCatPe(code) 2287 return ret
2288
2289 -def uCSIsCatPf(code):
2290 """Check whether the character is part of Pf UCS Category """ 2291 ret = libxml2mod.xmlUCSIsCatPf(code) 2292 return ret
2293
2294 -def uCSIsCatPi(code):
2295 """Check whether the character is part of Pi UCS Category """ 2296 ret = libxml2mod.xmlUCSIsCatPi(code) 2297 return ret
2298
2299 -def uCSIsCatPo(code):
2300 """Check whether the character is part of Po UCS Category """ 2301 ret = libxml2mod.xmlUCSIsCatPo(code) 2302 return ret
2303
2304 -def uCSIsCatPs(code):
2305 """Check whether the character is part of Ps UCS Category """ 2306 ret = libxml2mod.xmlUCSIsCatPs(code) 2307 return ret
2308
2309 -def uCSIsCatS(code):
2310 """Check whether the character is part of S UCS Category """ 2311 ret = libxml2mod.xmlUCSIsCatS(code) 2312 return ret
2313
2314 -def uCSIsCatSc(code):
2315 """Check whether the character is part of Sc UCS Category """ 2316 ret = libxml2mod.xmlUCSIsCatSc(code) 2317 return ret
2318
2319 -def uCSIsCatSk(code):
2320 """Check whether the character is part of Sk UCS Category """ 2321 ret = libxml2mod.xmlUCSIsCatSk(code) 2322 return ret
2323
2324 -def uCSIsCatSm(code):
2325 """Check whether the character is part of Sm UCS Category """ 2326 ret = libxml2mod.xmlUCSIsCatSm(code) 2327 return ret
2328
2329 -def uCSIsCatSo(code):
2330 """Check whether the character is part of So UCS Category """ 2331 ret = libxml2mod.xmlUCSIsCatSo(code) 2332 return ret
2333
2334 -def uCSIsCatZ(code):
2335 """Check whether the character is part of Z UCS Category """ 2336 ret = libxml2mod.xmlUCSIsCatZ(code) 2337 return ret
2338
2339 -def uCSIsCatZl(code):
2340 """Check whether the character is part of Zl UCS Category """ 2341 ret = libxml2mod.xmlUCSIsCatZl(code) 2342 return ret
2343
2344 -def uCSIsCatZp(code):
2345 """Check whether the character is part of Zp UCS Category """ 2346 ret = libxml2mod.xmlUCSIsCatZp(code) 2347 return ret
2348
2349 -def uCSIsCatZs(code):
2350 """Check whether the character is part of Zs UCS Category """ 2351 ret = libxml2mod.xmlUCSIsCatZs(code) 2352 return ret
2353
2354 -def uCSIsCherokee(code):
2355 """Check whether the character is part of Cherokee UCS Block """ 2356 ret = libxml2mod.xmlUCSIsCherokee(code) 2357 return ret
2358
2359 -def uCSIsCombiningDiacriticalMarks(code):
2360 """Check whether the character is part of 2361 CombiningDiacriticalMarks UCS Block """ 2362 ret = libxml2mod.xmlUCSIsCombiningDiacriticalMarks(code) 2363 return ret
2364
2365 -def uCSIsCombiningDiacriticalMarksforSymbols(code):
2366 """Check whether the character is part of 2367 CombiningDiacriticalMarksforSymbols UCS Block """ 2368 ret = libxml2mod.xmlUCSIsCombiningDiacriticalMarksforSymbols(code) 2369 return ret
2370
2371 -def uCSIsCombiningHalfMarks(code):
2372 """Check whether the character is part of CombiningHalfMarks 2373 UCS Block """ 2374 ret = libxml2mod.xmlUCSIsCombiningHalfMarks(code) 2375 return ret
2376
2377 -def uCSIsCombiningMarksforSymbols(code):
2378 """Check whether the character is part of 2379 CombiningMarksforSymbols UCS Block """ 2380 ret = libxml2mod.xmlUCSIsCombiningMarksforSymbols(code) 2381 return ret
2382
2383 -def uCSIsControlPictures(code):
2384 """Check whether the character is part of ControlPictures UCS 2385 Block """ 2386 ret = libxml2mod.xmlUCSIsControlPictures(code) 2387 return ret
2388
2389 -def uCSIsCurrencySymbols(code):
2390 """Check whether the character is part of CurrencySymbols UCS 2391 Block """ 2392 ret = libxml2mod.xmlUCSIsCurrencySymbols(code) 2393 return ret
2394
2395 -def uCSIsCypriotSyllabary(code):
2396 """Check whether the character is part of CypriotSyllabary UCS 2397 Block """ 2398 ret = libxml2mod.xmlUCSIsCypriotSyllabary(code) 2399 return ret
2400
2401 -def uCSIsCyrillic(code):
2402 """Check whether the character is part of Cyrillic UCS Block """ 2403 ret = libxml2mod.xmlUCSIsCyrillic(code) 2404 return ret
2405
2406 -def uCSIsCyrillicSupplement(code):
2407 """Check whether the character is part of CyrillicSupplement 2408 UCS Block """ 2409 ret = libxml2mod.xmlUCSIsCyrillicSupplement(code) 2410 return ret
2411
2412 -def uCSIsDeseret(code):
2413 """Check whether the character is part of Deseret UCS Block """ 2414 ret = libxml2mod.xmlUCSIsDeseret(code) 2415 return ret
2416
2417 -def uCSIsDevanagari(code):
2418 """Check whether the character is part of Devanagari UCS Block """ 2419 ret = libxml2mod.xmlUCSIsDevanagari(code) 2420 return ret
2421
2422 -def uCSIsDingbats(code):
2423 """Check whether the character is part of Dingbats UCS Block """ 2424 ret = libxml2mod.xmlUCSIsDingbats(code) 2425 return ret
2426
2427 -def uCSIsEnclosedAlphanumerics(code):
2428 """Check whether the character is part of 2429 EnclosedAlphanumerics UCS Block """ 2430 ret = libxml2mod.xmlUCSIsEnclosedAlphanumerics(code) 2431 return ret
2432
2433 -def uCSIsEnclosedCJKLettersandMonths(code):
2434 """Check whether the character is part of 2435 EnclosedCJKLettersandMonths UCS Block """ 2436 ret = libxml2mod.xmlUCSIsEnclosedCJKLettersandMonths(code) 2437 return ret
2438
2439 -def uCSIsEthiopic(code):
2440 """Check whether the character is part of Ethiopic UCS Block """ 2441 ret = libxml2mod.xmlUCSIsEthiopic(code) 2442 return ret
2443
2444 -def uCSIsGeneralPunctuation(code):
2445 """Check whether the character is part of GeneralPunctuation 2446 UCS Block """ 2447 ret = libxml2mod.xmlUCSIsGeneralPunctuation(code) 2448 return ret
2449
2450 -def uCSIsGeometricShapes(code):
2451 """Check whether the character is part of GeometricShapes UCS 2452 Block """ 2453 ret = libxml2mod.xmlUCSIsGeometricShapes(code) 2454 return ret
2455
2456 -def uCSIsGeorgian(code):
2457 """Check whether the character is part of Georgian UCS Block """ 2458 ret = libxml2mod.xmlUCSIsGeorgian(code) 2459 return ret
2460
2461 -def uCSIsGothic(code):
2462 """Check whether the character is part of Gothic UCS Block """ 2463 ret = libxml2mod.xmlUCSIsGothic(code) 2464 return ret
2465
2466 -def uCSIsGreek(code):
2467 """Check whether the character is part of Greek UCS Block """ 2468 ret = libxml2mod.xmlUCSIsGreek(code) 2469 return ret
2470
2471 -def uCSIsGreekExtended(code):
2472 """Check whether the character is part of GreekExtended UCS 2473 Block """ 2474 ret = libxml2mod.xmlUCSIsGreekExtended(code) 2475 return ret
2476
2477 -def uCSIsGreekandCoptic(code):
2478 """Check whether the character is part of GreekandCoptic UCS 2479 Block """ 2480 ret = libxml2mod.xmlUCSIsGreekandCoptic(code) 2481 return ret
2482
2483 -def uCSIsGujarati(code):
2484 """Check whether the character is part of Gujarati UCS Block """ 2485 ret = libxml2mod.xmlUCSIsGujarati(code) 2486 return ret
2487
2488 -def uCSIsGurmukhi(code):
2489 """Check whether the character is part of Gurmukhi UCS Block """ 2490 ret = libxml2mod.xmlUCSIsGurmukhi(code) 2491 return ret
2492
2493 -def uCSIsHalfwidthandFullwidthForms(code):
2494 """Check whether the character is part of 2495 HalfwidthandFullwidthForms UCS Block """ 2496 ret = libxml2mod.xmlUCSIsHalfwidthandFullwidthForms(code) 2497 return ret
2498
2499 -def uCSIsHangulCompatibilityJamo(code):
2500 """Check whether the character is part of 2501 HangulCompatibilityJamo UCS Block """ 2502 ret = libxml2mod.xmlUCSIsHangulCompatibilityJamo(code) 2503 return ret
2504
2505 -def uCSIsHangulJamo(code):
2506 """Check whether the character is part of HangulJamo UCS Block """ 2507 ret = libxml2mod.xmlUCSIsHangulJamo(code) 2508 return ret
2509
2510 -def uCSIsHangulSyllables(code):
2511 """Check whether the character is part of HangulSyllables UCS 2512 Block """ 2513 ret = libxml2mod.xmlUCSIsHangulSyllables(code) 2514 return ret
2515
2516 -def uCSIsHanunoo(code):
2517 """Check whether the character is part of Hanunoo UCS Block """ 2518 ret = libxml2mod.xmlUCSIsHanunoo(code) 2519 return ret
2520
2521 -def uCSIsHebrew(code):
2522 """Check whether the character is part of Hebrew UCS Block """ 2523 ret = libxml2mod.xmlUCSIsHebrew(code) 2524 return ret
2525
2526 -def uCSIsHighPrivateUseSurrogates(code):
2527 """Check whether the character is part of 2528 HighPrivateUseSurrogates UCS Block """ 2529 ret = libxml2mod.xmlUCSIsHighPrivateUseSurrogates(code) 2530 return ret
2531
2532 -def uCSIsHighSurrogates(code):
2533 """Check whether the character is part of HighSurrogates UCS 2534 Block """ 2535 ret = libxml2mod.xmlUCSIsHighSurrogates(code) 2536 return ret
2537
2538 -def uCSIsHiragana(code):
2539 """Check whether the character is part of Hiragana UCS Block """ 2540 ret = libxml2mod.xmlUCSIsHiragana(code) 2541 return ret
2542
2543 -def uCSIsIPAExtensions(code):
2544 """Check whether the character is part of IPAExtensions UCS 2545 Block """ 2546 ret = libxml2mod.xmlUCSIsIPAExtensions(code) 2547 return ret
2548
2549 -def uCSIsIdeographicDescriptionCharacters(code):
2550 """Check whether the character is part of 2551 IdeographicDescriptionCharacters UCS Block """ 2552 ret = libxml2mod.xmlUCSIsIdeographicDescriptionCharacters(code) 2553 return ret
2554
2555 -def uCSIsKanbun(code):
2556 """Check whether the character is part of Kanbun UCS Block """ 2557 ret = libxml2mod.xmlUCSIsKanbun(code) 2558 return ret
2559
2560 -def uCSIsKangxiRadicals(code):
2561 """Check whether the character is part of KangxiRadicals UCS 2562 Block """ 2563 ret = libxml2mod.xmlUCSIsKangxiRadicals(code) 2564 return ret
2565
2566 -def uCSIsKannada(code):
2567 """Check whether the character is part of Kannada UCS Block """ 2568 ret = libxml2mod.xmlUCSIsKannada(code) 2569 return ret
2570
2571 -def uCSIsKatakana(code):
2572 """Check whether the character is part of Katakana UCS Block """ 2573 ret = libxml2mod.xmlUCSIsKatakana(code) 2574 return ret
2575
2576 -def uCSIsKatakanaPhoneticExtensions(code):
2577 """Check whether the character is part of 2578 KatakanaPhoneticExtensions UCS Block """ 2579 ret = libxml2mod.xmlUCSIsKatakanaPhoneticExtensions(code) 2580 return ret
2581
2582 -def uCSIsKhmer(code):
2583 """Check whether the character is part of Khmer UCS Block """ 2584 ret = libxml2mod.xmlUCSIsKhmer(code) 2585 return ret
2586
2587 -def uCSIsKhmerSymbols(code):
2588 """Check whether the character is part of KhmerSymbols UCS 2589 Block """ 2590 ret = libxml2mod.xmlUCSIsKhmerSymbols(code) 2591 return ret
2592
2593 -def uCSIsLao(code):
2594 """Check whether the character is part of Lao UCS Block """ 2595 ret = libxml2mod.xmlUCSIsLao(code) 2596 return ret
2597
2598 -def uCSIsLatin1Supplement(code):
2599 """Check whether the character is part of Latin-1Supplement 2600 UCS Block """ 2601 ret = libxml2mod.xmlUCSIsLatin1Supplement(code) 2602 return ret
2603
2604 -def uCSIsLatinExtendedA(code):
2605 """Check whether the character is part of LatinExtended-A UCS 2606 Block """ 2607 ret = libxml2mod.xmlUCSIsLatinExtendedA(code) 2608 return ret
2609
2610 -def uCSIsLatinExtendedAdditional(code):
2611 """Check whether the character is part of 2612 LatinExtendedAdditional UCS Block """ 2613 ret = libxml2mod.xmlUCSIsLatinExtendedAdditional(code) 2614 return ret
2615
2616 -def uCSIsLatinExtendedB(code):
2617 """Check whether the character is part of LatinExtended-B UCS 2618 Block """ 2619 ret = libxml2mod.xmlUCSIsLatinExtendedB(code) 2620 return ret
2621
2622 -def uCSIsLetterlikeSymbols(code):
2623 """Check whether the character is part of LetterlikeSymbols 2624 UCS Block """ 2625 ret = libxml2mod.xmlUCSIsLetterlikeSymbols(code) 2626 return ret
2627
2628 -def uCSIsLimbu(code):
2629 """Check whether the character is part of Limbu UCS Block """ 2630 ret = libxml2mod.xmlUCSIsLimbu(code) 2631 return ret
2632
2633 -def uCSIsLinearBIdeograms(code):
2634 """Check whether the character is part of LinearBIdeograms UCS 2635 Block """ 2636 ret = libxml2mod.xmlUCSIsLinearBIdeograms(code) 2637 return ret
2638
2639 -def uCSIsLinearBSyllabary(code):
2640 """Check whether the character is part of LinearBSyllabary UCS 2641 Block """ 2642 ret = libxml2mod.xmlUCSIsLinearBSyllabary(code) 2643 return ret
2644
2645 -def uCSIsLowSurrogates(code):
2646 """Check whether the character is part of LowSurrogates UCS 2647 Block """ 2648 ret = libxml2mod.xmlUCSIsLowSurrogates(code) 2649 return ret
2650
2651 -def uCSIsMalayalam(code):
2652 """Check whether the character is part of Malayalam UCS Block """ 2653 ret = libxml2mod.xmlUCSIsMalayalam(code) 2654 return ret
2655
2656 -def uCSIsMathematicalAlphanumericSymbols(code):
2657 """Check whether the character is part of 2658 MathematicalAlphanumericSymbols UCS Block """ 2659 ret = libxml2mod.xmlUCSIsMathematicalAlphanumericSymbols(code) 2660 return ret
2661
2662 -def uCSIsMathematicalOperators(code):
2663 """Check whether the character is part of 2664 MathematicalOperators UCS Block """ 2665 ret = libxml2mod.xmlUCSIsMathematicalOperators(code) 2666 return ret
2667
2668 -def uCSIsMiscellaneousMathematicalSymbolsA(code):
2669 """Check whether the character is part of 2670 MiscellaneousMathematicalSymbols-A UCS Block """ 2671 ret = libxml2mod.xmlUCSIsMiscellaneousMathematicalSymbolsA(code) 2672 return ret
2673
2674 -def uCSIsMiscellaneousMathematicalSymbolsB(code):
2675 """Check whether the character is part of 2676 MiscellaneousMathematicalSymbols-B UCS Block """ 2677 ret = libxml2mod.xmlUCSIsMiscellaneousMathematicalSymbolsB(code) 2678 return ret
2679
2680 -def uCSIsMiscellaneousSymbols(code):
2681 """Check whether the character is part of MiscellaneousSymbols 2682 UCS Block """ 2683 ret = libxml2mod.xmlUCSIsMiscellaneousSymbols(code) 2684 return ret
2685
2686 -def uCSIsMiscellaneousSymbolsandArrows(code):
2687 """Check whether the character is part of 2688 MiscellaneousSymbolsandArrows UCS Block """ 2689 ret = libxml2mod.xmlUCSIsMiscellaneousSymbolsandArrows(code) 2690 return ret
2691
2692 -def uCSIsMiscellaneousTechnical(code):
2693 """Check whether the character is part of 2694 MiscellaneousTechnical UCS Block """ 2695 ret = libxml2mod.xmlUCSIsMiscellaneousTechnical(code) 2696 return ret
2697
2698 -def uCSIsMongolian(code):
2699 """Check whether the character is part of Mongolian UCS Block """ 2700 ret = libxml2mod.xmlUCSIsMongolian(code) 2701 return ret
2702
2703 -def uCSIsMusicalSymbols(code):
2704 """Check whether the character is part of MusicalSymbols UCS 2705 Block """ 2706 ret = libxml2mod.xmlUCSIsMusicalSymbols(code) 2707 return ret
2708
2709 -def uCSIsMyanmar(code):
2710 """Check whether the character is part of Myanmar UCS Block """ 2711 ret = libxml2mod.xmlUCSIsMyanmar(code) 2712 return ret
2713
2714 -def uCSIsNumberForms(code):
2715 """Check whether the character is part of NumberForms UCS Block """ 2716 ret = libxml2mod.xmlUCSIsNumberForms(code) 2717 return ret
2718
2719 -def uCSIsOgham(code):
2720 """Check whether the character is part of Ogham UCS Block """ 2721 ret = libxml2mod.xmlUCSIsOgham(code) 2722 return ret
2723
2724 -def uCSIsOldItalic(code):
2725 """Check whether the character is part of OldItalic UCS Block """ 2726 ret = libxml2mod.xmlUCSIsOldItalic(code) 2727 return ret
2728
2729 -def uCSIsOpticalCharacterRecognition(code):
2730 """Check whether the character is part of 2731 OpticalCharacterRecognition UCS Block """ 2732 ret = libxml2mod.xmlUCSIsOpticalCharacterRecognition(code) 2733 return ret
2734
2735 -def uCSIsOriya(code):
2736 """Check whether the character is part of Oriya UCS Block """ 2737 ret = libxml2mod.xmlUCSIsOriya(code) 2738 return ret
2739
2740 -def uCSIsOsmanya(code):
2741 """Check whether the character is part of Osmanya UCS Block """ 2742 ret = libxml2mod.xmlUCSIsOsmanya(code) 2743 return ret
2744
2745 -def uCSIsPhoneticExtensions(code):
2746 """Check whether the character is part of PhoneticExtensions 2747 UCS Block """ 2748 ret = libxml2mod.xmlUCSIsPhoneticExtensions(code) 2749 return ret
2750
2751 -def uCSIsPrivateUse(code):
2752 """Check whether the character is part of PrivateUse UCS Block """ 2753 ret = libxml2mod.xmlUCSIsPrivateUse(code) 2754 return ret
2755
2756 -def uCSIsPrivateUseArea(code):
2757 """Check whether the character is part of PrivateUseArea UCS 2758 Block """ 2759 ret = libxml2mod.xmlUCSIsPrivateUseArea(code) 2760 return ret
2761
2762 -def uCSIsRunic(code):
2763 """Check whether the character is part of Runic UCS Block """ 2764 ret = libxml2mod.xmlUCSIsRunic(code) 2765 return ret
2766
2767 -def uCSIsShavian(code):
2768 """Check whether the character is part of Shavian UCS Block """ 2769 ret = libxml2mod.xmlUCSIsShavian(code) 2770 return ret
2771
2772 -def uCSIsSinhala(code):
2773 """Check whether the character is part of Sinhala UCS Block """ 2774 ret = libxml2mod.xmlUCSIsSinhala(code) 2775 return ret
2776
2777 -def uCSIsSmallFormVariants(code):
2778 """Check whether the character is part of SmallFormVariants 2779 UCS Block """ 2780 ret = libxml2mod.xmlUCSIsSmallFormVariants(code) 2781 return ret
2782
2783 -def uCSIsSpacingModifierLetters(code):
2784 """Check whether the character is part of 2785 SpacingModifierLetters UCS Block """ 2786 ret = libxml2mod.xmlUCSIsSpacingModifierLetters(code) 2787 return ret
2788
2789 -def uCSIsSpecials(code):
2790 """Check whether the character is part of Specials UCS Block """ 2791 ret = libxml2mod.xmlUCSIsSpecials(code) 2792 return ret
2793
2794 -def uCSIsSuperscriptsandSubscripts(code):
2795 """Check whether the character is part of 2796 SuperscriptsandSubscripts UCS Block """ 2797 ret = libxml2mod.xmlUCSIsSuperscriptsandSubscripts(code) 2798 return ret
2799
2800 -def uCSIsSupplementalArrowsA(code):
2801 """Check whether the character is part of SupplementalArrows-A 2802 UCS Block """ 2803 ret = libxml2mod.xmlUCSIsSupplementalArrowsA(code) 2804 return ret
2805
2806 -def uCSIsSupplementalArrowsB(code):
2807 """Check whether the character is part of SupplementalArrows-B 2808 UCS Block """ 2809 ret = libxml2mod.xmlUCSIsSupplementalArrowsB(code) 2810 return ret
2811
2812 -def uCSIsSupplementalMathematicalOperators(code):
2813 """Check whether the character is part of 2814 SupplementalMathematicalOperators UCS Block """ 2815 ret = libxml2mod.xmlUCSIsSupplementalMathematicalOperators(code) 2816 return ret
2817
2818 -def uCSIsSupplementaryPrivateUseAreaA(code):
2819 """Check whether the character is part of 2820 SupplementaryPrivateUseArea-A UCS Block """ 2821 ret = libxml2mod.xmlUCSIsSupplementaryPrivateUseAreaA(code) 2822 return ret
2823
2824 -def uCSIsSupplementaryPrivateUseAreaB(code):
2825 """Check whether the character is part of 2826 SupplementaryPrivateUseArea-B UCS Block """ 2827 ret = libxml2mod.xmlUCSIsSupplementaryPrivateUseAreaB(code) 2828 return ret
2829
2830 -def uCSIsSyriac(code):
2831 """Check whether the character is part of Syriac UCS Block """ 2832 ret = libxml2mod.xmlUCSIsSyriac(code) 2833 return ret
2834
2835 -def uCSIsTagalog(code):
2836 """Check whether the character is part of Tagalog UCS Block """ 2837 ret = libxml2mod.xmlUCSIsTagalog(code) 2838 return ret
2839
2840 -def uCSIsTagbanwa(code):
2841 """Check whether the character is part of Tagbanwa UCS Block """ 2842 ret = libxml2mod.xmlUCSIsTagbanwa(code) 2843 return ret
2844
2845 -def uCSIsTags(code):
2846 """Check whether the character is part of Tags UCS Block """ 2847 ret = libxml2mod.xmlUCSIsTags(code) 2848 return ret
2849
2850 -def uCSIsTaiLe(code):
2851 """Check whether the character is part of TaiLe UCS Block """ 2852 ret = libxml2mod.xmlUCSIsTaiLe(code) 2853 return ret
2854
2855 -def uCSIsTaiXuanJingSymbols(code):
2856 """Check whether the character is part of TaiXuanJingSymbols 2857 UCS Block """ 2858 ret = libxml2mod.xmlUCSIsTaiXuanJingSymbols(code) 2859 return ret
2860
2861 -def uCSIsTamil(code):
2862 """Check whether the character is part of Tamil UCS Block """ 2863 ret = libxml2mod.xmlUCSIsTamil(code) 2864 return ret
2865
2866 -def uCSIsTelugu(code):
2867 """Check whether the character is part of Telugu UCS Block """ 2868 ret = libxml2mod.xmlUCSIsTelugu(code) 2869 return ret
2870
2871 -def uCSIsThaana(code):
2872 """Check whether the character is part of Thaana UCS Block """ 2873 ret = libxml2mod.xmlUCSIsThaana(code) 2874 return ret
2875
2876 -def uCSIsThai(code):
2877 """Check whether the character is part of Thai UCS Block """ 2878 ret = libxml2mod.xmlUCSIsThai(code) 2879 return ret
2880
2881 -def uCSIsTibetan(code):
2882 """Check whether the character is part of Tibetan UCS Block """ 2883 ret = libxml2mod.xmlUCSIsTibetan(code) 2884 return ret
2885
2886 -def uCSIsUgaritic(code):
2887 """Check whether the character is part of Ugaritic UCS Block """ 2888 ret = libxml2mod.xmlUCSIsUgaritic(code) 2889 return ret
2890
2891 -def uCSIsUnifiedCanadianAboriginalSyllabics(code):
2892 """Check whether the character is part of 2893 UnifiedCanadianAboriginalSyllabics UCS Block """ 2894 ret = libxml2mod.xmlUCSIsUnifiedCanadianAboriginalSyllabics(code) 2895 return ret
2896
2897 -def uCSIsVariationSelectors(code):
2898 """Check whether the character is part of VariationSelectors 2899 UCS Block """ 2900 ret = libxml2mod.xmlUCSIsVariationSelectors(code) 2901 return ret
2902
2903 -def uCSIsVariationSelectorsSupplement(code):
2904 """Check whether the character is part of 2905 VariationSelectorsSupplement UCS Block """ 2906 ret = libxml2mod.xmlUCSIsVariationSelectorsSupplement(code) 2907 return ret
2908
2909 -def uCSIsYiRadicals(code):
2910 """Check whether the character is part of YiRadicals UCS Block """ 2911 ret = libxml2mod.xmlUCSIsYiRadicals(code) 2912 return ret
2913
2914 -def uCSIsYiSyllables(code):
2915 """Check whether the character is part of YiSyllables UCS Block """ 2916 ret = libxml2mod.xmlUCSIsYiSyllables(code) 2917 return ret
2918
2919 -def uCSIsYijingHexagramSymbols(code):
2920 """Check whether the character is part of 2921 YijingHexagramSymbols UCS Block """ 2922 ret = libxml2mod.xmlUCSIsYijingHexagramSymbols(code) 2923 return ret
2924 2925 # 2926 # Functions from module xmlversion 2927 # 2928
2929 -def checkVersion(version):
2930 """check the compiled lib version against the include one. 2931 This can warn or immediately kill the application """ 2932 libxml2mod.xmlCheckVersion(version)
2933 2934 # 2935 # Functions from module xpathInternals 2936 # 2937
2938 -def valuePop(ctxt):
2939 """Pops the top XPath object from the value stack """ 2940 if ctxt is None: ctxt__o = None 2941 else: ctxt__o = ctxt._o 2942 ret = libxml2mod.valuePop(ctxt__o) 2943 return ret
2944
2945 -class xmlNode(xmlCore):
2946 - def __init__(self, _obj=None):
2947 if type(_obj).__name__ != 'PyCObject': 2948 raise TypeError, 'xmlNode needs a PyCObject argument' 2949 self._o = _obj 2950 xmlCore.__init__(self, _obj=_obj)
2951
2952 - def __repr__(self):
2953 return "<xmlNode (%s) object at 0x%x>" % (self.name, long(pos_id (self)))
2954 2955 # accessors for xmlNode
2956 - def ns(self):
2957 """Get the namespace of a node """ 2958 ret = libxml2mod.xmlNodeGetNs(self._o) 2959 if ret is None:return None 2960 __tmp = xmlNs(_obj=ret) 2961 return __tmp
2962
2963 - def nsDefs(self):
2964 """Get the namespace of a node """ 2965 ret = libxml2mod.xmlNodeGetNsDefs(self._o) 2966 if ret is None:return None 2967 __tmp = xmlNs(_obj=ret) 2968 return __tmp
2969 2970 # 2971 # xmlNode functions from module debugXML 2972 # 2973
2974 - def debugDumpNode(self, output, depth):
2975 """Dumps debug information for the element node, it is 2976 recursive """ 2977 libxml2mod.xmlDebugDumpNode(output, self._o, depth)
2978
2979 - def debugDumpNodeList(self, output, depth):
2980 """Dumps debug information for the list of element node, it is 2981 recursive """ 2982 libxml2mod.xmlDebugDumpNodeList(output, self._o, depth)
2983
2984 - def debugDumpOneNode(self, output, depth):
2985 """Dumps debug information for the element node, it is not 2986 recursive """ 2987 libxml2mod.xmlDebugDumpOneNode(output, self._o, depth)
2988
2989 - def lsCountNode(self):
2990 """Count the children of @node. """ 2991 ret = libxml2mod.xmlLsCountNode(self._o) 2992 return ret
2993
2994 - def lsOneNode(self, output):
2995 """Dump to @output the type and name of @node. """ 2996 libxml2mod.xmlLsOneNode(output, self._o)
2997
2998 - def shellPrintNode(self):
2999 """Print node to the output FILE """ 3000 libxml2mod.xmlShellPrintNode(self._o)
3001 3002 # 3003 # xmlNode functions from module tree 3004 # 3005
3006 - def addChild(self, cur):
3007 """Add a new node to @parent, at the end of the child (or 3008 property) list merging adjacent TEXT nodes (in which case 3009 @cur is freed) If the new node is ATTRIBUTE, it is added 3010 into properties instead of children. If there is an 3011 attribute with equal name, it is first destroyed. """ 3012 if cur is None: cur__o = None 3013 else: cur__o = cur._o 3014 ret = libxml2mod.xmlAddChild(self._o, cur__o) 3015 if ret is None:raise treeError('xmlAddChild() failed') 3016 __tmp = xmlNode(_obj=ret) 3017 return __tmp
3018
3019 - def addChildList(self, cur):
3020 """Add a list of node at the end of the child list of the 3021 parent merging adjacent TEXT nodes (@cur may be freed) """ 3022 if cur is None: cur__o = None 3023 else: cur__o = cur._o 3024 ret = libxml2mod.xmlAddChildList(self._o, cur__o) 3025 if ret is None:raise treeError('xmlAddChildList() failed') 3026 __tmp = xmlNode(_obj=ret) 3027 return __tmp
3028
3029 - def addContent(self, content):
3030 """Append the extra substring to the node content. NOTE: In 3031 contrast to xmlNodeSetContent(), @content is supposed to 3032 be raw text, so unescaped XML special chars are allowed, 3033 entity references are not supported. """ 3034 libxml2mod.xmlNodeAddContent(self._o, content)
3035
3036 - def addContentLen(self, content, len):
3037 """Append the extra substring to the node content. NOTE: In 3038 contrast to xmlNodeSetContentLen(), @content is supposed 3039 to be raw text, so unescaped XML special chars are 3040 allowed, entity references are not supported. """ 3041 libxml2mod.xmlNodeAddContentLen(self._o, content, len)
3042
3043 - def addNextSibling(self, elem):
3044 """Add a new node @elem as the next sibling of @cur If the new 3045 node was already inserted in a document it is first 3046 unlinked from its existing context. As a result of text 3047 merging @elem may be freed. If the new node is ATTRIBUTE, 3048 it is added into properties instead of children. If there 3049 is an attribute with equal name, it is first destroyed. """ 3050 if elem is None: elem__o = None 3051 else: elem__o = elem._o 3052 ret = libxml2mod.xmlAddNextSibling(self._o, elem__o) 3053 if ret is None:raise treeError('xmlAddNextSibling() failed') 3054 __tmp = xmlNode(_obj=ret) 3055 return __tmp
3056
3057 - def addPrevSibling(self, elem):
3058 """Add a new node @elem as the previous sibling of @cur 3059 merging adjacent TEXT nodes (@elem may be freed) If the 3060 new node was already inserted in a document it is first 3061 unlinked from its existing context. If the new node is 3062 ATTRIBUTE, it is added into properties instead of 3063 children. If there is an attribute with equal name, it is 3064 first destroyed. """ 3065 if elem is None: elem__o = None 3066 else: elem__o = elem._o 3067 ret = libxml2mod.xmlAddPrevSibling(self._o, elem__o) 3068 if ret is None:raise treeError('xmlAddPrevSibling() failed') 3069 __tmp = xmlNode(_obj=ret) 3070 return __tmp
3071
3072 - def addSibling(self, elem):
3073 """Add a new element @elem to the list of siblings of @cur 3074 merging adjacent TEXT nodes (@elem may be freed) If the 3075 new element was already inserted in a document it is first 3076 unlinked from its existing context. """ 3077 if elem is None: elem__o = None 3078 else: elem__o = elem._o 3079 ret = libxml2mod.xmlAddSibling(self._o, elem__o) 3080 if ret is None:raise treeError('xmlAddSibling() failed') 3081 __tmp = xmlNode(_obj=ret) 3082 return __tmp
3083
3084 - def copyNode(self, extended):
3085 """Do a copy of the node. """ 3086 ret = libxml2mod.xmlCopyNode(self._o, extended) 3087 if ret is None:raise treeError('xmlCopyNode() failed') 3088 __tmp = xmlNode(_obj=ret) 3089 return __tmp
3090
3091 - def copyNodeList(self):
3092 """Do a recursive copy of the node list. Use 3093 xmlDocCopyNodeList() if possible to ensure string 3094 interning. """ 3095 ret = libxml2mod.xmlCopyNodeList(self._o) 3096 if ret is None:raise treeError('xmlCopyNodeList() failed') 3097 __tmp = xmlNode(_obj=ret) 3098 return __tmp
3099
3100 - def copyProp(self, cur):
3101 """Do a copy of the attribute. """ 3102 if cur is None: cur__o = None 3103 else: cur__o = cur._o 3104 ret = libxml2mod.xmlCopyProp(self._o, cur__o) 3105 if ret is None:raise treeError('xmlCopyProp() failed') 3106 __tmp = xmlAttr(_obj=ret) 3107 return __tmp
3108
3109 - def copyPropList(self, cur):
3110 """Do a copy of an attribute list. """ 3111 if cur is None: cur__o = None 3112 else: cur__o = cur._o 3113 ret = libxml2mod.xmlCopyPropList(self._o, cur__o) 3114 if ret is None:raise treeError('xmlCopyPropList() failed') 3115 __tmp = xmlAttr(_obj=ret) 3116 return __tmp
3117
3118 - def docCopyNode(self, doc, extended):
3119 """Do a copy of the node to a given document. """ 3120 if doc is None: doc__o = None 3121 else: doc__o = doc._o 3122 ret = libxml2mod.xmlDocCopyNode(self._o, doc__o, extended) 3123 if ret is None:raise treeError('xmlDocCopyNode() failed') 3124 __tmp = xmlNode(_obj=ret) 3125 return __tmp
3126
3127 - def docCopyNodeList(self, doc):
3128 """Do a recursive copy of the node list. """ 3129 if doc is None: doc__o = None 3130 else: doc__o = doc._o 3131 ret = libxml2mod.xmlDocCopyNodeList(doc__o, self._o) 3132 if ret is None:raise treeError('xmlDocCopyNodeList() failed') 3133 __tmp = xmlNode(_obj=ret) 3134 return __tmp
3135
3136 - def docSetRootElement(self, doc):
3137 """Set the root element of the document (doc->children is a 3138 list containing possibly comments, PIs, etc ...). """ 3139 if doc is None: doc__o = None 3140 else: doc__o = doc._o 3141 ret = libxml2mod.xmlDocSetRootElement(doc__o, self._o) 3142 if ret is None:return None 3143 __tmp = xmlNode(_obj=ret) 3144 return __tmp
3145
3146 - def freeNode(self):
3147 """Free a node, this is a recursive behaviour, all the 3148 children are freed too. This doesn't unlink the child from 3149 the list, use xmlUnlinkNode() first. """ 3150 libxml2mod.xmlFreeNode(self._o)
3151
3152 - def freeNodeList(self):
3153 """Free a node and all its siblings, this is a recursive 3154 behaviour, all the children are freed too. """ 3155 libxml2mod.xmlFreeNodeList(self._o)
3156
3157 - def getBase(self, doc):
3158 """Searches for the BASE URL. The code should work on both XML 3159 and HTML document even if base mechanisms are completely 3160 different. It returns the base as defined in RFC 2396 3161 sections 5.1.1. Base URI within Document Content and 3162 5.1.2. Base URI from the Encapsulating Entity However it 3163 does not return the document base (5.1.3), use 3164 xmlDocumentGetBase() for this """ 3165 if doc is None: doc__o = None 3166 else: doc__o = doc._o 3167 ret = libxml2mod.xmlNodeGetBase(doc__o, self._o) 3168 return ret
3169
3170 - def getContent(self):
3171 """Read the value of a node, this can be either the text 3172 carried directly by this node if it's a TEXT node or the 3173 aggregate string of the values carried by this node 3174 child's (TEXT and ENTITY_REF). Entity references are 3175 substituted. """ 3176 ret = libxml2mod.xmlNodeGetContent(self._o) 3177 return ret
3178
3179 - def getLang(self):
3180 """Searches the language of a node, i.e. the values of the 3181 xml:lang attribute or the one carried by the nearest 3182 ancestor. """ 3183 ret = libxml2mod.xmlNodeGetLang(self._o) 3184 return ret
3185
3186 - def getSpacePreserve(self):
3187 """Searches the space preserving behaviour of a node, i.e. the 3188 values of the xml:space attribute or the one carried by 3189 the nearest ancestor. """ 3190 ret = libxml2mod.xmlNodeGetSpacePreserve(self._o) 3191 return ret
3192
3193 - def hasNsProp(self, name, nameSpace):
3194 """Search for an attribute associated to a node This attribute 3195 has to be anchored in the namespace specified. This does 3196 the entity substitution. This function looks in DTD 3197 attribute declaration for #FIXED or default declaration 3198 values unless DTD use has been turned off. Note that a 3199 namespace of None indicates to use the default namespace. """ 3200 ret = libxml2mod.xmlHasNsProp(self._o, name, nameSpace) 3201 if ret is None:return None 3202 __tmp = xmlAttr(_obj=ret) 3203 return __tmp
3204
3205 - def hasProp(self, name):
3206 """Search an attribute associated to a node This function also 3207 looks in DTD attribute declaration for #FIXED or default 3208 declaration values unless DTD use has been turned off. """ 3209 ret = libxml2mod.xmlHasProp(self._o, name) 3210 if ret is None:return None 3211 __tmp = xmlAttr(_obj=ret) 3212 return __tmp
3213
3214 - def isBlankNode(self):
3215 """Checks whether this node is an empty or whitespace only 3216 (and possibly ignorable) text-node. """ 3217 ret = libxml2mod.xmlIsBlankNode(self._o) 3218 return ret
3219
3220 - def isText(self):
3221 """Is this node a Text node ? """ 3222 ret = libxml2mod.xmlNodeIsText(self._o) 3223 return ret
3224
3225 - def lastChild(self):
3226 """Search the last child of a node. """ 3227 ret = libxml2mod.xmlGetLastChild(self._o) 3228 if ret is None:raise treeError('xmlGetLastChild() failed') 3229 __tmp = xmlNode(_obj=ret) 3230 return __tmp
3231
3232 - def lineNo(self):
3233 """Get line number of @node. This requires activation of this 3234 option before invoking the parser by calling 3235 xmlLineNumbersDefault(1) """ 3236 ret = libxml2mod.xmlGetLineNo(self._o) 3237 return ret
3238
3239 - def listGetRawString(self, doc, inLine):
3240 """Builds the string equivalent to the text contained in the 3241 Node list made of TEXTs and ENTITY_REFs, contrary to 3242 xmlNodeListGetString() this function doesn't do any 3243 character encoding handling. """ 3244 if doc is None: doc__o = None 3245 else: doc__o = doc._o 3246 ret = libxml2mod.xmlNodeListGetRawString(doc__o, self._o, inLine) 3247 return ret
3248
3249 - def listGetString(self, doc, inLine):
3250 """Build the string equivalent to the text contained in the 3251 Node list made of TEXTs and ENTITY_REFs """ 3252 if doc is None: doc__o = None 3253 else: doc__o = doc._o 3254 ret = libxml2mod.xmlNodeListGetString(doc__o, self._o, inLine) 3255 return ret
3256
3257 - def newChild(self, ns, name, content):
3258 """Creation of a new child element, added at the end of 3259 @parent children list. @ns and @content parameters are 3260 optional (None). If @ns is None, the newly created element 3261 inherits the namespace of @parent. If @content is non 3262 None, a child list containing the TEXTs and ENTITY_REFs 3263 node will be created. NOTE: @content is supposed to be a 3264 piece of XML CDATA, so it allows entity references. XML 3265 special chars must be escaped first by using 3266 xmlEncodeEntitiesReentrant(), or xmlNewTextChild() should 3267 be used. """ 3268 if ns is None: ns__o = None 3269 else: ns__o = ns._o 3270 ret = libxml2mod.xmlNewChild(self._o, ns__o, name, content) 3271 if ret is None:raise treeError('xmlNewChild() failed') 3272 __tmp = xmlNode(_obj=ret) 3273 return __tmp
3274
3275 - def newNs(self, href, prefix):
3276 """Creation of a new Namespace. This function will refuse to 3277 create a namespace with a similar prefix than an existing 3278 one present on this node. We use href==None in the case of 3279 an element creation where the namespace was not defined. """ 3280 ret = libxml2mod.xmlNewNs(self._o, href, prefix) 3281 if ret is None:raise treeError('xmlNewNs() failed') 3282 __tmp = xmlNs(_obj=ret) 3283 return __tmp
3284
3285 - def newNsProp(self, ns, name, value):
3286 """Create a new property tagged with a namespace and carried 3287 by a node. """ 3288 if ns is None: ns__o = None 3289 else: ns__o = ns._o 3290 ret = libxml2mod.xmlNewNsProp(self._o, ns__o, name, value) 3291 if ret is None:raise treeError('xmlNewNsProp() failed') 3292 __tmp = xmlAttr(_obj=ret) 3293 return __tmp
3294
3295 - def newNsPropEatName(self, ns, name, value):
3296 """Create a new property tagged with a namespace and carried 3297 by a node. """ 3298 if ns is None: ns__o = None 3299 else: ns__o = ns._o 3300 ret = libxml2mod.xmlNewNsPropEatName(self._o, ns__o, name, value) 3301 if ret is None:raise treeError('xmlNewNsPropEatName() failed') 3302 __tmp = xmlAttr(_obj=ret) 3303 return __tmp
3304
3305 - def newProp(self, name, value):
3306 """Create a new property carried by a node. """ 3307 ret = libxml2mod.xmlNewProp(self._o, name, value) 3308 if ret is None:raise treeError('xmlNewProp() failed') 3309 __tmp = xmlAttr(_obj=ret) 3310 return __tmp
3311
3312 - def newTextChild(self, ns, name, content):
3313 """Creation of a new child element, added at the end of 3314 @parent children list. @ns and @content parameters are 3315 optional (None). If @ns is None, the newly created element 3316 inherits the namespace of @parent. If @content is non 3317 None, a child TEXT node will be created containing the 3318 string @content. NOTE: Use xmlNewChild() if @content will 3319 contain entities that need to be preserved. Use this 3320 function, xmlNewTextChild(), if you need to ensure that 3321 reserved XML chars that might appear in @content, such as 3322 the ampersand, greater-than or less-than signs, are 3323 automatically replaced by their XML escaped entity 3324 representations. """ 3325 if ns is None: ns__o = None 3326 else: ns__o = ns._o 3327 ret = libxml2mod.xmlNewTextChild(self._o, ns__o, name, content) 3328 if ret is None:raise treeError('xmlNewTextChild() failed') 3329 __tmp = xmlNode(_obj=ret) 3330 return __tmp
3331
3332 - def noNsProp(self, name):
3333 """Search and get the value of an attribute associated to a 3334 node This does the entity substitution. This function 3335 looks in DTD attribute declaration for #FIXED or default 3336 declaration values unless DTD use has been turned off. 3337 This function is similar to xmlGetProp except it will 3338 accept only an attribute in no namespace. """ 3339 ret = libxml2mod.xmlGetNoNsProp(self._o, name) 3340 return ret
3341
3342 - def nodePath(self):
3343 """Build a structure based Path for the given node """ 3344 ret = libxml2mod.xmlGetNodePath(self._o) 3345 return ret
3346
3347 - def nsProp(self, name, nameSpace):
3348 """Search and get the value of an attribute associated to a 3349 node This attribute has to be anchored in the namespace 3350 specified. This does the entity substitution. This 3351 function looks in DTD attribute declaration for #FIXED or 3352 default declaration values unless DTD use has been turned 3353 off. """ 3354 ret = libxml2mod.xmlGetNsProp(self._o, name, nameSpace) 3355 return ret
3356
3357 - def prop(self, name):
3358 """Search and get the value of an attribute associated to a 3359 node This does the entity substitution. This function 3360 looks in DTD attribute declaration for #FIXED or default 3361 declaration values unless DTD use has been turned off. 3362 NOTE: this function acts independently of namespaces 3363 associated to the attribute. Use xmlGetNsProp() or 3364 xmlGetNoNsProp() for namespace aware processing. """ 3365 ret = libxml2mod.xmlGetProp(self._o, name) 3366 return ret
3367
3368 - def reconciliateNs(self, doc):
3369 """This function checks that all the namespaces declared 3370 within the given tree are properly declared. This is 3371 needed for example after Copy or Cut and then paste 3372 operations. The subtree may still hold pointers to 3373 namespace declarations outside the subtree or 3374 invalid/masked. As much as possible the function try to 3375 reuse the existing namespaces found in the new 3376 environment. If not possible the new namespaces are 3377 redeclared on @tree at the top of the given subtree. """ 3378 if doc is None: doc__o = None 3379 else: doc__o = doc._o 3380 ret = libxml2mod.xmlReconciliateNs(doc__o, self._o) 3381 return ret
3382
3383 - def replaceNode(self, cur):
3384 """Unlink the old node from its current context, prune the new 3385 one at the same place. If @cur was already inserted in a 3386 document it is first unlinked from its existing context. """ 3387 if cur is None: cur__o = None 3388 else: cur__o = cur._o 3389 ret = libxml2mod.xmlReplaceNode(self._o, cur__o) 3390 if ret is None:raise treeError('xmlReplaceNode() failed') 3391 __tmp = xmlNode(_obj=ret) 3392 return __tmp
3393
3394 - def searchNs(self, doc, nameSpace):
3395 """Search a Ns registered under a given name space for a 3396 document. recurse on the parents until it finds the 3397 defined namespace or return None otherwise. @nameSpace can 3398 be None, this is a search for the default namespace. We 3399 don't allow to cross entities boundaries. If you don't 3400 declare the namespace within those you will be in troubles 3401 !!! A warning is generated to cover this case. """ 3402 if doc is None: doc__o = None 3403 else: doc__o = doc._o 3404 ret = libxml2mod.xmlSearchNs(doc__o, self._o, nameSpace) 3405 if ret is None:raise treeError('xmlSearchNs() failed') 3406 __tmp = xmlNs(_obj=ret) 3407 return __tmp
3408
3409 - def searchNsByHref(self, doc, href):
3410 """Search a Ns aliasing a given URI. Recurse on the parents 3411 until it finds the defined namespace or return None 3412 otherwise. """ 3413 if doc is None: doc__o = None 3414 else: doc__o = doc._o 3415 ret = libxml2mod.xmlSearchNsByHref(doc__o, self._o, href) 3416 if ret is None:raise treeError('xmlSearchNsByHref() failed') 3417 __tmp = xmlNs(_obj=ret) 3418 return __tmp
3419
3420 - def setBase(self, uri):
3421 """Set (or reset) the base URI of a node, i.e. the value of 3422 the xml:base attribute. """ 3423 libxml2mod.xmlNodeSetBase(self._o, uri)
3424
3425 - def setContent(self, content):
3426 """Replace the content of a node. NOTE: @content is supposed 3427 to be a piece of XML CDATA, so it allows entity 3428 references, but XML special chars need to be escaped first 3429 by using xmlEncodeEntitiesReentrant() resp. 3430 xmlEncodeSpecialChars(). """ 3431 libxml2mod.xmlNodeSetContent(self._o, content)
3432
3433 - def setContentLen(self, content, len):
3434 """Replace the content of a node. NOTE: @content is supposed 3435 to be a piece of XML CDATA, so it allows entity 3436 references, but XML special chars need to be escaped first 3437 by using xmlEncodeEntitiesReentrant() resp. 3438 xmlEncodeSpecialChars(). """ 3439 libxml2mod.xmlNodeSetContentLen(self._o, content, len)
3440
3441 - def setLang(self, lang):
3442 """Set the language of a node, i.e. the values of the xml:lang 3443 attribute. """ 3444 libxml2mod.xmlNodeSetLang(self._o, lang)
3445
3446 - def setListDoc(self, doc):
3447 """update all nodes in the list to point to the right document """ 3448 if doc is None: doc__o = None 3449 else: doc__o = doc._o 3450 libxml2mod.xmlSetListDoc(self._o, doc__o)
3451
3452 - def setName(self, name):
3453 """Set (or reset) the name of a node. """ 3454 libxml2mod.xmlNodeSetName(self._o, name)
3455
3456 - def setNs(self, ns):
3457 """Associate a namespace to a node, a posteriori. """ 3458 if ns is None: ns__o = None 3459 else: ns__o = ns._o 3460 libxml2mod.xmlSetNs(self._o, ns__o)
3461
3462 - def setNsProp(self, ns, name, value):
3463 """Set (or reset) an attribute carried by a node. The ns 3464 structure must be in scope, this is not checked """ 3465 if ns is None: ns__o = None 3466 else: ns__o = ns._o 3467 ret = libxml2mod.xmlSetNsProp(self._o, ns__o, name, value) 3468 if ret is None:raise treeError('xmlSetNsProp() failed') 3469 __tmp = xmlAttr(_obj=ret) 3470 return __tmp
3471
3472 - def setProp(self, name, value):
3473 """Set (or reset) an attribute carried by a node. If @name has 3474 a prefix, then the corresponding namespace-binding will be 3475 used, if in scope; it is an error it there's no such 3476 ns-binding for the prefix in scope. """ 3477 ret = libxml2mod.xmlSetProp(self._o, name, value) 3478 if ret is None:raise treeError('xmlSetProp() failed') 3479 __tmp = xmlAttr(_obj=ret) 3480 return __tmp
3481
3482 - def setSpacePreserve(self, val):
3483 """Set (or reset) the space preserving behaviour of a node, 3484 i.e. the value of the xml:space attribute. """ 3485 libxml2mod.xmlNodeSetSpacePreserve(self._o, val)
3486
3487 - def setTreeDoc(self, doc):
3488 """update all nodes under the tree to point to the right 3489 document """ 3490 if doc is None: doc__o = None 3491 else: doc__o = doc._o 3492 libxml2mod.xmlSetTreeDoc(self._o, doc__o)
3493
3494 - def textConcat(self, content, len):
3495 """Concat the given string at the end of the existing node 3496 content """ 3497 ret = libxml2mod.xmlTextConcat(self._o, content, len) 3498 return ret
3499
3500 - def textMerge(self, second):
3501 """Merge two text nodes into one """ 3502 if second is None: second__o = None 3503 else: second__o = second._o 3504 ret = libxml2mod.xmlTextMerge(self._o, second__o) 3505 if ret is None:raise treeError('xmlTextMerge() failed') 3506 __tmp = xmlNode(_obj=ret) 3507 return __tmp
3508
3509 - def unlinkNode(self):
3510 """Unlink a node from it's current context, the node is not 3511 freed """ 3512 libxml2mod.xmlUnlinkNode(self._o)
3513
3514 - def unsetNsProp(self, ns, name):
3515 """Remove an attribute carried by a node. """ 3516 if ns is None: ns__o = None 3517 else: ns__o = ns._o 3518 ret = libxml2mod.xmlUnsetNsProp(self._o, ns__o, name) 3519 return ret
3520
3521 - def unsetProp(self, name):
3522 """Remove an attribute carried by a node. This handles only 3523 attributes in no namespace. """ 3524 ret = libxml2mod.xmlUnsetProp(self._o, name) 3525 return ret
3526 3527 # 3528 # xmlNode functions from module valid 3529 # 3530
3531 - def isID(self, doc, attr):
3532 """Determine whether an attribute is of type ID. In case we 3533 have DTD(s) then this is done if DTD loading has been 3534 requested. In the case of HTML documents parsed with the 3535 HTML parser, then ID detection is done systematically. """ 3536 if doc is None: doc__o = None 3537 else: doc__o = doc._o 3538 if attr is None: attr__o = None 3539 else: attr__o = attr._o 3540 ret = libxml2mod.xmlIsID(doc__o, self._o, attr__o) 3541 return ret
3542
3543 - def isRef(self, doc, attr):
3544 """Determine whether an attribute is of type Ref. In case we 3545 have DTD(s) then this is simple, otherwise we use an 3546 heuristic: name Ref (upper or lowercase). """ 3547 if doc is None: doc__o = None 3548 else: doc__o = doc._o 3549 if attr is None: attr__o = None 3550 else: attr__o = attr._o 3551 ret = libxml2mod.xmlIsRef(doc__o, self._o, attr__o) 3552 return ret
3553
3554 - def validNormalizeAttributeValue(self, doc, name, value):
3555 """Does the validation related extra step of the normalization 3556 of attribute values: If the declared value is not CDATA, 3557 then the XML processor must further process the normalized 3558 attribute value by discarding any leading and trailing 3559 space (#x20) characters, and by replacing sequences of 3560