2006-09-18 11:05:26

Module providing utilities for processing XML files

Copyright 2006 Fourthought, Inc. (USA). Detailed license and copyright information: http://4suite.org/COPYRIGHT Project home, documentation, distributions: http://4suite.org/
0.0

Classes and functions that help implement OASIS XML and TR9401 Catalogs. Resolution with Catalogs is handled via the Ft.Xml.InputSource module.

Based on a contribution to PyXML from Tarn Weisner Burton <twburton@users.sf.net>. See http://sourceforge.net/tracker/index.php?func=detail&aid=490069&group_id=6473&atid=306473

Copyright 2005 Fourthought, Inc. (USA). Detailed license and copyright information: http://4suite.org/COPYRIGHT Project home, documentation, distributions: http://4suite.org/

Abstraction module for Domlette usage. Domlette is a DOM-like library tailored for use in XPath/XSLT.

Copyright 2005 Fourthought, Inc. (USA). Detailed license and copyright information: http://4suite.org/COPYRIGHT Project home, documentation, distributions: http://4suite.org/

Classes providing a standard interface and encapsulation of metadata for document/entity streams intended for input to various XML processors.

Copyright 2005 Fourthought, Inc. (USA). Detailed license and copyright information: http://4suite.org/COPYRIGHT Project home, documentation, distributions: http://4suite.org/

Module providing XML support utilities (including serialization and tree comparison)

Copyright 2004 Fourthought, Inc. (USA). Detailed license and copyright information: http://4suite.org/COPYRIGHT Project home, documentation, distributions: http://4suite.org/

General-purpose utility class for generating XML (may eventually be expanded to produce more output types)

Sample usage:

from Ft.Xml import MarkupWriter writer = MarkupWriter(indent=u"yes") writer.startDocument() writer.startElement(u'xsa') writer.startElement(u'vendor') #Element with simple text (#PCDATA) content writer.simpleElement(u'name', content=u'Centigrade systems') #Note writer.text(content) still works writer.simpleElement(u'email', content=u"info@centigrade.bogus") writer.endElement(u'vendor') #Element with an attribute writer.startElement(u'product', attributes={u'id': u"100\u00B0"}) #Note writer.attribute(name, value, namespace=None) still works writer.simpleElement(u'name', content=u"100\u00B0 Server") #XML fragment writer.xmlFragment('<version>1.0</version><last-release>20030401</last-release>') #Empty element writer.simpleElement(u'changes') writer.endElement(u'product') writer.endElement(u'xsa') writer.endDocument()

Note on the difference between 4Suite writers and printers Writer - module that exposes a broad public API for building output bit by bit Printer - module that simply takes a DOM and creates output from it as a whole, within one API invokation

Localizable message strings

Copyright 2005 Fourthought, Inc. (USA). Detailed license and copyright information: http://4suite.org/COPYRIGHT Project home, documentation, distributions: http://4suite.org/

Abstraction module for Domlette SAX usage.

Copyright 2005 Fourthought, Inc. (USA). Detailed license and copyright information: http://4suite.org/COPYRIGHT Project home, documentation, distributions: http://4suite.org/

XInclude processing

XInclude processing is normally controlled via the Domlette reader APIs and is implemented within Domlette itself. This module just provides constants and classes to support XInclude processing.

XInclude is defined at http://www.w3.org/TR/xinclude

Copyright 2005 Fourthought, Inc. (USA). Detailed license and copyright information: http://4suite.org/COPYRIGHT Project home, documentation, distributions: http://4suite.org/

XLink processing package

See http://www.w3.org/TR/xlink/

Copyright 2005 Fourthought, Inc. (USA). Detailed license and copyright information: http://4suite.org/COPYRIGHT Project home, documentation, distributions: http://4suite.org/

4XPath initialization and principal functions

Copyright 2005 Fourthought, Inc. (USA). Detailed license and copyright information: http://4suite.org/COPYRIGHT Project home, documentation, distributions: http://4suite.org/

Module for XPointer processing

Copyright 2005 Fourthought, Inc. (USA). Detailed license and copyright information: http://4suite.org/COPYRIGHT Project home, documentation, distributions: http://4suite.org/

XUpdate request processing

