public class XmlUtil extends Object
Modifier and Type | Field and Description |
---|---|
static org.apache.xmlbeans.XmlOptions |
FAST |
static org.apache.xmlbeans.XmlOptions |
NO_XML_FRAGMENTS |
static org.apache.xmlbeans.XmlOptions |
PRETTYPRINT |
Constructor and Description |
---|
XmlUtil() |
Modifier and Type | Method and Description |
---|---|
static org.apache.xmlbeans.XmlObject[] |
execQuery(String path,
org.apache.xmlbeans.XmlObject xo)
This method allows XQuery expressions with XmlBeans 2.4.0+
It uses a wrapper to access Saxon-HE 9.4.0.6
|
static org.apache.xmlbeans.XmlObject[] |
execQuery(String path,
org.apache.xmlbeans.XmlObject xo,
org.apache.xmlbeans.XmlOptions opts)
This method allows XQuery expressions with XmlBeans 2.4.0+
It uses a wrapper to access Saxon-HE 9.4.0.6
|
static Node |
getDomNode(org.apache.xmlbeans.XmlObject input)
Builds an org.w3c.dom.Node from a
XmlObject . |
static Node |
getDomNode(org.apache.xmlbeans.XmlObject xmlobj,
String name)
Mechanism to find an xml element by its name in a given
XmlObject . |
static String |
getElement(org.apache.xmlbeans.XmlObject doc,
String element)
Extracts an element from an xml doc.
|
static QName |
getElementType(org.apache.xmlbeans.XmlObject xml) |
static String |
getTextContentFromAnyNode(org.apache.xmlbeans.XmlObject xmlAnyElement) |
static String |
getTextContentFromXml(org.apache.xmlbeans.XmlObject xmlElement) |
static org.apache.xmlbeans.XmlObject |
getXmlAnyNodeFrom(org.apache.xmlbeans.XmlObject xml,
String nodeName) |
static String |
objectToString(org.apache.xmlbeans.XmlObject doc) |
static String |
objectToString(org.apache.xmlbeans.XmlObject doc,
boolean validate) |
static String |
objectToString(org.apache.xmlbeans.XmlObject doc,
boolean validate,
boolean prettyprint) |
static org.apache.xmlbeans.XmlObject |
qualifySubstitutionGroup(org.apache.xmlbeans.XmlObject xobj,
QName newInstance) |
static org.apache.xmlbeans.XmlObject |
qualifySubstitutionGroup(org.apache.xmlbeans.XmlObject xobj,
QName newInstance,
org.apache.xmlbeans.SchemaType newType)
Qualifies a valid member of a substitution group.
|
static org.apache.xmlbeans.XmlObject[] |
selectPath(String path,
org.apache.xmlbeans.XmlObject xo)
This method allows XPath 2.0 expressions with XmlBeans 2.4.0+
It uses a wrapper to access Saxon-HE 9.4.0.6
|
static org.apache.xmlbeans.XmlObject[] |
selectPath(String path,
org.apache.xmlbeans.XmlObject xo,
org.apache.xmlbeans.XmlOptions opts)
This method allows XPath 2.0 expressions with XmlBeans 2.4.0+
It uses a wrapper to access Saxon-HE 9.4.0.6
|
static org.apache.xmlbeans.XmlObject |
setTextContent(org.apache.xmlbeans.XmlObject xmlObject,
String content) |
static String |
stripText(org.apache.xmlbeans.XmlObject elem) |
static String |
stripText(org.apache.xmlbeans.XmlObject[] elems)
Strips out the text of an xml-element and returns as a String.
|
static String |
toString(Node xml)
|
static void |
writeObject(org.apache.xmlbeans.XmlObject doc,
PrintWriter out)
Writes a document with the given
PrintWriter |
static void |
writeObject(org.apache.xmlbeans.XmlObject doc,
PrintWriter out,
boolean validate)
Writes a document with the given
PrintWriter |
public static final org.apache.xmlbeans.XmlOptions NO_XML_FRAGMENTS
public static final org.apache.xmlbeans.XmlOptions PRETTYPRINT
public static final org.apache.xmlbeans.XmlOptions FAST
public static org.apache.xmlbeans.XmlObject getXmlAnyNodeFrom(org.apache.xmlbeans.XmlObject xml, String nodeName) throws org.apache.xmlbeans.XmlException
xml
- the node containing xmlnodeName
- the node's name of the DOM nodeXmlObject
representation of the body, or null
if node could
not be found.org.apache.xmlbeans.XmlException
- if parsing to XML failspublic static Node getDomNode(org.apache.xmlbeans.XmlObject xmlobj, String name) throws org.apache.xmlbeans.XmlException
XmlObject
.
Node
.xmlobj
- the xml object which contains the <name> element.name
- the xml element which shall be found.Node
which can further be parsed .org.apache.xmlbeans.XmlException
- if DOM node of xmlobj
is null
.public static String getElement(org.apache.xmlbeans.XmlObject doc, String element) throws XMLHandlingException
doc
- The xml elementelement
- the name of the Method, for example getUom
XMLHandlingException
- thrown if the XML is incorrectpublic static String objectToString(org.apache.xmlbeans.XmlObject doc) throws XMLHandlingException
doc
- XmlBeans objectXMLHandlingException
- thrown if the XML is incorrectpublic static String objectToString(org.apache.xmlbeans.XmlObject doc, boolean validate) throws XMLHandlingException
doc
- XmlBeans objectvalidate
- validate the document?XMLHandlingException
- thrown if the XML is incorrectpublic static String objectToString(org.apache.xmlbeans.XmlObject doc, boolean validate, boolean prettyprint) throws XMLHandlingException
doc
- XmlBeans objectvalidate
- validate the object?prettyprint
- Output in pretty print mode?XMLHandlingException
- thrown if the XML is incorrectpublic static void writeObject(org.apache.xmlbeans.XmlObject doc, PrintWriter out) throws IOException
PrintWriter
doc
- the document to writeout
- the print writerIOException
- thrown if an IO error occurredpublic static void writeObject(org.apache.xmlbeans.XmlObject doc, PrintWriter out, boolean validate) throws IOException, XMLHandlingException
PrintWriter
doc
- the document to writeout
- the print writervalidate
- validate the document?IOException
- thrown if an IO error occurredXMLHandlingException
- thrown if the XML is incorrectpublic static Node getDomNode(org.apache.xmlbeans.XmlObject input) throws XMLHandlingException
XmlObject
.input
- the event documentXMLHandlingException
- if a problem during XML handling occurs.public static org.apache.xmlbeans.XmlObject qualifySubstitutionGroup(org.apache.xmlbeans.XmlObject xobj, QName newInstance)
xobj
- the XmlObject to substitutenewInstance
- the element to substitute towith SchemaType=null.
public static org.apache.xmlbeans.XmlObject qualifySubstitutionGroup(org.apache.xmlbeans.XmlObject xobj, QName newInstance, org.apache.xmlbeans.SchemaType newType)
XmlObject.substitute(QName, SchemaType)
and if succesful returns
a valid substitution which is usable (not disconnected). If it fails, it uses
low-level XmlCursor
manipulation to qualify the substitution group. Note
that if the latter is the case the resulting document is disconnected and should
no longer be manipulated. Thus, use it as a final step after all markup is included.
If newType is null, this method will skip XmlObject.substitute(QName, SchemaType)
and directly use XmlCursor
. This can be used, if you are sure that the substitute
is not in the list of (pre-compiled) valid substitutions (this is the case if a schema
uses another schema's type as a base for elements. E.g. om:Observation uses gml:_Feature
as the base type).xobj
- the abstract elementnewInstance
- the new QName
of the instancenewType
- the new schemaType. if null, cursors will be used and the resulting object
will be disconnected.XmlObject.substitute(QName, SchemaType)
a living object with a
type == newType is returned. Otherwise null is returned as you can no longer manipulate the object.public static String stripText(org.apache.xmlbeans.XmlObject[] elems)
elems
- array of elementspublic static String stripText(org.apache.xmlbeans.XmlObject elem)
elem
- the text-containing elementpublic static org.apache.xmlbeans.XmlObject[] selectPath(String path, org.apache.xmlbeans.XmlObject xo)
path
- the XPath expressionxo
- the Xmlobjectpublic static org.apache.xmlbeans.XmlObject[] selectPath(String path, org.apache.xmlbeans.XmlObject xo, org.apache.xmlbeans.XmlOptions opts)
path
- the XPath expressionxo
- the Xmlobjectopts
- XmlOptionspublic static org.apache.xmlbeans.XmlObject[] execQuery(String path, org.apache.xmlbeans.XmlObject xo)
path
- the XQuery expressionxo
- the Xmlobjectpublic static org.apache.xmlbeans.XmlObject[] execQuery(String path, org.apache.xmlbeans.XmlObject xo, org.apache.xmlbeans.XmlOptions opts)
path
- the XQuery expressionxo
- the Xmlobjectopts
- XmlOptionspublic static QName getElementType(org.apache.xmlbeans.XmlObject xml)
public static String getTextContentFromXml(org.apache.xmlbeans.XmlObject xmlElement)
public static String getTextContentFromAnyNode(org.apache.xmlbeans.XmlObject xmlAnyElement)
public static org.apache.xmlbeans.XmlObject setTextContent(org.apache.xmlbeans.XmlObject xmlObject, String content)
Copyright © 2012–2017 52North Initiative for Geospatial Open Source Software GmbH. All rights reserved.