4Suite™ API Documentation

# ► Module Ft.Xml.Xslt.XmlWriter

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

Classes: CdataSectionXmlWriter, XmlWriter |  |  |  | Fields: DEFAULT_GENERATED_PREFIX, EMPTY_NAMESPACE, EMPTY_PREFIX, XMLNS_NAMESPACE, XML_NAMESPACE

## Classes

class CdataSectionXmlWriter(XmlWriter)
Converts character data to CDATA sections if the character data occurs within an element defined as outputting CDATA sections.

### Methods

__init__(self, outputParams, stream)
outputParams - instance of Ft.Xml.Xslt.OutputParameters.OutputParameters stream - a stream that takes a byte stream (not a unicode object)
endElement(self, tagName, namespace=None)
startElement(self, tagName, namespace=None, extraNss=None)
text(self, text, escapeOutput=True)

### Methods inherited from class XmlWriter

attribute, changePrefix, comment, endDocument, getStream, matchesGeneratedPrefix, namespace, processingInstruction, startDocument

### Methods inherited from class Ft.Xml.Xslt.NullWriter.NullWriter

copyNodes, getMediaType, getResult

### Fields

class XmlWriter(Ft.Xml.Xslt.NullWriter.NullWriter)
Takes events such as those generated by an XSLT processor and invokes a serializer to produce XML.

### Methods

__init__(self, outputParams, stream)
outputParams - instance of Ft.Xml.Xslt.OutputParameters.OutputParameters stream - a stream that takes a byte stream (not a unicode object)
attribute(self, name, value, namespace=None)
add an attribute to an element
name - the qualified name of the attribute
value - the attribute value: must be Unicode
namespace - must be Unicode or Ft.Xml.EMPTY_NAMESPACE (the default)
Strives for "sanity". For brilliant definition thereof, c.f. Joe English
http://lists.xml.org/archives/xml-dev/200204/msg00170.html
Uses terminology from that article
See also discussions starting
http://lists.fourthought.com/pipermail/4suite-dev/2003-March/001294.html
http://lists.fourthought.com/pipermail/4suite-dev/2003-March/001283.html
Note: attribute output is computed as invoked.
This means that the ugly case
attribute(u"foo", u"bar", "http://some-ns/")
attribute(u"x:foo", u"baz", "http://some-ns/")
will result in the ugly
xmlns:org.4suite.4xslt.ns0="http://some-ns/"
org.4suite.4xslt.ns0:foo="baz"
The user can easily correct this by reversing the
order of the calls
changePrefix(self, namespace, forbidEmpty=False)
comment(self, body)
endDocument(self)
endElement(self, tagName, namespace=None)
getStream(self)
matchesGeneratedPrefix(self, prefix)
namespace(self, prefix, namespace)
processingInstruction(self, target, data)
startDocument(self)
startElement(self, tagName, namespace=None, extraNss=None)
text(self, text, escapeOutput=True)

### Methods inherited from class Ft.Xml.Xslt.NullWriter.NullWriter

copyNodes, getMediaType, getResult

### Fields

GENERATED_PREFIX = u'org.4suite.4xslt.ns%s'

## Fields

DEFAULT_GENERATED_PREFIX = u'org.4suite.4xslt.ns'
EMPTY_NAMESPACE = None
EMPTY_PREFIX = None
XMLNS_NAMESPACE = u'http://www.w3.org/2000/xmlns/'
XML_NAMESPACE = u'http://www.w3.org/XML/1998/namespace'