public class XMLDocument
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String[] |
ENCODINGS |
static java.lang.String[] |
MAGICS |
Constructor and Description |
---|
XMLDocument(uk.ac.starlink.util.DataSource datsrc)
Constructs a new XMLDocument from a DataSource.
|
Modifier and Type | Method and Description |
---|---|
javax.xml.transform.dom.DOMSource |
constructDOM(boolean validate)
Convenience method to get a DOM from this document, which either
succeeds or throws a NoSuchDataException.
|
uk.ac.starlink.util.DataSource |
getDataSource() |
static java.lang.String |
getEncoding(byte[] magic)
Returns what appears to be the encoding of the XML stream which
starts with a given magic number.
|
java.util.List |
getMessages() |
java.lang.String |
getName() |
java.util.Collection |
getNamespaces() |
java.lang.String |
getPublicId() |
java.lang.String |
getSystemId() |
org.xml.sax.Attributes |
getTopAttributes() |
java.lang.String |
getTopLocalName() |
java.lang.String |
getTopNamespaceURI() |
static boolean |
isMagic(byte[] magic)
This tests for the likely start of an XML file.
|
javax.xml.transform.dom.DOMSource |
parseToDOM(boolean validate,
org.xml.sax.ErrorHandler ehandler)
Performs a parse on the data source represented by this object
and returns the resulting DOM.
|
public static final java.lang.String[] MAGICS
public static final java.lang.String[] ENCODINGS
public XMLDocument(uk.ac.starlink.util.DataSource datsrc) throws NoSuchDataException
datsrc
- data sourceNoSuchDataException
- if datsrc doesn't contain XMLpublic uk.ac.starlink.util.DataSource getDataSource()
public java.lang.String getTopLocalName()
public java.lang.String getTopNamespaceURI()
public org.xml.sax.Attributes getTopAttributes()
public java.util.Collection getNamespaces()
public java.util.List getMessages()
public java.lang.String getSystemId()
public java.lang.String getPublicId()
public java.lang.String getName()
public javax.xml.transform.dom.DOMSource parseToDOM(boolean validate, org.xml.sax.ErrorHandler ehandler) throws org.xml.sax.SAXException, java.io.IOException
validate
- whether the parse should be validatingehandler
- handler for parse errors (may be null)org.xml.sax.SAXException
java.io.IOException
public javax.xml.transform.dom.DOMSource constructDOM(boolean validate) throws NoSuchDataException
NoSuchDataException
public static boolean isMagic(byte[] magic)
magic
- buffer containing the first few bytes of the streampublic static java.lang.String getEncoding(byte[] magic)
MAGICS
). The result will be one of the
encoding names listed in ENCODINGS
, or null if
it doesn't look like the start of an XML stream in any of these
encodings.magic
- buffer containing the first few bytes of the streamCopyright © 2017 Central Laboratory of the Research Councils. All Rights Reserved.