|
Novell exteNd Director 5.2 API |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.novell.afw.util.EboXmlUtil
Utilities for dealing with XML
Constructor Summary | |
EboXmlUtil()
|
Method Summary | |
static Node |
addDirectiveToXSL(Document xslDom,
String directiveName,
String attributeName,
String attributeValue)
Add an xsl:import or xsl:include etc. |
static Node |
addDirectiveToXSLBeforeSibling(Node sibling,
String directiveName,
String attributeName,
String attributeValue)
Add an xsl:import or xsl:include node to an existing xsl style sheet (represented as DOM) before the passed sibling node |
static Node |
addNodeAfterSibling(Node siblingNode,
String nodeName,
Node content)
create a new Element with nodeName and insert it after the siblingNode (same level); if the node name is null, insert the content node after the sibling node; both Nodes need to be part of the same document |
static Node |
addNodeAfterSibling(Node siblingNode,
String nodeName,
Node content,
boolean contentIsLocal)
create a new Element with nodeName and insert it after the siblingNode (same level); if the node name is null, insert the content node after the sibling node |
static Node |
addNodeBeforeSibling(Node siblingNode,
String nodeName,
Node content)
create a new Element with nodeName and insert it before the siblingNode (same level) |
static Node |
addNodeBeforeSibling(Node siblingNode,
String nodeName,
Node content,
boolean contentIsLocal)
create a new Element with nodeName and insert it before the siblingNode (same level); if the node name is null, insert the content node before the sibling node |
static Node |
appendChildNode(Node parentNode,
Node contentNode)
import a node into the current document directly under the passed parent Node |
static Node |
appendChildNode(Node parentNode,
Node contentNode,
boolean contentIsLocal)
import a node into the current document directly under the passed parent Node |
static Attr |
createAttribute(Document doc,
String attributeName,
String attributeValue)
create an attribute standalone (not added to any node) |
static Attr |
createAttribute(Element el,
String attributeName,
String attributeValue)
create an attribute and add it to the Node provided |
static Node |
createCDATANode(Node parentNode,
String nodeName,
String content)
create a CDATA section as a child to the provided parentNode In case the content is null, a child node without content will be created, using createChildNode() |
static Node |
createChildNode(Node parentNode,
String nodeName)
Create a child node and append it to the provided parent node |
static Node |
createChildNode(Node parentNode,
String nodeName,
Node contentNode)
create a child node (to parentNode) and populate it with the delivered content (if != null) |
static Node |
createChildNode(Node parentNode,
String nodeName,
Node contentNode,
boolean contentIsLocal)
create a child node (to parentNode) and populate it with the delivered content (if != null) |
static Document |
createDocument()
create a new org.w3c.dom.Document with validation turned off and name space awareness turned on |
static Document |
createDocument(byte[] bytes)
create a Document from a byte[] |
static Document |
createDocument(InputSource inputSrc,
boolean isValidating,
boolean isNamespaceAware,
ErrorHandler errorHandler,
EntityResolver entityResolver)
Creates a new Document from an InputSource allowing the validation, namespace, error handler and entity resolver to be set. |
static Document |
createDocument(InputStream stream)
create a Document from a String representation (with name space awareness on and validation off) |
static Document |
createDocument(InputStream stream,
String encoding,
boolean validation,
boolean namespace)
create a Document from a stream representation of the XML content use the requested char-set encoding, validation and name space awareness |
static Document |
createDocument(Reader reader,
boolean validation,
boolean namespace)
create a Document from a reader representation of the XML content use the requested validation and name space awareness |
static Document |
createDocument(String strDoc)
Creates a Document from a String representing a valid XML document (no validation, but name space aware) |
static Document |
createDocument(URL documentURL)
create a Document from a URL (get the content from the URL); name space aware, but no validation |
static Node |
createDocumentRootNode(Document parentDocument,
String nodeName,
Node contentNode)
create a child node (to parentDocument) and populate it with the delivered content (if != null) |
static Node |
createDocumentRootNode(Document parentDocument,
String nodeName,
Node contentNode,
boolean contentIsLocal)
create a child node (to parentDocument) and populate it with the delivered content (if != null) |
static Node |
createNode(Document document,
String nodeName,
Node contentNode)
create a Node standalone (not added to any parent) |
static Node |
createNode(Document document,
String nodeName,
Node contentNode,
boolean contentIsLocal)
create a Node standalone (not added to any parent) |
static Node |
createTextNode(Document doc,
Node parentNode,
String nodeName,
String content)
create a text node |
static Node |
createTextNode(Node parentNode,
String nodeName,
String content)
create a text node |
static Attr |
getAttribute(String attributeName,
Node node)
get an attribute of a node (if present) |
static String |
getAttributeValue(String attributeName,
Node node)
get the value of an attribute of a node (if present) |
static DocumentBuilder |
getBuilder()
get a javax.xml.parsers.DocumentBuilder from the javax.xml.parsers.DocumentBuilderFactory validation turned off and name space awareness turned on if you need a DocumentBuilder with different features, use the getBuilder(boolean validation, boolean nameSpaceAware) method (this method will cache the DocumentBuilder after the fist hit |
static DocumentBuilder |
getBuilder(boolean validation,
boolean nameSpaceAware)
get a javax.xml.parsers.DocumentBuilder from the javax.xml.parsers.DocumentBuilderFactory |
static String |
getElementBodyText(Node parentNode)
get the text from an elements body example get 'hello world' from |
static Templates |
getTemplates(Source source)
compile the provided style sheet into templates |
static Transformer |
getTransformer()
get a new Transformer from the TransformerFactory with indent turned on |
static Transformer |
getTransformer(Document doc)
get a new Transformer for the passed Document (the xsl) from the TransformerFactory with indent turned on |
static Transformer |
getTransformer(Properties transProps)
get a new Transformer from the TransformerFactory with the passed output properties |
static Transformer |
getTransformer(Source strSource)
get a new Transformer for the passed Source (the xsl) from the TransformerFactory with indent turned on |
static Transformer |
getTransformer(Templates templates)
get a new Transformer for the passed compiled xsl template (with indent turned on) |
static String |
serialize(Node doc)
serialize a Document to String (using a Transformer) This call uses a javax.xml.transform.Transformer, and it's output encoding to convert the content to a String (default is UTF-8) If you want to use a different encoding, get a transformer via #getTransformer(Properties) and set the output property "encoding" to the desired one, then use #serialize(Node, Transformer) |
static void |
serialize(Node doc,
OutputStream output)
serialize a Document to the provided OutputStream (using a Transformer) |
static void |
serialize(Node doc,
OutputStream output,
Transformer transformer)
serialize a Document to the provided OutputStream (using the passed Transformer) |
static String |
serialize(Node doc,
Transformer transformer)
serialize a Document to String (using the passed Transformer) This call uses the transformer's output encoding to convert the content to a String |
static void |
serialize(Node doc,
Writer writer)
serialize a Document to the provided Writer (using a Transformer) |
static void |
serialize(Node doc,
Writer writer,
Transformer transformer)
serialize a Document to the provided Writer (using a Transformer) This call uses the transformer's output encoding to convert the content to a String (default is UTF-8) |
static void |
xslTransform(Document contentDom,
Document styleDom,
Writer out)
Transforms an xml with the provided xsl document and writes it to the writer. |
static String |
xslTransform(Document contentDom,
Transformer transformer,
OutputStream out)
Transforms an xml document with the provided xsl style (compiled version) and write it to the provided writer |
static void |
xslTransform(Document contentDom,
Transformer transformer,
Writer writer)
Transforms an xml document with the provided xsl style (compiled version) and write it to the provided writer |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public EboXmlUtil()
Method Detail |
public static DocumentBuilder getBuilder() throws ParserConfigurationException
public static DocumentBuilder getBuilder(boolean validation, boolean nameSpaceAware) throws ParserConfigurationException
validation
- true if validation should be turned on, otherwise use falsenameSpaceAware
- true if name space awareness should be turned on, otherwise use falsepublic static Document createDocument() throws ParserConfigurationException
public static Document createDocument(String strDoc) throws DOMException, IOException, SAXException, ParserConfigurationException
strDoc
- the string representing the xmlpublic static Document createDocument(InputStream stream) throws DOMException, IOException, SAXException, ParserConfigurationException
stream
- the InputStream that represents the XML Contentpublic static Document createDocument(byte[] bytes) throws DOMException, IOException, SAXException, ParserConfigurationException
byte[]
- that represents the XML Contentpublic static Document createDocument(InputStream stream, String encoding, boolean validation, boolean namespace) throws DOMException, IOException, SAXException, ParserConfigurationException
stream
- the stream (InputStream,...) to represent the XMLencoding
- the Char encoding that should be used to read from the streamnamespace
- use namespace awareness (true) , or not (false)validation
- use validation (true), or not (false)public static Document createDocument(Reader reader, boolean validation, boolean namespace) throws DOMException, IOException, SAXException, ParserConfigurationException
reader
- the reader pointing to the 'raw' xmlnamespace
- use namespace awareness (true) , or not (false)validation
- use validation (true), or not (false)public static Document createDocument(URL documentURL) throws IOException, SAXException, ParserConfigurationException
documentURL
- the URL pointing to the Documentpublic static Document createDocument(InputSource inputSrc, boolean isValidating, boolean isNamespaceAware, ErrorHandler errorHandler, EntityResolver entityResolver) throws DOMException, IOException, SAXException, ParserConfigurationException
inputSrc
- the InputSource representing the xmlisValidating
- the boolean determining if validating is used against the xmlisNamespaceAware
- the boolean determining if the NameSpaceAware feature is seterrorHandler
- the ErrorHandler to be used if suppliedentityResolver
- the entityResolver to be used if suppliedpublic static Node createDocumentRootNode(Document parentDocument, String nodeName, Node contentNode)
parentDocument
- the Document that will receive the new Element and the contentnodeName
- the name of the Element to createcontentNode
- the Node that will be appended as a child to the created Elementpublic static Node createDocumentRootNode(Document parentDocument, String nodeName, Node contentNode, boolean contentIsLocal)
parentDocument
- the Document that will receive the new Element and the contentnodeName
- the name of the Element to createcontentNode
- the Node that will be imported (if external) or appended (if local) as a child to the created Element (incl. subtree)contentIsLocal
- a boolean indicating wether the contentNode is external to the document and has to be imported (false), or if it can be appended (true)public static Node createNode(Document document, String nodeName, Node contentNode)
document
- Document used to create the Element (not null!)nodeName
- name of the node to be created (not null!)contentNode
- content in form of a Node to be appended as child (if not null) ; including the subtreepublic static Node createNode(Document document, String nodeName, Node contentNode, boolean contentIsLocal)
document
- Document used to create the Element (not null!)nodeName
- name of the node to be created (not null!)contentNode
- content in form of a Node to be imported or appended as child (if not null)contentIsLocal
- a boolean indicating wether the contentNode is external to the document and has to be imported (false), or if it can be appended (true)public static Node createChildNode(Node parentNode, String nodeName, Node contentNode)
parentNode
- the parent Node (not null!)nodeName
- the name for the new Element (not null!)contentNode
- org.w3c.dom.Node that contains the content to be appended (incl. subtree) to the parent Document (or null)public static Node createChildNode(Node parentNode, String nodeName, Node contentNode, boolean contentIsLocal)
parentNode
- the parent Node (not null!)nodeName
- the name for the new Element (not null!)contentNode
- org.w3c.dom.Node that contains the content to be imported (incl. subtree) or appended (if local) to the parent Document (or null)contentIsLocal
- a boolean indicating wether the contentNode is external to the document and has to be imported (false), or if it can be appended (true)public static Node createChildNode(Node parentNode, String nodeName)
nodeName
- the name for the new nodeparentNode
- the parent org.w3c.dom.Node that will receive the childpublic static Node createTextNode(Document doc, Node parentNode, String nodeName, String content)
doc
- the Document to contain the new text node (not null!)parentNode
- the Node under which the new text node should be placed (or null)nodeName
- the name of the new text node (not null!)content
- the text itselfpublic static Node createTextNode(Node parentNode, String nodeName, String content)
parentNode
- the Node under which the new text node should be placed (not null!)nodeName
- the name of the new text node (not null!)content
- the text itselfpublic static Attr createAttribute(Element el, String attributeName, String attributeValue)
el
- the element that will receive the attribute (not null!)attributeName
- name of the attribute to be created (not null!)attributeValue
- value of the attribute to be createdpublic static Attr createAttribute(Document doc, String attributeName, String attributeValue)
doc
- the Document used to create the attributeattributeName
- name of the attribute to be createdattributeValue
- value of the attribute to be createdpublic static String getAttributeValue(String attributeName, Node node)
attributeName
- the name of the attribute you want to getnode
- the Node where the attribute livespublic static Attr getAttribute(String attributeName, Node node)
attributeName
- the name of the attribute you want to getnode
- the Node where the attribute livespublic static String getElementBodyText(Node parentNode)
parentNode
- the node that contains textpublic static Node createCDATANode(Node parentNode, String nodeName, String content)
parentNode
- Node (parent) of the element to be created (not null!)nodeName
- the name you want to give your Node (or null if the textnode should be appended to the parent node directly)content
- the content of the node (the text that will be wrapped in a CDATA section)EboXmlUtil.createChildNode(Node,String)
public static Node addNodeBeforeSibling(Node siblingNode, String nodeName, Node content)
siblingNode
- the node that will be used as reference; the new element will be inserted before this nodenodeName
- the name of the element to createcontent
- any subtree that will be appended as child of the new element (if != null)public static Node addNodeBeforeSibling(Node siblingNode, String nodeName, Node content, boolean contentIsLocal)
siblingNode
- the node that will be used as reference; the new element will be inserted before this nodenodeName
- the name of the element to create (or null; if null, content needs to be not null!)content
- any subtree that will be imported or appended (if local) as child of the new element (if != null)contentIsLocal
- a boolean indicating wether the contentNode is external to the document and has to be imported (false), or if it can be appended (true)public static Node addNodeAfterSibling(Node siblingNode, String nodeName, Node content)
siblingNode
- the node that will be used as reference; the new element will be inserted after this nodenodeName
- the name of the element to create (or null; if null, content needs to be not null!)content
- any subtree that will be imported or appended (if local) as child of the new element (if != null)public static Node addNodeAfterSibling(Node siblingNode, String nodeName, Node content, boolean contentIsLocal)
siblingNode
- the node that will be used as reference; the new element will be inserted after this nodenodeName
- the name of the element to create (or null; if null, content needs to be not null!)content
- any subtree that will be imported or appended (if local) as child of the new element (if != null)contentIsLocal
- a boolean indicating wether the contentNode is external to the document and has to be imported (false), or if it can be appended (true)public static Node appendChildNode(Node parentNode, Node contentNode)
parentNode
- the Node under which the content should be placed (not null!)contentNode
- the Node (not null!) that will be imported as a child to the created Node (incl. subtree)public static Node appendChildNode(Node parentNode, Node contentNode, boolean contentIsLocal)
parentNode
- the Node under which the content should be placed (not null!)contentNode
- the Node (not null!) that will be imported as a child to the created Node (incl. subtree)contentIsLocal
- a boolean indicating wether the contentNode is external to the document and has to be imported (false), or if it can be appended (true)public static void serialize(Node doc, OutputStream output) throws IOException, TransformerConfigurationException, TransformerException
doc
- Document (-fragment) to be serializedoutput
- the OutputStream to write topublic static void serialize(Node doc, OutputStream output, Transformer transformer) throws IOException, TransformerConfigurationException, TransformerException
doc
- Document (-fragment) to be serializedoutput
- the OutputStream to write totransformer
- the transformer to usepublic static void serialize(Node doc, Writer writer) throws IOException, TransformerConfigurationException, TransformerException
doc
- Document (-fragment) to be serializedwriter
- the writer to write topublic static void serialize(Node doc, Writer writer, Transformer transformer) throws IOException, TransformerConfigurationException, TransformerException
doc
- Document (-fragment) to be serializedwriter
- the writer to write totransformer
- the transformer to usepublic static String serialize(Node doc) throws IOException, TransformerConfigurationException, TransformerException
doc
- Document (-fragment) to be serializedpublic static String serialize(Node doc, Transformer transformer) throws IOException, TransformerConfigurationException, TransformerException
doc
- Document (-fragment) to be serializedtransformer
- the transformer to usepublic static Node addDirectiveToXSL(Document xslDom, String directiveName, String attributeName, String attributeValue) throws TransformerException
xslDom
- the DOM representation of the XSL style sheetdirectiveName
- the tag name (@see #DIRECTIVE_INCLUDE and #DIRECTIVE_IMPORT)attributeName
- the name of an attribute to create, or nullattributeValue
- the value for the attribute, or nullpublic static Node addDirectiveToXSLBeforeSibling(Node sibling, String directiveName, String attributeName, String attributeValue)
sibling
- the node before which the new node will be added as a sibling (same level)directiveName
- (@see #DIRECTIVE_INCLUDE and #DIRECTIVE_IMPORT)attributeName
- the name of an attribute to create, or nullattributeValue
- the value for the attribute, or nullpublic static void xslTransform(Document contentDom, Document styleDom, Writer out) throws TransformerException, TransformerConfigurationException, FileNotFoundException, IOException
contentDom
- the document to be transformedstyleDom
- the style to apply to the contentout
- the writer to write the result topublic static String xslTransform(Document contentDom, Transformer transformer, OutputStream out) throws TransformerException, TransformerConfigurationException, FileNotFoundException, IOException
contentDom
- the document to be transformedtransformer
- the compiled xsl style sheet that will be applied to the content documentout
- the OutputStream to write the result toNote: you can set that encoding via #Transformer.getOutputProperties().setProperty("encoding", String); or in you xsl style sheet via xsl:output encoding="your encoding here" .....; the default encoding is UTF-8
public static void xslTransform(Document contentDom, Transformer transformer, Writer writer) throws TransformerException, TransformerConfigurationException, FileNotFoundException, IOException
contentDom
- the document to be transformedtransformer
- the compiled xsl style sheet that will be applied to the content documentwriter
- the writer to write the result topublic static Transformer getTransformer() throws TransformerConfigurationException
public static Transformer getTransformer(Properties transProps) throws TransformerConfigurationException
transProps
- a Porperties file containing the desired Output propertiespublic static Transformer getTransformer(Source strSource) throws TransformerConfigurationException
strSource
- a Source (StreamSource, DOMSource, SAXSource) representing the style we need the Transformer forpublic static Transformer getTransformer(Templates templates) throws TransformerConfigurationException
templates
- the pre compile xsl style sheetpublic static Transformer getTransformer(Document doc) throws TransformerException, IOException
doc
- a document representing the style we need the Transformer forpublic static Templates getTemplates(Source source) throws TransformerConfigurationException
source
- a StreamSource, DOMSource, ... that contains the xsl style sheet to compile
|
Novell exteNd Director 5.2 API |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |