\STc@sWdZdZddlmZmZmZmZddlmZm Z m Z m Z ddl Tddlm Z mZmZmZmZmZmZmZmZmZmZmZdefdYZd dd YZd dd YZd ddYZdddYZdddYZdeeeefdYZdddYZ dS(se This module contains the core classes of version 2.0 of SAX for Python. This file provides only default classes with absolutely minimum functionality, from which drivers and applications can be subclassed. Many of these classes are empty and are included only as documentation of the interfaces. $Id: saxlib.py,v 1.12 2002/05/10 14:49:21 akuchling Exp $ s2.0betai(t ErrorHandlertContentHandlert DTDHandlertEntityResolver(t XMLReadert InputSourcetLocatortIncrementalParser(t*( tfeature_namespacestfeature_namespace_prefixestfeature_string_interningtfeature_validationtfeature_external_gestfeature_external_pest all_featurestproperty_lexical_handlertproperty_declaration_handlertproperty_dom_nodetproperty_xml_stringtall_propertiest XMLFiltercBs,eZdZddZdZdZRS(sEInterface for a SAX2 parser filter. A parser filter is an XMLReader that gets its events from another XMLReader (which may in turn also be a filter) rather than from a primary source like a document or other non-SAX data source. Filters can modify a stream of events before passing it on to its handlers.cCstj|||_dS(s\Creates a filter instance, allowing applications to set the parent on instantiation.N(Rt__init__t_parent(tselftparent((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pyR5s cCs ||_dS(sOSets the parent XMLReader of this filter. The argument may not be None.N(R(RR((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pyt setParent;scCs|jS(s"Returns the parent of this filter.(R(R((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pyt getParent@sN(t__name__t __module__t__doc__tNoneRRR(((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pyR,s  t AttributescBseZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z dd Zd ZdZdZRS(scInterface for a list of XML attributes. Contains a list of XML attributes, accessible by name.cCstddS(s-Returns the number of attributes in the list.s This method must be implemented!N(tNotImplementedError(R((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pyt getLengthKscCstddS(s6Returns the type of the attribute with the given name.s This method must be implemented!N(R!(Rtname((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pytgetTypeOscCstddS(s7Returns the value of the attribute with the given name.s This method must be implemented!N(R!(RR#((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pytgetValueSscCstddS(sRReturns the value of the attribute with the given raw (or qualified) name.s This method must be implemented!N(R!(RR#((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pytgetValueByQNameWscCstddS(s[Returns the namespace name of the attribute with the given raw (or qualified) name.s This method must be implemented!N(R!(RR#((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pytgetNameByQName\scCstddS(sBReturns a list of the names of all attributes in the list.s This method must be implemented!N(R!(R((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pytgetNamesascCstddS(sPReturns a list of the raw qualified names of all attributes in the list.s This method must be implemented!N(R!(R((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pyt getQNamesfscCstddS(sAlias for getLength.s This method must be implemented!N(R!(R((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pyt__len__kscCstddS(sAlias for getValue.s This method must be implemented!N(R!(RR#((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pyt __getitem__oscCstddS(s2Returns a list of the attribute names in the list.s This method must be implemented!N(R!(R((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pytkeyssscCstddS(s6True if the attribute is in the list, false otherwise.s This method must be implemented!N(R!(RR#((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pythas_keywscCstddS(smReturn the value associated with attribute name; if it is not available, then return the alternative.s This method must be implemented!N(R!(RR#t alternative((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pytget{scCstddS(s'Return a copy of the Attributes object.s This method must be implemented!N(R!(R((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pytcopyscCstddS(s/Return a list of (attribute_name, value) pairs.s This method must be implemented!N(R!(R((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pytitemsscCstddS(s&Return a list of all attribute values.s This method must be implemented!N(R!(R((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pytvaluessN(RRRR"R$R%R&R'R(R)R*R+R,R-RR/R0R1R2(((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pyR Fs               t DeclHandlercBs2eZdZdZdZdZdZRS(sOptional SAX2 handler for DTD declaration events. Note that some DTD declarations are already reported through the DTDHandler interface. All events reported to this handler will occur between the startDTD and endDTD events of the LexicalHandler. To set the DeclHandler for an XMLReader, use the setProperty method with the identifier http://xml.org/sax/handlers/DeclHandler.cCsdS(sReport an attribute type declaration. Only the first declaration will be reported. The type will be one of the strings "CDATA", "ID", "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY", "ENTITIES", or "NOTATION", or a list of names (in the case of enumerated definitions). elem_name is the element type name, attr_name the attribute type name, type a string representing the attribute type, value_def a string representing the default declaration ('#IMPLIED', '#REQUIRED', '#FIXED' or None). value is a string representing the attribute's default value, or None if there is none.N((Rt elem_namet attr_namettypet value_deftvalue((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pyt attributeDeclscCsdS(sReport an element type declaration. Only the first declaration will be reported. content_model is the string 'EMPTY', the string 'ANY' or the content model structure represented as tuple (separator, tokens, modifier) where separator is the separator in the token list (that is, '|' or ','), tokens is the list of tokens (element type names or tuples representing parentheses) and modifier is the quantity modifier ('*', '?' or '+').N((RR4t content_model((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pyt elementDeclscCsdS(s Report an internal entity declaration. Only the first declaration of an entity will be reported. name is the name of the entity. If it is a parameter entity, the name will begin with '%'. value is the replacement text of the entity.N((RR#R8((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pytinternalEntityDeclscCsdS(sReport a parsed entity declaration. (Unparsed entities are reported to the DTDHandler.) Only the first declaration for each entity will be reported. name is the name of the entity. If it is a parameter entity, the name will begin with '%'. public_id and system_id are the public and system identifiers of the entity. public_id will be None if none were declared.N((RR#t public_idt system_id((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pytexternalEntityDecls(RRRR9R;R<R?(((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pyR3s    tLexicalHandlercBsMeZdZdZdZdZdZdZdZdZ RS(s9Optional SAX2 handler for lexical events. This handler is used to obtain lexical information about an XML document, that is, information about how the document was encoded (as opposed to what it contains, which is reported to the ContentHandler), such as comments and CDATA marked section boundaries. To set the LexicalHandler of an XMLReader, use the setProperty method with the property identifier 'http://xml.org/sax/handlers/LexicalHandler'. There is no guarantee that the XMLReader will support or recognize this property.cCsdS(sReports a comment anywhere in the document (including the DTD and outside the document element). content is a string that holds the contents of the comment.N((Rtcontent((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pytcommentscCsdS(sReport the start of the DTD declarations, if the document has an associated DTD. A startEntity event will be reported before declaration events from the external DTD subset are reported, and this can be used to infer from which subset DTD declarations derive. name is the name of the document element type, public_id the public identifier of the DTD (or None if none were supplied) and system_id the system identfier of the external subset (or None if none were supplied).N((RR#R=R>((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pytstartDTDscCsdS(s$Signals the end of DTD declarations.N((R((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pytendDTDscCsdS(sReport the beginning of an entity. The start and end of the document entity is not reported. The start and end of the external DTD subset is reported with the pseudo-name '[dtd]'. Skipped entities will be reported through the skippedEntity event of the ContentHandler rather than through this event. name is the name of the entity. If it is a parameter entity, the name will begin with '%'.N((RR#((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pyt startEntityscCsdS(sReports the end of an entity. name is the name of the entity, and follows the same conventions as for startEntity.N((RR#((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pyt endEntityscCsdS(sReports the beginning of a CDATA marked section. The contents of the CDATA marked section will be reported through the characters event.N((R((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pyt startCDATA scCsdS(s*Reports the end of a CDATA marked section.N((R((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pytendCDATAs( RRRRBRCRDRERFRGRH(((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pyR@s     t AttributeListcBs}eZdZdZdZdZdZdZdZdZ dZ d d Z d Z d Zd ZRS(sInterface for an attribute list. This interface provides information about a list of attributes for an element (only specified or defaulted attributes will be reported). Note that the information returned by this object will be valid only during the scope of the DocumentHandler.startElement callback, and the attributes will not necessarily be provided in the order declared or specified.cCsdS(s(Return the number of attributes in list.N((R((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pyR"'scCsdS(s,Return the name of an attribute in the list.N((Rti((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pytgetName*scCsdS(soReturn the type of an attribute in the list. (Parameter can be either integer index or attribute name.)N((RRJ((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pyR$-scCsdS(spReturn the value of an attribute in the list. (Parameter can be either integer index or attribute name.)N((RRJ((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pyR%1scCsdS(sAlias for getLength.N((R((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pyR*5scCsdS(sBAlias for getName (if key is an integer) and getValue (if string).N((Rtkey((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pyR+8scCsdS(s&Returns a list of the attribute names.N((R((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pyR,;scCsdS(s6True if the attribute is in the list, false otherwise.N((RRL((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pyR->scCsdS(smReturn the value associated with attribute name; if it is not available, then return the alternative.N((RRLR.((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pyR/AscCsdS(s#Return a copy of the AttributeList.N((R((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pyR0EscCsdS(s.Return a list of (attribute_name,value) pairs.N((R((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pyR1HscCsdS(s&Return a list of all attribute values.N((R((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pyR2KsN(RRRR"RKR$R%R*R+R,R-RR/R0R1R2(((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pyRIs           tDocumentHandlercBsVeZdZdZdZdZdZdZdZdZ dZ RS( s+Handle general document events. This is the main client interface for SAX: it contains callbacks for the most important document events, such as the start and end of elements. You need to create an object that implements this interface, and then register it with the Parser. If you do not want to implement the entire interface, you can derive a class from HandlerBase, which implements the default functionality. You can find the location of any document event using the Locator interface supplied by setDocumentLocator().cCsdS(sHandle a character data event.N((Rtchtstarttlength((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pyt characters\scCsdS(s*Handle an event for the end of a document.N((R((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pyt endDocument_scCsdS(s*Handle an event for the end of an element.N((RR#((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pyt endElementbscCsdS(s<Handle an event for ignorable whitespace in element content.N((RRNRORP((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pytignorableWhitespaceescCsdS(s&Handle a processing instruction event.N((Rttargettdata((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pytprocessingInstructionhscCsdS(sAReceive an object for locating the origin of SAX document events.N((Rtlocator((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pytsetDocumentLocatorkscCsdS(s0Handle an event for the beginning of a document.N((R((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pyt startDocumentnscCsdS(s0Handle an event for the beginning of an element.N((RR#tatts((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pyt startElementqs( RRRRQRRRSRTRWRYRZR\(((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pyRMQs        t HandlerBasecBseZdZRS(sDefault base class for handlers. This class implements the default behaviour for four SAX interfaces: EntityResolver, DTDHandler, DocumentHandler, and ErrorHandler: rather than implementing those full interfaces, you may simply extend this class and override the methods that you need. Note that the use of this class is optional (you are free to implement the interfaces directly if you wish).(RRR(((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pyR]wstParsercBsVeZdZdZdZdZdZdZdZdZ dZ RS( sFBasic interface for SAX (Simple API for XML) parsers. All SAX parsers must implement this basic interface: it allows users to register handlers for different types of events and to initiate a parse from a URI, a character stream, or a byte stream. SAX parsers should also implement a zero-argument constructor.cCs4t|_t|_t|_t|_dS(N(RMt doc_handlerRt dtd_handlerRt ent_handlerRt err_handler(R((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pyRs   cCsdS(s/Parse an XML document from a system identifier.N((RtsystemId((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pytparsescCsdS(s.Parse an XML document from a file-like object.N((Rtfileobj((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pyt parseFilescCs ||_dS(s<Register an object to receive basic document-related events.N(R_(Rthandler((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pytsetDocumentHandlerscCs ||_dS(s7Register an object to receive basic DTD-related events.N(R`(RRg((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pyt setDTDHandlerscCs ||_dS(s0Register an object to resolve external entities.N(Ra(Rtresolver((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pytsetEntityResolverscCs ||_dS(s3Register an object to receive error-message events.N(Rb(RRg((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pytsetErrorHandlerscCstddS(sHAllow an application to set the locale for errors and warnings. SAX parsers are not required to provide localisation for errors and warnings; if they cannot support the requested locale, however, they must throw a SAX exception. Applications may request a locale change in the middle of a parse.sLocale support not implementedN(tSAXNotSupportedException(Rtlocale((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pyt setLocales( RRRRRdRfRhRiRkRlRo(((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pyR^s       N(((((((!RtversionRgRRRRt xmlreaderRRRRt _exceptionsR R R R R RRRRRRRRR R3R@RIRMR]R^(((sB/opt/freeware/lib64/python2.7/site-packages/_xmlplus/sax/saxlib.pyt s"" RP>J3&