Copyright 2006 Fourthought, Inc. (USA). Detailed license and copyright information: http://4suite.org/COPYRIGHT Project home, documentation, distributions: http://4suite.org/
Classes:
|
Functions:
|
Globals:
|
Classes and functions that help implement OASIS XML and TR9401 Catalogs.
Resolution with Catalogs is handled via the Ft.Xml.InputSource module.
|
|
Abstraction module for Domlette usage.
Domlette is a DOM-like library tailored for use in XPath/XSLT.
|
|
Classes providing a standard interface and encapsulation of metadata for
document/entity streams intended for input to various XML processors.
|
|
Module providing XML support utilities (including serialization and tree comparison)
|
|
General-purpose utility class for generating XML (may eventually be
expanded to produce more output types)
|
|
Localizable message strings
|
|
Abstraction module for Domlette SAX usage.
|
|
XInclude processing
|
|
XLink processing package
|
|
4XPath initialization and principal functions
|
|
Module for XPointer processing
|
|
XUpdate request processing
|
|
4XSLT initialization and XSLT pattern tools
|
|
XVIF integration for 4Suite. Includes basic RELAX NG support
|
|
cDomlette implementation: a very fast DOM-like library tailored for use in XPath/XSLT
|
|
cDomlette implementation: a very fast DOM-like library tailored for use in XPath/XSLT
|
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
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.
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.
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.
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.