Package gavo :: Package protocols :: Module oaiclient :: Class OAIRecordsParser
[frames] | no frames]

Class OAIRecordsParser

source code

xml.sax.handler.ContentHandler --+
                                 |
                    object --+   |
                             |   |
                 OAIErrorMixin --+
                                 |
                                OAIRecordsParser

a SAX ContentHandler generating tuples of some record-level metadata and pre-formatted XML of simple implementation of the OAI interface.

canonicalPrefixes is a CanonicalPrefixesInstance built from res/canonicalPrefixes.pickle

Note that we *require* that records actually carry ivo_vor metadata.

Instance Methods
 
__init__(self, canonicalPrefixes=None)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
startPrefixMapping(self, prefix, uri)
Begin the scope of a prefix-URI Namespace mapping.
source code
 
endPrefixMapping(self, prefix)
End the scope of a prefix-URI mapping.
source code
 
startElementNS(self, namePair, ignored, attrs)
Signals the start of an element in namespace mode.
source code
 
endElementNS(self, namePair, name)
Signals the end of an element in namespace mode.
source code
 
characters(self, stuff)
Receive notification of character data.
source code
 
normalizeNamespace(self, name)
fixes the namespace prefix of name if necessary.
source code
 
notifyError(self, err) source code
 
shipout(self, role, record) source code
 
getResult(self) source code

Inherited from xml.sax.handler.ContentHandler: endDocument, endElement, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startElement

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables
  resumptionToken = None
hash(x)
  startHandlers = {'oai:error': <__builtin__.function object>, '...
  endHandlers = {'oai:error': <__builtin__.function object>, 'oa...
Properties

Inherited from object: __class__

Method Details

__init__(self, canonicalPrefixes=None)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

startPrefixMapping(self, prefix, uri)

source code 

Begin the scope of a prefix-URI Namespace mapping.

The information from this event is not necessary for normal Namespace processing: the SAX XML reader will automatically replace prefixes for element and attribute names when the http://xml.org/sax/features/namespaces feature is true (the default).

There are cases, however, when applications need to use prefixes in character data or in attribute values, where they cannot safely be expanded automatically; the start/endPrefixMapping event supplies the information to the application to expand prefixes in those contexts itself, if necessary.

Note that start/endPrefixMapping events are not guaranteed to be properly nested relative to each-other: all startPrefixMapping events will occur before the corresponding startElement event, and all endPrefixMapping events will occur after the corresponding endElement event, but their order is not guaranteed.

Overrides: xml.sax.handler.ContentHandler.startPrefixMapping
(inherited documentation)

endPrefixMapping(self, prefix)

source code 

End the scope of a prefix-URI mapping.

See startPrefixMapping for details. This event will always occur after the corresponding endElement event, but the order of endPrefixMapping events is not otherwise guaranteed.

Overrides: xml.sax.handler.ContentHandler.endPrefixMapping
(inherited documentation)

startElementNS(self, namePair, ignored, attrs)

source code 

Signals the start of an element in namespace mode.

The name parameter contains the name of the element type as a (uri, localname) tuple, the qname parameter the raw XML 1.0 name used in the source document, and the attrs parameter holds an instance of the Attributes class containing the attributes of the element.

The uri part of the name tuple is None for elements which have no namespace.

Overrides: xml.sax.handler.ContentHandler.startElementNS
(inherited documentation)

endElementNS(self, namePair, name)

source code 

Signals the end of an element in namespace mode.

The name parameter contains the name of the element type, just as with the startElementNS event.

Overrides: xml.sax.handler.ContentHandler.endElementNS
(inherited documentation)

characters(self, stuff)

source code 

Receive notification of character data.

The Parser will call this method to report each chunk of character data. SAX parsers may return all contiguous character data in a single chunk, or they may split it into several chunks; however, all of the characters in any single event must come from the same external entity so that the Locator provides useful information.

Overrides: xml.sax.handler.ContentHandler.characters
(inherited documentation)

normalizeNamespace(self, name)

source code 

fixes the namespace prefix of name if necessary.

name must be a qualified name, i.e., contain exactly one colon.

"normalize" here means make sure the prefix matches our canonical prefix and change it to the canonical one if necessary.


Class Variable Details

startHandlers

Value:
{'oai:error': <__builtin__.function object>,
 'oai:header': <__builtin__.function object>,
 'oai:record': <__builtin__.function object>,
 'ri:Resource': <__builtin__.function object>}

endHandlers

Value:
{'oai:error': <__builtin__.function object>,
 'oai:identifier': <__builtin__.function object>,
 'oai:record': <__builtin__.function object>,
 'oai:resumptionToken': <__builtin__.function object>,
 'oai:setSpec': <__builtin__.function object>}