public class XMLTools
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.util.Comparator<javax.xml.namespace.QName> |
QNameComparatorINSTANCE
The Q name comparator instance.
|
static java.util.Comparator<net.sf.saxon.s9api.QName> |
SxQNameComparatorINSTANCE
The Q name comparator instance.
|
Modifier and Type | Method and Description |
---|---|
static void |
closeCloseableSilently(java.io.Closeable is)
Close closeable silently.
|
static void |
closeSource(javax.xml.transform.Source source)
Tries to close a source used to process an XML file.
|
static java.lang.String |
colorizeXML(java.lang.String xml)
This method prepares an HTML representation of the incoming text with nice colors on element names
attribute names, attribute values and element values.
|
static boolean |
effectiveBooleanValue(net.sf.saxon.value.AtomicValue atVal)
Effective boolean value.
|
static javax.xml.namespace.QName |
enumStringToQName(java.lang.String value)
Transforms an expanded name URI value into a QName
The Extensible Enumerations 2.0 specification expresses an XML expanded name as the combination
of a namespace name (an absolute URI reference [URI]) and a local part, separated by the '#'
character.
|
static java.lang.String |
getNamespaceURIforPrefix(java.lang.String pfx,
net.sf.saxon.s9api.XdmNode node)
Gets the namespace ur ifor prefix.
|
static java.lang.String |
indentXML(java.lang.String xml)
This method transforms XML in a string into the same XML but
adding line breaks on every attribute so it can be represented
in a not very wide text control.
|
static boolean |
inSubstitutionGroup(XMLFragment from,
javax.xml.namespace.QName qName)
returns true if the XMLFragment in the from parameter is in the
substitution group of the QName indicated in the qName parameter.
|
static boolean |
isEmpty(net.sf.saxon.s9api.XdmValue value)
Returns true if the value is empty.
|
static boolean |
isNullOrEmpty(javax.xml.namespace.QName value)
Returns true if the value is null or empty.
|
static boolean |
isNullOrEmpty(net.sf.saxon.s9api.QName value)
Returns true if the value is null or empty.
|
static boolean |
isNullOrEmpty(java.lang.String value)
Returns true if the value is null or empty.
|
static boolean |
isNullOrEmpty(net.sf.saxon.s9api.XdmValue value)
Returns true if the value is null or empty.
|
static javax.xml.namespace.QName |
javaxQName(int fp,
DTSContainer container)
Builds up a QName form the received fingerprint using the name pool
associated with the container.
|
static javax.xml.namespace.QName |
javaxQName(int fp,
net.sf.saxon.om.NamePool np)
Builds up a QName form the received fingerprint using the name pool
in the np parameter.
|
static javax.xml.namespace.QName |
javaxQName(net.sf.saxon.om.NodeInfo node)
Constructs a QName from an NodeInfo that is well known
to have a QName content.
|
static javax.xml.namespace.QName |
javaxQName(net.sf.saxon.s9api.QName qname)
Creates a new javax QName from a saxon QName.
|
static javax.xml.namespace.QName |
javaxQName(net.sf.saxon.value.QNameValue qname)
Creates a new javax QName from a saxon QName.
|
static javax.xml.namespace.QName |
javaxQName(java.lang.String value,
net.sf.saxon.om.NodeInfo node)
Constructs a QName using the lexical representation in the value argument and
namespaces defined at NodeInfo node.
|
static javax.xml.namespace.QName |
javaxQName(java.lang.String value,
net.sf.saxon.s9api.XdmNode node)
Constructs a QName using the lexical representation in the value argument and
namespaces defined at XdmNode node.
|
static javax.xml.namespace.QName |
javaxQName(net.sf.saxon.om.StructuredQName qname)
Creates a new javax QName from a saxon QName.
|
static javax.xml.namespace.QName |
javaxQName(net.sf.saxon.s9api.XdmNode node)
Constructs a QName from an attribute XdmNode or an element that is well known
to have a QName content.
|
static javax.xml.namespace.QName |
javaxQnameNodeName(net.sf.saxon.om.NodeInfo node)
Obtains the node name from a NodeImpl node.
|
static java.lang.String |
jClark(javax.xml.namespace.QName q)
Generates a JClark representation of the QName as a String.
|
static java.lang.String |
jClarkNoPrefix(javax.xml.namespace.QName q)
Generates a JClark representation of the QName as a String.
|
static net.sf.saxon.om.FingerprintedQName |
makeFingerprintedQName(net.sf.saxon.om.NamePool np,
java.lang.String pfx,
java.lang.String namespaceURI,
java.lang.String localName)
Makes a fast to compare (equals()) FingerprinterQName.
|
static net.sf.saxon.s9api.DocumentBuilder |
newDocumentBuilder(net.sf.saxon.s9api.Processor proc,
net.sf.saxon.om.TreeModel treeModel,
net.sf.saxon.s9api.SchemaValidator schemaValidator)
Generates a new document builder.
|
static net.sf.saxon.s9api.Processor |
newProcessor(boolean licensedEdition)
Generates a new saxonica processor.
|
static void |
noop()
Noop to avoid "Empty control-flow statement" compiler Warnings.
|
static void |
noopExceptionIgnored(java.lang.Exception e)
Noop to avoid "Empty control-flow statement" compiler Warnings.
|
static void |
noopThrowableIgnored(java.lang.Throwable e)
Noop to avoid "Empty control-flow statement" compiler Warnings.
|
static void |
preventDeadLocks()
This method makes sure the class net.sf.saxon.functions.StandardFunction
and the class net.sf.saxon.expr.Expression has been
loaded by the same thread.
|
static javax.xml.namespace.QName |
qnameFromJClark(java.lang.String clarkQName)
builds back a QName instance from the jClark representation.
|
static java.lang.String |
qnamesToString(java.util.Collection<javax.xml.namespace.QName> qnames)
Concatenates a Collection of QName values in a single string separating all them with commas except
the last one that is separated using "and" localized to either Spanish or English .
|
static java.lang.String |
qnameToString(javax.xml.namespace.QName q)
Serializes the QName as a string using the prefix:localName
if prefix is not defined then this method uses {namespace}:localName
.
|
static java.lang.String |
qnameToString2(javax.xml.namespace.QName q)
Serializes the QName as a string using the prefix:localName
if prefix is not defined then this method uses statically defined
prefixes in the XBRLNamespaceContext class
if prefix is still not defined, this method uses localName only
if prefix is null, the returned value is QName(?).
|
static java.lang.String |
qnameToString3(javax.xml.namespace.QName q)
Serializes the QName as a string using the prefix:localName
if prefix is not defined, this method uses localName only
if q is null, the returned value is QName(?).
|
static net.sf.saxon.value.QNameValue |
qnameValue(javax.xml.namespace.QName q)
Qname value.
|
static void |
removeLineNumbering(net.sf.saxon.tree.linked.DocumentImpl dni)
uses reflection to remove line numberig information and save memory.
|
static java.lang.String |
removeNamespaceDeclarations(java.lang.String string)
This method removes namespace declarations from the incoming string.
|
static java.lang.String |
replaceExpressionsWithVariableValues(java.lang.String xpathExpression,
TraceVariablesBind variableBinds)
This method will replace variables in the xpathExpression with the evaluated values from the TraceVariablesBind
The variable comparison is not perfect because at this time the input xpath expression is just a string
so there is no way to determine the right namespace link to variables in the variables has a prefix.
|
static java.lang.String |
replaceExpressionsWithVariableValuesInHTML(java.lang.String xpathExpression,
TraceVariablesBind variableBinds,
KeysForFactsProvider kp,
LabelsProvider lp)
This method works the same as
replaceExpressionsWithVariableValues(String, TraceVariablesBind) but when
a variable was bind to a fact variable a link to the fact variable is created so the GUI can resolve the variable
reference |
static net.sf.saxon.om.NodeInfo |
rootNode(net.sf.saxon.om.DocumentInfo ni)
Returns the root node of a DocumentInfo node.
|
static net.sf.saxon.s9api.XdmNode |
rootNode(net.sf.saxon.s9api.XdmNode document)
Returns the root node of a DocumentInfo node encapsulated inside an XdmNode.
|
static void |
saveDocumentFile(java.io.File f,
net.sf.saxon.s9api.XdmNode doc)
Saves the XdmNode doc to disk File f.
|
static void |
saveDocumentFile(java.io.File f,
XMLDocumentImpl doc)
Saves the XMLDocumentImpl doc to disk File f.
|
static void |
saveDocumentOutputStream(java.io.OutputStream os,
XMLDocumentImpl doc)
Writes the XMLDocumentImpl doc to OutputStream.
|
static net.sf.saxon.om.CodedName |
saxonCodedName(javax.xml.namespace.QName qName,
net.sf.saxon.om.NamePool np)
Obtains a CodedName (that is also a NodeName) from a namepool and a javax.xml.namespace.QName
the benefit of CodedName is that they use less memory footprint
|
static net.sf.saxon.om.FingerprintedQName |
saxonFpQName(javax.xml.namespace.QName qName)
Saxon fp q name.
|
static net.sf.saxon.s9api.QName |
saxonQName(javax.xml.namespace.QName qname)
Creates a new saxon QName from a javax QName.
|
static net.sf.saxon.s9api.QName |
saxonQName(net.sf.saxon.value.QNameValue attribute)
Saxon q name.
|
static void |
serializeDocument(java.util.Properties props,
net.sf.saxon.tree.linked.DocumentImpl doc,
javax.xml.transform.Result res)
Serialize document.
|
static void |
setSiblingPosition(net.sf.saxon.tree.linked.NodeImpl node,
int index)
This is necessary because NodeImpl.setSiblingPosition() is final protected.
|
static net.sf.saxon.om.StructuredQName |
structuredQName(javax.xml.namespace.QName qName)
Structured q name.
|
public static java.util.Comparator<javax.xml.namespace.QName> QNameComparatorINSTANCE
public static java.util.Comparator<net.sf.saxon.s9api.QName> SxQNameComparatorINSTANCE
public static void preventDeadLocks()
public static net.sf.saxon.s9api.Processor newProcessor(boolean licensedEdition)
licensedEdition
- the licensed editionpublic static net.sf.saxon.om.FingerprintedQName makeFingerprintedQName(net.sf.saxon.om.NamePool np, java.lang.String pfx, java.lang.String namespaceURI, java.lang.String localName)
np
- the name poolpfx
- the prefixnamespaceURI
- the namespace urilocalName
- the local namepublic static net.sf.saxon.s9api.DocumentBuilder newDocumentBuilder(net.sf.saxon.s9api.Processor proc, net.sf.saxon.om.TreeModel treeModel, net.sf.saxon.s9api.SchemaValidator schemaValidator)
proc
- the saxonica processortreeModel
- the saxonica tree modelschemaValidator
- the schema validator, may be nullpublic static net.sf.saxon.s9api.QName saxonQName(javax.xml.namespace.QName qname)
qname
- in the javax librarypublic static javax.xml.namespace.QName javaxQName(net.sf.saxon.s9api.QName qname)
qname
- in the Saxon librarypublic static javax.xml.namespace.QName javaxQName(net.sf.saxon.value.QNameValue qname)
qname
- in the Saxon value librarypublic static javax.xml.namespace.QName javaxQName(net.sf.saxon.om.StructuredQName qname)
qname
- in the Saxon value librarypublic static javax.xml.namespace.QName javaxQName(net.sf.saxon.s9api.XdmNode node)
node
- the nodepublic static javax.xml.namespace.QName javaxQName(net.sf.saxon.om.NodeInfo node)
node
- the nodepublic static javax.xml.namespace.QName javaxQName(java.lang.String value, net.sf.saxon.s9api.XdmNode node)
value
- the valuenode
- the nodepublic static javax.xml.namespace.QName javaxQName(java.lang.String value, net.sf.saxon.om.NodeInfo node)
value
- the valuenode
- the nodepublic static boolean effectiveBooleanValue(net.sf.saxon.value.AtomicValue atVal)
atVal
- the at valpublic static net.sf.saxon.value.QNameValue qnameValue(javax.xml.namespace.QName q)
q
- the qpublic static java.lang.String getNamespaceURIforPrefix(java.lang.String pfx, net.sf.saxon.s9api.XdmNode node)
pfx
- the pfxnode
- the nodepublic static net.sf.saxon.om.StructuredQName structuredQName(javax.xml.namespace.QName qName)
qName
- the q namepublic static net.sf.saxon.om.FingerprintedQName saxonFpQName(javax.xml.namespace.QName qName)
qName
- the q namepublic static net.sf.saxon.om.CodedName saxonCodedName(javax.xml.namespace.QName qName, net.sf.saxon.om.NamePool np)
qName
- the q namenp
- the nppublic static java.lang.String qnameToString(javax.xml.namespace.QName q)
if prefix is not defined then this method uses {namespace}:localName
.
q
- the qpublic static java.lang.String jClark(javax.xml.namespace.QName q)
The JClark representation consist of the {namespaceuri}prefix:localname where namespaceuri might not exists when the QName has no namespace the prexix (and the colon) might not exists if the QName contains no prefix
This should be the same as QName.toString() but we may want to implement this consistently for other QNames too so we have own own implementation
q
- the qpublic static java.lang.String jClarkNoPrefix(javax.xml.namespace.QName q)
The JClark representation consist of the {namespaceuri}localname where namespaceuri might not exists when the QName has no namespace the will not exists
This should be the same as QName.toString() but we may want to implement this consistently for other QNames too so we have own own implementation
q
- the qpublic static javax.xml.namespace.QName qnameFromJClark(java.lang.String clarkQName)
clarkQName
- the clark q namepublic static java.lang.String qnameToString2(javax.xml.namespace.QName q)
if prefix is not defined then this method uses statically defined prefixes in the XBRLNamespaceContext class
if prefix is still not defined, this method uses localName only
if prefix is null, the returned value is QName(?).
q
- the qqnameToString(QName)
,
qnameToString3(QName)
public static java.lang.String qnameToString3(javax.xml.namespace.QName q)
if prefix is not defined, this method uses localName only
if q is null, the returned value is QName(?).
q
- the qqnameToString(QName)
,
qnameToString2(QName)
public static java.lang.String indentXML(java.lang.String xml)
xml
- the xmlpublic static java.lang.String qnamesToString(java.util.Collection<javax.xml.namespace.QName> qnames)
qnames
- the qnamespublic static java.lang.String colorizeXML(java.lang.String xml)
If the incoming element is
<foo:whatever name="fooname">value</foo:whatever>
the returned value representation is
<foo:whatever name="fooname">value</foo:whatever>
xml
- the xmlpublic static java.lang.String removeNamespaceDeclarations(java.lang.String string)
string
- this is a valid XML string including xmlns:XXXXX="whatever" declarations.public static java.lang.String replaceExpressionsWithVariableValues(java.lang.String xpathExpression, TraceVariablesBind variableBinds)
xpathExpression
- the xpath expressionvariableBinds
- the variable bindspublic static java.lang.String replaceExpressionsWithVariableValuesInHTML(java.lang.String xpathExpression, TraceVariablesBind variableBinds, KeysForFactsProvider kp, LabelsProvider lp)
replaceExpressionsWithVariableValues(String, TraceVariablesBind)
but when
a variable was bind to a fact variable a link to the fact variable is created so the GUI can resolve the variable
referencexpathExpression
- the xpath expressionvariableBinds
- the variable bindskp
- the kplp
- the lppublic static net.sf.saxon.s9api.QName saxonQName(net.sf.saxon.value.QNameValue attribute)
attribute
- the attributepublic static boolean isNullOrEmpty(net.sf.saxon.s9api.XdmValue value)
value
- the valuepublic static boolean isNullOrEmpty(javax.xml.namespace.QName value)
value
- the valuepublic static boolean isNullOrEmpty(net.sf.saxon.s9api.QName value)
value
- the valuepublic static boolean isNullOrEmpty(java.lang.String value)
value
- the valuepublic static boolean isEmpty(net.sf.saxon.s9api.XdmValue value)
value
- the valuepublic static void closeCloseableSilently(java.io.Closeable is)
is
- the ispublic static void closeSource(javax.xml.transform.Source source)
source
- the sourcepublic static net.sf.saxon.s9api.XdmNode rootNode(net.sf.saxon.s9api.XdmNode document)
document
- XdmNode wrapping a DocumentInfopublic static net.sf.saxon.om.NodeInfo rootNode(net.sf.saxon.om.DocumentInfo ni)
ni
- the nipublic static void noop()
public static void noopThrowableIgnored(java.lang.Throwable e)
e
- the epublic static void noopExceptionIgnored(java.lang.Exception e)
e
- the epublic static void removeLineNumbering(net.sf.saxon.tree.linked.DocumentImpl dni)
dni
- the dnipublic static void saveDocumentFile(java.io.File f, XMLDocumentImpl doc) throws java.io.IOException
f
- the Filedoc
- the XMLDocumentImpljava.io.IOException
- Signals that an I/O exception has occurred.public static void saveDocumentOutputStream(java.io.OutputStream os, XMLDocumentImpl doc) throws java.io.IOException
os
- the OutputStream where the document will be writtendoc
- the XMLDocumentImpljava.io.IOException
- Signals that an I/O exception has occurred.public static void serializeDocument(java.util.Properties props, net.sf.saxon.tree.linked.DocumentImpl doc, javax.xml.transform.Result res)
props
- the propsdoc
- the docres
- the respublic static void saveDocumentFile(java.io.File f, net.sf.saxon.s9api.XdmNode doc) throws java.io.FileNotFoundException, java.io.IOException
f
- the Filedoc
- the XdmNodejava.io.FileNotFoundException
- the file not found exceptionjava.io.IOException
- Signals that an I/O exception has occurred.public static boolean inSubstitutionGroup(XMLFragment from, javax.xml.namespace.QName qName)
from
- the XMLFragment to checkqName
- the substitution grouppublic static javax.xml.namespace.QName javaxQName(int fp, DTSContainer container)
fp
- name code fingerprintcontainer
- DTSContainer instance to grap the NanePool frompublic static javax.xml.namespace.QName javaxQName(int fp, net.sf.saxon.om.NamePool np)
fp
- name code fingerprintnp
- the nppublic static javax.xml.namespace.QName javaxQnameNodeName(net.sf.saxon.om.NodeInfo node)
node
- the nodepublic static void setSiblingPosition(net.sf.saxon.tree.linked.NodeImpl node, int index)
node
- the nodeindex
- the indexpublic static javax.xml.namespace.QName enumStringToQName(java.lang.String value)
value
- as StringCopyright 2006-2015 Reporting Standard S.L., C/ Torrecilla del Puerto 1, 28043, Madrid, Espaņa