XUpdate is specified (poorly) at http://xmldb-org.sourceforge.net/xupdate/xupdate-wd.html

Copyright 2005 Fourthought, Inc. (USA). Detailed license and copyright information: http://4suite.org/COPYRIGHT Project home, documentation, distributions: http://4suite.org/

4XSLT initialization and XSLT pattern tools

These are the most common steps for using this XSLT engine:

1. Create an Ft.Xml.Xslt.Processor.Processor instance:

from Ft.Xml.Xslt import Processor processor = Processor.Processor()

2. Prepare Ft.Xml.InputSource instances (via their factory) for the source XML and for the stylesheet.

3. Call the Processor's appendStylesheet() method, passing it the stylesheet's InputSource.

4. Call the Processor's run() method, passing it the source document's InputSource.

You can call run() multiple times on different InputSources. When you're done, the processor's reset() method can be used to restore a clean slate (at which point you would have to append stylesheets to the processor again), but in most circumstances it is actually less expensive to just create a new Processor instance.

Copyright 2003 Fourthought, Inc. (USA). Detailed license and copyright information: http://4suite.org/COPYRIGHT Project home, documentation, distributions: http://4suite.org/

XVIF integration for 4Suite. Includes basic RELAX NG support

Copyright 2006 Fourthought, Inc. (USA). Detailed license and copyright information: http://4suite.org/COPYRIGHT Project home, documentation, distributions: http://4suite.org/

Implementation of '4xml' command (functions defined here are used by the Ft.Lib.CommandLine framework)

Copyright 2004 Fourthought, Inc. (USA). Detailed license and copyright information: http://4suite.org/COPYRIGHT Project home, documentation, distributions: http://4suite.org/

cDomlette implementation: a very fast DOM-like library tailored for use in XPath/XSLT

Copyright 2005 Fourthought, Inc. (USA). Detailed license and copyright information: http://4suite.org/COPYRIGHT Project home, documentation, distributions: http://4suite.org/

cDomlette implementation: a very fast DOM-like library tailored for use in XPath/XSLT

Copyright 2006 Fourthought, Inc. (USA). Detailed license and copyright information: http://4suite.org/COPYRIGHT Project home, documentation, distributions: http://4suite.org/

General-purpose utility class for generating XML (may eventually be expanded to produce more output types)

Sample usage:

from Ft.Xml import MarkupWriter writer = MarkupWriter(indent=u"yes") writer.startDocument() writer.startElement(u'xsa') writer.startElement(u'vendor') #Element with simple text (#PCDATA) content writer.simpleElement(u'name', content=u'Centigrade systems') #Note writer.text(content) still works writer.simpleElement(u'email', content=u"info@centigrade.bogus") writer.endElement(u'vendor') #Element with an attribute writer.startElement(u'product', attributes={u'id': u"100\u00B0"}) #Note writer.attribute(name, value, namespace=None) still works writer.simpleElement(u'name', content=u"100\u00B0 Server") #XML fragment writer.xmlFragment('<version>1.0</version><last-release>20030401</last-release>') #Empty element writer.simpleElement(u'changes') writer.endElement(u'product') writer.endElement(u'xsa') writer.endDocument()

Note on the difference between 4Suite writers and printers Writer - module that exposes a broad public API for building output bit by bit Printer - module that simply takes a DOM and creates output from it as a whole, within one API invokation

Convenience factory function for Markup writers (based on xsl:output in XSLT)

Create a simple tag with optional attributes and content. The complete element, start tag, optional text content, end tag, will all be generated by this one call. Must *not* be matched with an endElement call.

Note: all "strings" in these parameters must be unicode objects tagName - qualified name of the element namespace - optional namespace URI attributes - optional dictionary mapping name to unicode value the name can either be a unicode QName or a tuple of (QName, namespace URI) content - optional unicode object with the text body of the simple element extraNss - optional dictionary (defaults to an empty one) that creates additional namespace declarations that the user wants to place on the specific element. Each key is a ns prefix, and each value a ns name (URI). You do not need to use extraNss if you will be using a similar namespace parameter. In fact, most people will never need this parameter.

Create a start tag with optional attributes. Must eventually be matched with an endElement call

