com.ihr.xbrl.util
Class XMLTools

java.lang.Object
  extended by com.ihr.xbrl.util.XMLTools

public class XMLTools
extends java.lang.Object

Static helper methods to deal with common XML issues

Author:
Ignacio

Constructor Summary
XMLTools()
           
 
Method Summary
static boolean effectiveBooleanValue(net.sf.saxon.value.AtomicValue atVal)
           
static java.lang.String getNamespaceURIforPrefix(java.lang.String pfx, net.sf.saxon.s9api.XdmNode node)
           
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.s9api.XdmNode node)
           
static javax.xml.namespace.QName javaxQName(net.sf.saxon.om.StructuredQName qname)
           
static java.lang.Object jdomNode(net.sf.saxon.s9api.XdmNode node)
           
static java.util.Collection<?> jdomNodeSet(net.sf.saxon.s9api.XdmSequenceIterator iter)
           
static java.util.Collection<?> jdomNodeSet(net.sf.saxon.s9api.XdmValue descriptionNodes)
           
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 net.sf.saxon.value.QNameValue qnameValue(javax.xml.namespace.QName q)
           
static java.lang.String removeNamespaceDeclarations(java.lang.String string)
          This method removes namespace declarations from the incoming string.
static net.sf.saxon.s9api.QName saxonQName(javax.xml.namespace.QName qname)
          Creates a new saxon QName from a javax QName
static void setJDomElementValue(org.jdom.Element jdomNode, java.lang.Object value)
          Sets to jdomNode the value after the required conversions depending on the object type.
static net.sf.saxon.om.StructuredQName structuredQName(javax.xml.namespace.QName qName)
           
static java.util.Collection<?> textToJDomNodes(java.lang.String string)
          Returns a collection of text and Element nodes transforming the content of the string parameter accordingly
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLTools

public XMLTools()
Method Detail

saxonQName

public static net.sf.saxon.s9api.QName saxonQName(javax.xml.namespace.QName qname)
Creates a new saxon QName from a javax QName

Parameters:
qname - in the javax library
Returns:
QName in the Saxon library

javaxQName

public static javax.xml.namespace.QName javaxQName(net.sf.saxon.s9api.QName qname)
Creates a new javax QName from a saxon QName

Parameters:
qname - in the Saxon library
Returns:
QName in the javax library

javaxQName

public static javax.xml.namespace.QName javaxQName(net.sf.saxon.value.QNameValue qname)
Creates a new javax QName from a saxon QName

Parameters:
qname - in the Saxon value library
Returns:
QName in the javax library

javaxQName

public static javax.xml.namespace.QName javaxQName(java.lang.String value,
                                                   net.sf.saxon.s9api.XdmNode node)
Parameters:
value -
node -
Returns:

effectiveBooleanValue

public static boolean effectiveBooleanValue(net.sf.saxon.value.AtomicValue atVal)
Parameters:
atVal -
Returns:

qnameValue

public static net.sf.saxon.value.QNameValue qnameValue(javax.xml.namespace.QName q)
Parameters:
nodeName -
Returns:

jdomNodeSet

public static java.util.Collection<?> jdomNodeSet(net.sf.saxon.s9api.XdmValue descriptionNodes)
Parameters:
descriptionNodes -
Returns:

jdomNodeSet

public static java.util.Collection<?> jdomNodeSet(net.sf.saxon.s9api.XdmSequenceIterator iter)

jdomNode

public static java.lang.Object jdomNode(net.sf.saxon.s9api.XdmNode node)
Parameters:
node -
Returns:
org.jdom.Element or org.jdom.Text depending on the node type

getNamespaceURIforPrefix

public static java.lang.String getNamespaceURIforPrefix(java.lang.String pfx,
                                                        net.sf.saxon.s9api.XdmNode node)
Parameters:
pfx -
errorNode -
Returns:

javaxQName

public static javax.xml.namespace.QName javaxQName(net.sf.saxon.om.StructuredQName qname)
Parameters:
next -
Returns:

structuredQName

public static net.sf.saxon.om.StructuredQName structuredQName(javax.xml.namespace.QName qName)
Parameters:
qName -
Returns:

qnameToString

public 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

Parameters:
q -
Returns:

setJDomElementValue

public static void setJDomElementValue(org.jdom.Element jdomNode,
                                       java.lang.Object value)
Sets to jdomNode the value after the required conversions depending on the object type.

if value is null, jdom node content is unset.
if value is a String, BigDecimal, BigInteger, Double, Float, Boolean, QName or net.sf.saxon.s9api.QName the value is converted to a string using the toString or toPlainString methods. if valule is a QName, namespaces may be added to the node. if value is not any of the previously value types, the toString method is used on the value object.

Parameters:
jdomNode - as org.jdom.Element
value - as Object

textToJDomNodes

public static java.util.Collection<?> textToJDomNodes(java.lang.String string)
                                               throws org.jdom.JDOMException
Returns a collection of text and Element nodes transforming the content of the string parameter accordingly

Parameters:
string -
Returns:
Throws:
org.jdom.JDOMException

removeNamespaceDeclarations

public static java.lang.String removeNamespaceDeclarations(java.lang.String string)
This method removes namespace declarations from the incoming string. This method is useful only to show raw XML on a small text container in the user interface.

Parameters:
string - this is a valid XML string including xmlns:XXXXX="whatever" declarations.
Returns:
a string that contains all xmlns:XXXXX="whatever" declarations stripped off.


Copyright 2006-2009 Reporting Standard S.L., C/ Torrecilla del Puerto 1, 28043, Madrid, Espaņa