org.apache.ode.utils
Class XMLParserUtils

java.lang.Object
  extended by org.apache.ode.utils.XMLParserUtils

public class XMLParserUtils
extends java.lang.Object

A collection of utility methods for the Apache Xerces XML parser.


Field Summary
static java.lang.String NAMESPACES_SAXF
           
static java.lang.String SCHEMA_V_XERCESF
           
static java.lang.String VALIDATION_SAXF
           
 
Constructor Summary
XMLParserUtils()
           
 
Method Summary
static void addExternalSchemaURL(org.apache.xerces.parsers.DOMParser dp, java.lang.String namespace, java.lang.String u)
           Add a namespace/URL pair to the mapping between namespaces and the schemas used to validate elements in them.
static void addExternalSchemaURL(org.xml.sax.XMLReader xr, java.lang.String namespace, java.lang.String u)
           Add a namespace/URL pair to the mapping between namespaces and the schemas used to validate elements in them.
static javax.xml.parsers.DocumentBuilderFactory getDocumentBuilderFactory()
           Get the 'correct' implementation of a JAXP DocumentBuilderFactory; this is intended to ensure that local implementations (e.g., Crimson) don't sneak into the mix.
static org.apache.xerces.parsers.DOMParser getDOMParser()
           
static javax.xml.parsers.SAXParserFactory getSAXParserFactory()
           Get the 'correct' implementation of a JAXP SAXParserFactory; this is intended to ensure that local implementations (e.g., Crimson) don't sneak into the mix.
static org.xml.sax.ContentHandler getXercesSerializer(java.io.OutputStream os)
           
static org.xml.sax.XMLReader getXMLReader()
           
static void setExternalSchemaURL(org.apache.xerces.parsers.DOMParser dp, java.lang.String namespace, java.lang.String u)
           Specify an external schema location and turn on validation via setting features and properties.
static void setExternalSchemaURL(org.xml.sax.XMLReader xr, java.lang.String namespace, java.lang.String u)
           Specify an external schema location and turn on validation via setting features and properties.
static void setNamespaces(org.xml.sax.XMLReader xr)
          Set the namespaces SAX property on the supplied XMLReader.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAMESPACES_SAXF

public static final java.lang.String NAMESPACES_SAXF
See Also:
Constant Field Values

VALIDATION_SAXF

public static final java.lang.String VALIDATION_SAXF
See Also:
Constant Field Values

SCHEMA_V_XERCESF

public static final java.lang.String SCHEMA_V_XERCESF
See Also:
Constant Field Values
Constructor Detail

XMLParserUtils

public XMLParserUtils()
Method Detail

getSAXParserFactory

public static javax.xml.parsers.SAXParserFactory getSAXParserFactory()

Get the 'correct' implementation of a JAXP SAXParserFactory; this is intended to ensure that local implementations (e.g., Crimson) don't sneak into the mix.

Returns:
the Xerces-specific implementaiton

getDocumentBuilderFactory

public static javax.xml.parsers.DocumentBuilderFactory getDocumentBuilderFactory()

Get the 'correct' implementation of a JAXP DocumentBuilderFactory; this is intended to ensure that local implementations (e.g., Crimson) don't sneak into the mix.

Returns:
the Xerces-specific implementation

setNamespaces

public static void setNamespaces(org.xml.sax.XMLReader xr)
Set the namespaces SAX property on the supplied XMLReader.

Parameters:
xr - the XMLReader to apply the feature to.

getXMLReader

public static org.xml.sax.XMLReader getXMLReader()
Returns:
a Xerces-specific XMLReader instance.

getDOMParser

public static org.apache.xerces.parsers.DOMParser getDOMParser()
Returns:
a Xerces-specific DOM parser.

setExternalSchemaURL

public static void setExternalSchemaURL(org.xml.sax.XMLReader xr,
                                        java.lang.String namespace,
                                        java.lang.String u)
                                 throws org.xml.sax.SAXNotRecognizedException,
                                        org.xml.sax.SAXNotSupportedException

Specify an external schema location and turn on validation via setting features and properties.

Parameters:
xr - the XMLReader to apply the features and properties to.
namespace - the namespace URI of the schema to validate, with the empty string or null serving to represent the empty namespace.
u - the URL (or relative URL) that contains the schema.
Throws:
org.xml.sax.SAXNotSupportedException - if one of the underlying feature/property settings does.
org.xml.sax.SAXNotRecognizedException - if one of the underlying feature/property settings does.

setExternalSchemaURL

public static void setExternalSchemaURL(org.apache.xerces.parsers.DOMParser dp,
                                        java.lang.String namespace,
                                        java.lang.String u)
                                 throws org.xml.sax.SAXNotRecognizedException,
                                        org.xml.sax.SAXNotSupportedException

Specify an external schema location and turn on validation via setting features and properties.

Parameters:
dp - the DOMParser to apply the features and properties to.
namespace - the namespace URI of the schema to validate, with the empty string or null serving to represent the empty namespace.
u - the URL or relative URL that contains the schema.
Throws:
org.xml.sax.SAXNotSupportedException - if one of the underlying feature/property settings does.
org.xml.sax.SAXNotRecognizedException - if one of the underlying feature/property settings does.

addExternalSchemaURL

public static void addExternalSchemaURL(org.xml.sax.XMLReader xr,
                                        java.lang.String namespace,
                                        java.lang.String u)
                                 throws org.xml.sax.SAXNotRecognizedException,
                                        org.xml.sax.SAXNotSupportedException

Add a namespace/URL pair to the mapping between namespaces and the schemas used to validate elements in them. Adding a pair for a namespace that's already bound will result in overwriting the URL previously bound.

Parameters:
xr -
namespace -
u -
Throws:
org.xml.sax.SAXNotRecognizedException
org.xml.sax.SAXNotSupportedException

addExternalSchemaURL

public static void addExternalSchemaURL(org.apache.xerces.parsers.DOMParser dp,
                                        java.lang.String namespace,
                                        java.lang.String u)
                                 throws org.xml.sax.SAXNotRecognizedException,
                                        org.xml.sax.SAXNotSupportedException

Add a namespace/URL pair to the mapping between namespaces and the schemas used to validate elements in them. Adding a pair for a namespace that's already bound will result in overwriting the URL previously bound.

Parameters:
dp - the DOMParser to apply the features and properties to.
namespace - the namespace URI of the schema to validate, with the empty string or null serving to represent the empty namespace.
u - the URL or relative URL that contains the schema.
Throws:
org.xml.sax.SAXNotSupportedException - if one of the underlying feature/property settings does.
org.xml.sax.SAXNotRecognizedException - if one of the underlying feature/property settings does.

getXercesSerializer

public static org.xml.sax.ContentHandler getXercesSerializer(java.io.OutputStream os)