public abstract class SaxXmlHandler extends org.xml.sax.helpers.DefaultHandler implements LexicalHandler, ContentHandler
Map
-based representations of EA* files.
Makes use of properties file with format:
path/within/xml/=node/property
if no <node> is given, it is the default logical-unit or unit-description of this property file. with eac.properties this would be an HistoricalAgent with an HistoricalAgentDescription if there is a <node> given, it will translate to another graph node, like Address.
lines starting with '@' give the attributes:
@attribute=tmpname
path/within/xml/@tmpname=node/property
all tags not included in the properties file that have a nodevalue will be put in a unknownproperties node, with an edge to the unit-description.
Modifier and Type | Field and Description |
---|---|
protected String |
currentEntity |
protected Stack<Map<String,Object>> |
currentGraphPath
Key in the node that denotes the object's identifier.
|
protected Stack<String> |
currentPath |
protected Stack<StringBuilder> |
currentText |
protected int |
depth |
protected ItemImporter<Map<String,Object>,?> |
importer |
protected Map<String,Map<String,Object>> |
languageMap |
protected Locator |
locator |
protected XmlImportProperties |
properties |
Constructor and Description |
---|
SaxXmlHandler(ItemImporter<Map<String,Object>,?> importer) |
SaxXmlHandler(ItemImporter<Map<String,Object>,?> importer,
XmlImportProperties properties) |
Modifier and Type | Method and Description |
---|---|
void |
characters(char[] ch,
int start,
int length)
Receives character data in SAX events, converts multiple space to a single space
and puts the characters in the current node, unless the input contains only
whitespace.
|
void |
comment(char[] ch,
int start,
int end) |
void |
endCDATA() |
void |
endDTD() |
void |
endElement(String uri,
String localName,
String qName)
Receive an end element.
|
void |
endEntity(String name) |
protected String |
getMappedProperty(Stack<String> path)
Get the property name corresponding to the given path from the .properties file.
|
protected abstract boolean |
needToCreateSubNode(String qName)
Determines whether a new node that is a 'child' of the current node (i.e.
|
protected void |
overwritePropertyInCurrentGraph(String property,
String value)
Overwrite a value in the current graph.
|
protected void |
printGraph()
Print a text representation of the graph on `System.out`.
|
protected void |
putPropertyInCurrentGraph(String property,
String value)
Stores this property value pair in the current DocumentNode.
|
protected void |
putSubGraphInCurrentGraph(String key,
Map<String,Object> subgraph)
Insert a graph representation in the current graph (the one on top of
the currentGraphPath stack) as a list item at the given key.
|
void |
setDocumentLocator(Locator locator) |
void |
startCDATA() |
void |
startDTD(String name,
String publicId,
String systemId) |
void |
startElement(String uri,
String localName,
String qName,
Attributes attributes)
Receive an opening tag.
|
void |
startEntity(String name) |
endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
endDocument, endPrefixMapping, ignorableWhitespace, processingInstruction, skippedEntity, startDocument, startPrefixMapping
protected Locator locator
protected final Stack<Map<String,Object>> currentGraphPath
protected final Stack<StringBuilder> currentText
protected String currentEntity
protected final ItemImporter<Map<String,Object>,?> importer
protected final XmlImportProperties properties
protected int depth
public SaxXmlHandler(ItemImporter<Map<String,Object>,?> importer)
public SaxXmlHandler(ItemImporter<Map<String,Object>,?> importer, XmlImportProperties properties)
protected abstract boolean needToCreateSubNode(String qName)
qName
- the QNamepublic void startEntity(String name)
startEntity
in interface LexicalHandler
public void endEntity(String name)
endEntity
in interface LexicalHandler
public void startDTD(String name, String publicId, String systemId)
startDTD
in interface LexicalHandler
public void setDocumentLocator(Locator locator)
setDocumentLocator
in interface ContentHandler
setDocumentLocator
in class org.xml.sax.helpers.DefaultHandler
public void endDTD()
endDTD
in interface LexicalHandler
public void comment(char[] ch, int start, int end)
comment
in interface LexicalHandler
public void startCDATA()
startCDATA
in interface LexicalHandler
public void endCDATA()
endCDATA
in interface LexicalHandler
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException
startElement
in interface ContentHandler
startElement
in class org.xml.sax.helpers.DefaultHandler
SAXException
public void endElement(String uri, String localName, String qName) throws SAXException
endElement
in interface ContentHandler
endElement
in class org.xml.sax.helpers.DefaultHandler
SAXException
protected void putSubGraphInCurrentGraph(String key, Map<String,Object> subgraph)
key
- name of the edge to connect the sub-graph to the current graphsubgraph
- Map graph representation to insert into the current graphpublic void characters(char[] ch, int start, int length) throws SAXException
characters
in interface ContentHandler
characters
in class org.xml.sax.helpers.DefaultHandler
SAXException
protected void putPropertyInCurrentGraph(String property, String value)
property
- the property namevalue
- the property valueprotected void overwritePropertyInCurrentGraph(String property, String value)
property
- name of the property to overwritevalue
- new value for the property.protected String getMappedProperty(Stack<String> path)
path
- the stacked element names forming a path from the root to the current elementif this path has no corresponding value in the properties file, it will return the entire path name, with _ replacing the /
protected void printGraph()
Copyright © 2018 The European Holocaust Research Infrastructure (EHRI). All rights reserved.