Class XmlUtils


  • public final class XmlUtils
    extends java.lang.Object
    Collection of XML related code.
    Version:
    $Id: $Id
    Author:
    Jeremy Long
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static javax.xml.parsers.DocumentBuilder buildSecureDocumentBuilder()
      Constructs a new document builder with security features enabled.
      static javax.xml.parsers.SAXParser buildSecureSaxParser()
      Constructs a secure SAX Parser.
      static javax.xml.parsers.SAXParser buildSecureSaxParser​(java.io.InputStream... schemaStream)
      Constructs a validating secure SAX Parser.
      static java.lang.String getPrettyParseExceptionInfo​(org.xml.sax.SAXParseException ex)
      Builds a prettier exception message.
      static boolean parseBoolean​(java.lang.String lexicalXSDBoolean)
      Converts an attribute value representing an xsd:boolean value to a boolean using the rules as stated in the XML specification.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • JAXP_SCHEMA_LANGUAGE

        public static final java.lang.String JAXP_SCHEMA_LANGUAGE
        JAXP Schema Language. Source: http://docs.oracle.com/javase/tutorial/jaxp/sax/validation.html
        See Also:
        Constant Field Values
      • W3C_XML_SCHEMA

        public static final java.lang.String W3C_XML_SCHEMA
        W3C XML Schema. Source: http://docs.oracle.com/javase/tutorial/jaxp/sax/validation.html
        See Also:
        Constant Field Values
      • JAXP_SCHEMA_SOURCE

        public static final java.lang.String JAXP_SCHEMA_SOURCE
        JAXP Schema Source. Source: http://docs.oracle.com/javase/tutorial/jaxp/sax/validation.html
        See Also:
        Constant Field Values
    • Method Detail

      • buildSecureSaxParser

        public static javax.xml.parsers.SAXParser buildSecureSaxParser​(java.io.InputStream... schemaStream)
                                                                throws javax.xml.parsers.ParserConfigurationException,
                                                                       org.xml.sax.SAXNotRecognizedException,
                                                                       org.xml.sax.SAXNotSupportedException,
                                                                       org.xml.sax.SAXException
        Constructs a validating secure SAX Parser.
        Parameters:
        schemaStream - One or more inputStreams with the schema(s) that the parser should be able to validate the XML against, one InputStream per schema
        Returns:
        a SAX Parser
        Throws:
        javax.xml.parsers.ParserConfigurationException - is thrown if there is a parser configuration exception
        org.xml.sax.SAXNotRecognizedException - thrown if there is an unrecognized feature
        org.xml.sax.SAXNotSupportedException - thrown if there is a non-supported feature
        org.xml.sax.SAXException - is thrown if there is a org.xml.sax.SAXException
      • parseBoolean

        public static boolean parseBoolean​(java.lang.String lexicalXSDBoolean)
        Converts an attribute value representing an xsd:boolean value to a boolean using the rules as stated in the XML specification.
        Parameters:
        lexicalXSDBoolean - The string-value of the boolean
        Returns:
        the boolean value represented by lexicalXSDBoolean
        Throws:
        java.lang.IllegalArgumentException - When lexicalXSDBoolean does fit the lexical space of the XSD boolean datatype
      • buildSecureSaxParser

        public static javax.xml.parsers.SAXParser buildSecureSaxParser()
                                                                throws javax.xml.parsers.ParserConfigurationException,
                                                                       org.xml.sax.SAXNotRecognizedException,
                                                                       org.xml.sax.SAXNotSupportedException,
                                                                       org.xml.sax.SAXException
        Constructs a secure SAX Parser.
        Returns:
        a SAX Parser
        Throws:
        javax.xml.parsers.ParserConfigurationException - thrown if there is a parser configuration exception
        org.xml.sax.SAXNotRecognizedException - thrown if there is an unrecognized feature
        org.xml.sax.SAXNotSupportedException - thrown if there is a non-supported feature
        org.xml.sax.SAXException - is thrown if there is a org.xml.sax.SAXException
      • buildSecureDocumentBuilder

        public static javax.xml.parsers.DocumentBuilder buildSecureDocumentBuilder()
                                                                            throws javax.xml.parsers.ParserConfigurationException
        Constructs a new document builder with security features enabled.
        Returns:
        a new document builder
        Throws:
        javax.xml.parsers.ParserConfigurationException - thrown if there is a parser configuration exception
      • getPrettyParseExceptionInfo

        public static java.lang.String getPrettyParseExceptionInfo​(org.xml.sax.SAXParseException ex)
        Builds a prettier exception message.
        Parameters:
        ex - the SAXParseException
        Returns:
        an easier to read exception message