Table of Contents

Module: SOX ./src/peak/util/SOX.py

Simple Objects from XML - quick-and-dirty XML parsing without a DOM

This module implements most of the overhead needed for turning SAX events into a hierarchy of objects. E.g., stack handling, delegation to node classes, etc.

If all you need is to read an XML file and turn it into objects, you came to the right place. If you need an actual model of the XML file that you can manipulate, with absolute fidelity to the original, you might be better off with a DOM, since this doesn't retain processing instructions or comments.

SOX is faster than minidom or any other DOM that I know of. On the other hand, SOX is slower than PyRXP, but SOX handles Unicode correctly.

To use this module, you will need a "document" object that implements either ISOXNode or ISOXNode_NS, depending on whether you want namespace support. The interfaces are very similar, except that the NS version has some enhancements/simplifications that can't be added to the non-namespace version for backward-compatibility reasons.

Once you have your document object, just call SOX.load(filenameOrStream,documentObject,namespaces=flag) to get back the result of your document object's _finish() method after it has absorbed all of the XML data supplied.

If you need a simple document or node class, Document, Document_NS, Node, and Node_NS are available for subclassing or idea-stealing.

Imported modules   
from protocols import Interface, advise, Adapter
from xml.sax.saxutils import XMLGenerator, quoteattr, escape
Functions   
invalidAttribute
invalidElement
load
validatedAttributes
  invalidAttribute 
invalidAttribute (
        parser,
        data,
        name,
        value,
        )

Use this as an element negotiator for unrecognized attributes

  invalidElement 
invalidElement ( parser,  data )

Use this as an element negotiator for unrecognized elements

  load 
load (
        filename_or_stream,
        documentObject=None,
        namespaces=False,
        )

Build a tree from a filename/stream, rooted in a document object

  validatedAttributes 
validatedAttributes (
        parser,
        data,
        required=(),
        optional=(),
        )

Filter an element's attributes, w/errors for invalid/missing attributes

Return a dictionary of unprefixed attributes (i.e. no attributes with : in them). If any attributes in required are missing, or if there are any attributes present that aren't listed in required or optional, a SyntaxError is generated.

Classes   

Document

Document_NS

ExpatBuilder

Parser that assembles a document

IAttributeNegotiator

IElementNegotiator

INegotiationData

All of the negotiator's behavior is controlled by data dictionaries that

INegotiatorLookup

ISOXNode

Object mapping from an XML element

ISOXNode_NS

IXMLBuilder

IndentedXML

SAX handler that writes its output to an IndentedStream

NSNodeAsXMLBuilder

NegotiatingParser

XML processor that lets elements and attributes "negotiate" w/each other

Node

Simple, DOM-like ISOXNode implementation

Node_NS

SoxNodeAsXMLBuilder


Table of Contents

This document was automatically generated on Mon Feb 20 01:11:13 2017 by HappyDoc version 2.1