Note: all "strings" in these parameters must be unicode objects tagName - qualified name of the element (must be unicode) namespace - optional namespace URI attributes - optional dictionary mapping name to unicode value the name can either be a unicode QName or a tuple of (QName, namespace URI) extraNss - optional dictionary (defaults to an empty one) that creates additional namespace declarations that the user wants to place on the specific element. Each key is a ns prefix, and each value a ns name (URI). You do not need to use extraNss if you will be using a similar namespace parameter. In fact, most people will never need this parameter.

Incorporate a well-formed general entity into the output. fragment of fragment - string (must not be a Unicode object) to be incorporated verbatim into the output, after testing for wellp-formedness

- <attribute '__dict__' of 'MarkupWriter' objects>
- <attribute '__weakref__' of 'MarkupWriter' objects>

Exception class for errors specific to XML reading (at a level above standard, non-namespace-aware parsing)

- 13
- 2000
- 2001
- 16
- 1023
- 14
- 15
- 8
- 1013
- 1007
- 1014
- 2002
- 24
- 1024
- 21
- 1015
- 10
- 1004
- 29
- 19
- 1001
- 1009
- 1022
- 1019
- 1018
- 1021
- 1020
- 32
- 1005
- 31
- 4
- 30
- 9
- 17
- 1011
- 1000
- 22
- 3
- 6
- 12
- 101
- 40
- 38
- 39
- 1002
- 2
- 7
- 27
- 20
- 5
- 1006
- 1003
- 1008
- 1010
- 28
- 11
- 1012
- 18
- 100
- 1016
- 1017

Exception class for errors specific to XInclude processing

- 16
- 13
- 15
- 11
- 10
- 17
- 12
- 14

#Wrap this so that we can import it later

#Good ol' backward compatibility for creative spellings

PyXML is required by some features of 4Suite (e.g., validating parsing, and 4XSLT's SaxWriter). This is a common function to test whether a correct version of PyXML is installed. It raises a SystemExit if the test result is negative, and returns None otherwise.

The feature argument is a string indicating which feature in 4Suite requires PyXML. It is output as part of the SystemExit message.

Convenience function for creating an InputSource. obj - a string, Unicode object (only if you really know what you're doing), file-like object (stream), file path or URI. You can also pass an InputSource object, in which case the return value is just the same object, possibly with the URI modified uri - optional override URI. The base URI for the IS will be set to this value

Returns an InputSource which can be passed to 4Suite APIs.

Convenience function for parsing XML. Use this function with a single argument, which must either be a string (not Unicode object), file-like object (stream), file path or URI.

Returns a Domlette node.

Only pass strings or streams to this function if the XML is self-contained XML (i.e. not requiring access to any other resource such as external entities or includes). If you get URI resolution errors, do not use this function: use the lower-level APIs instead. As an example, if you want such resolution to use the current working directory as a base, parse as follows for strings:

from Ft.Xml.Domlette import NonvalidatingReader from Ft.Lib import Uri

XML = "<!DOCTYPE a [ <!ENTITY b "b.xml"> ]><a>&b;</a>"

base = Uri.OsPathToUri('') #Turn CWD into a file: URL doc = NonvalidatingReader.parseString(XML, base) # during parsing, the replacement text for &b; # will be obtained from b.xml in the CWD

For streams, use "parseStream" rather than "parseString" in the above.

SplitQName(qualifiedName) -> (prefix, localName)

where 'qualifiedName' is a QName according to XML Namespaces 1.0 <http://www.w3.org/TR/REC-xml-names>. returns the name parts according to the spec.
qualifiedName
None
None
True
True
u'http://www.w3.org/1999/xhtml'
u'http://www.w3.org/2000/xmlns/'
u'http://www.w3.org/XML/1998/namespace'
['EMPTY_NAMESPACE', 'EMPTY_PREFIX', 'XML_NAMESPACE', 'XMLNS_NAMESPACE', 'XHTML_NAMESPACE', 'READ_EXTERNAL_DTD', 'HAS_PYEXPAT', 'ReaderException', 'XIncludeException', 'SplitQName', 'ApplyXUpdate', 'MarkupWriter', 'Parse', 'ParsePath']
'0.0'
StrictVersion ('0.8')