Package com.jcabi.xml

Class XSDDocument

  • All Implemented Interfaces:
    XSD

    public final class XSDDocument
    extends Object
    implements XSD
    Implementation of XSD.

    Objects of this class are immutable and thread-safe.

    Since:
    0.5
    Suppressed Checkstyle violations:
    AbbreviationAsWordInNameCheck (5 lines)
    • Constructor Detail

      • XSDDocument

        public XSDDocument​(XML src)
        Public ctor, from XSD as a source.
        Parameters:
        src - XSD document body
      • XSDDocument

        public XSDDocument​(String src)
        Public ctor, from XSD as a string.
        Parameters:
        src - XSD document body
      • XSDDocument

        public XSDDocument​(URL url)
                    throws IOException
        Public ctor, from URL.
        Parameters:
        url - Location of document
        Throws:
        IOException - If fails to read
        Since:
        0.7.4
      • XSDDocument

        public XSDDocument​(URI uri)
                    throws IOException
        Public ctor, from URI.
        Parameters:
        uri - Location of document
        Throws:
        IOException - If fails to read
        Since:
        0.15
      • XSDDocument

        public XSDDocument​(InputStream stream)
        Public ctor, from XSD as an input stream.
        Parameters:
        stream - XSD input stream
    • Method Detail

      • make

        public static XSD make​(InputStream stream)
        Make an instance of XSD schema without I/O exceptions.

        This factory method is useful when you need to create an instance of XSD schema as a static final variable. In this case you can't catch an exception but this method can help, for example:

         class Foo {
           private static final XSD SCHEMA = XSDDocument.make(
             Foo.class.getResourceAsStream("my-schema.xsd")
           );
         }
        Parameters:
        stream - Input stream
        Returns:
        XSD schema
      • make

        public static XSD make​(URL url)
        Make an instance of XSD schema without I/O exceptions.
        Parameters:
        url - URL with content
        Returns:
        XSD schema
        Since:
        0.7.4
        See Also:
        make(InputStream)
      • validate

        public Collection<SAXParseException> validate​(Source xml)
        Description copied from interface: XSD
        Validate XML.
        Specified by:
        validate in interface XSD
        Parameters:
        xml - Source XML document
        Returns:
        Collection of problems found (empty if no problems)