public class XMLDocument extends Object
getChildren
or
maybe configureDetail
have been called. DataNode constructors
which do operate on an XMLDocument should not construct and cache
a DOM themselves, though other DataNode methods may do so.Modifier and Type | Field and Description |
---|---|
static String[] |
ENCODINGS |
static String[] |
MAGICS |
Constructor and Description |
---|
XMLDocument(DataSource datsrc)
Constructs a new XMLDocument from a DataSource.
|
Modifier and Type | Method and Description |
---|---|
DOMSource |
constructDOM(boolean validate)
Convenience method to get a DOM from this document, which either
succeeds or throws a NoSuchDataException.
|
DataSource |
getDataSource() |
static String |
getEncoding(byte[] magic)
Returns what appears to be the encoding of the XML stream which
starts with a given magic number.
|
List |
getMessages() |
String |
getName() |
Collection |
getNamespaces() |
String |
getPublicId() |
String |
getSystemId() |
Attributes |
getTopAttributes() |
String |
getTopLocalName() |
String |
getTopNamespaceURI() |
static boolean |
isMagic(byte[] magic)
This tests for the likely start of an XML file.
|
DOMSource |
parseToDOM(boolean validate,
ErrorHandler ehandler)
Performs a parse on the data source represented by this object
and returns the resulting DOM.
|
public static final String[] MAGICS
public static final String[] ENCODINGS
public XMLDocument(DataSource datsrc) throws NoSuchDataException
datsrc
- data sourceNoSuchDataException
- if datsrc
doesn't contain XMLpublic DataSource getDataSource()
public String getTopLocalName()
public String getTopNamespaceURI()
public Attributes getTopAttributes()
public Collection getNamespaces()
public List getMessages()
public String getSystemId()
public String getPublicId()
public String getName()
public DOMSource parseToDOM(boolean validate, ErrorHandler ehandler) throws SAXException, IOException
validate
- whether the parse should be validatingehandler
- handler for parse errors (may be null)SAXException
IOException
public DOMSource constructDOM(boolean validate) throws NoSuchDataException
NoSuchDataException
public static boolean isMagic(byte[] magic)
magic
- buffer containing the first few bytes of the streamtrue
iff this looks like an XML filepublic static 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 © 2024 Central Laboratory of the Research Councils. All Rights Reserved.