public class XMLDocument extends Object
TODO XMLDocument type description
Modifier and Type | Field and Description |
---|---|
protected Document |
domDocument
w3c.Document object
|
protected static DOMImplementation |
domImpl |
protected Map<String,Element> |
identifiers
map linking each (local) ID (String) to an Element (w3c.Element)
|
protected Map<String,String> |
nsPrefixToUri
map linking NS Prefix (String) to a NS URI (String)
|
protected Map<String,String> |
nsUriToPrefix
map linking NS URI (String) to a NS prefix (String)
|
protected URI |
uri
document URI
|
Constructor and Description |
---|
XMLDocument() |
XMLDocument(Document doc) |
XMLDocument(InputStream inputStream,
boolean validate) |
XMLDocument(InputStream inputStream,
boolean validate,
Map<String,String> schemaLocations) |
XMLDocument(org.vast.xml.QName qname) |
Modifier and Type | Method and Description |
---|---|
void |
addId(String id,
Element elt)
Adds a pair identifier/node in the list
|
void |
addNS(String prefix,
String uri)
Adds mapping from uri to prefix and prefix to uri
for further lookups
|
Document |
getDocument()
Get the dom document object
|
Element |
getDocumentElement()
Get this dom document root element
|
Element |
getElementByID(String id)
Retrieve a node from the unique ID
|
String |
getNSPrefix(String nsUri)
Retrieve a namespace prefix for this document
|
Map<String,String> |
getNSTable()
Retrieves the namespace table
|
String |
getNSUri(String nsPrefix)
Retrieves the namespace uri matching the given prefix
|
URI |
getUri() |
protected Document |
parseDOM_JAXP(InputStream inputStream,
boolean validate,
Map<String,String> schemaLocations) |
protected Document |
parseDOM_LS(InputStream inputStream,
boolean validate,
Map<String,String> schemaLocations) |
protected Document |
parseDOM(InputStream inputStream,
boolean validate,
Map<String,String> schemaLocations)
Parse DOM from given input stream
|
void |
readIdentifiers(Element elt,
boolean recursive)
This function looks and stores all identifiers attributes found in the document
This adds every id it founds to the corresponding hashtable in the given XMLDocument This is called recursively for each child node |
void |
readNamespaces(Element elt,
boolean recursive)
Reads all the namespace prefix:domain pairs and store them in the hashtable of the XMLDocument
|
void |
serialize(Node node,
OutputStream out,
boolean pretty)
Helper method to serialize this DOM to a stream
|
protected void |
serializeDOM_JAXP(Element elt,
OutputStream out,
boolean pretty) |
protected void |
serializeDOM_LS(Element elt,
OutputStream out,
boolean pretty) |
void |
setUri(URI uri) |
protected static DOMImplementation domImpl
protected URI uri
protected Document domDocument
protected Map<String,Element> identifiers
protected Map<String,String> nsUriToPrefix
public XMLDocument()
public XMLDocument(org.vast.xml.QName qname)
public XMLDocument(Document doc)
public XMLDocument(InputStream inputStream, boolean validate) throws DOMHelperException
DOMHelperException
public XMLDocument(InputStream inputStream, boolean validate, Map<String,String> schemaLocations) throws DOMHelperException
DOMHelperException
public void addId(String id, Element elt)
id
- XML Identifierelt
- XML Nodepublic void addNS(String prefix, String uri)
prefix
- uri
- public Element getElementByID(String id) throws DOMHelperException
id
- Node identifierDOMHelperException
- if no node with the given ID belongs to the documentpublic String getNSPrefix(String nsUri)
nsUri
- namespace domain uripublic String getNSUri(String nsPrefix)
nsPrefix
- namespace prefix stringpublic Map<String,String> getNSTable()
public Document getDocument()
public Element getDocumentElement()
public URI getUri()
public void setUri(URI uri)
uri
- The uri to set as base uri for this document.protected Document parseDOM(InputStream inputStream, boolean validate, Map<String,String> schemaLocations) throws DOMHelperException
inputSource
- Stream containing XML file we want to parsevalidation
- boolean if true force the validation process with the schemaDOMHelperException
- if a problem occur during parsingprotected Document parseDOM_LS(InputStream inputStream, boolean validate, Map<String,String> schemaLocations) throws Exception
Exception
protected Document parseDOM_JAXP(InputStream inputStream, boolean validate, Map<String,String> schemaLocations) throws Exception
Exception
public void serialize(Node node, OutputStream out, boolean pretty) throws IOException
node
- out
- pretty
- set to true to indent outputIOException
protected void serializeDOM_LS(Element elt, OutputStream out, boolean pretty) throws Exception
Exception
protected void serializeDOM_JAXP(Element elt, OutputStream out, boolean pretty) throws Exception
Exception
public void readIdentifiers(Element elt, boolean recursive)
elt
- the DOM element where to start the searchrecursive
- if true, all children elements are also processed recursivelypublic void readNamespaces(Element elt, boolean recursive)
elt
- the DOM element where to start the searchrecursive
- if true, all children elements are also processed recursivelyCopyright © 2016 Sensia Software LLC. All rights reserved.