Package net.sf.saxon.s9api.push
Interface Push
-
- All Known Implementing Classes:
PushToReceiver
public interface PushAn interface designed for applications to generate XML documents by issuing events. Functionally similar to the SAXContentHandleror the StaxXMLStreamWriter, it is designed eliminate the usability problems and ambiguities in those specifications.The
Pushinterface can be used to create a single tree rooted at a document node. It is possible to constrain the document node to be well-formed (in which case it must have a single element node child, plus optionally comment and processing instruction children). Some implementations may only accept well-formed documents.The document created using the
Pushinterface is set to theDestinationdefined whenPushis created using the factory methodProcessor.newPush(Destination). TheDestinationwill commonly be anXdmDestinationor aSerializer, but it could also be, for example, anXsltTransformeror anSchemaValidator.Here is an example of application code written to construct a simple XML document:
Push.Document doc = processor.newPush(destination).document(true); doc.setDefaultNamespace("http://www.example.org/ns"); Push.Element top = doc.element("root") .attribute("version", "1.5"); for (Employee emp : employees) { top.element("emp") .attribute("ssn", emp.getSSN()) .text(emp.getName()); } doc.close();
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Documentdocument(boolean wellFormed)Start an XML document.
-
-
-
Method Detail
-
document
Document document(boolean wellFormed) throws SaxonApiException
Start an XML document.- Parameters:
wellFormed- Set to true if the document is required to be well-formed; set to false if there is no such requirement. A well-formed document must have as its children exactly one element node plus optionally, any number of comment and processing instruction nodes (no text nodes are allowed); any attempt to construct a node sequence that does not follow these rules will result in an exception. If the document is not required to be well-formed, the children of the document node may comprise any sequence of element, text, comment, and processing instruction nodes.- Returns:
- a Document object which may be used to add content to the document, or to close the document when it has been fully written.
- Throws:
SaxonApiException- if the specified constraints are violated, or if the implementation detects any problems
-
-