public class XMLParser
extends org.xml.sax.helpers.DefaultHandler
Modifier and Type | Field and Description |
---|---|
protected int |
alignLevel
The level at which we found the Alignment tag.
|
protected URIAlignment |
alignment
the alignment that is parsed
We always create a URIAlignment (we could also use a BasicAlignment).
|
protected Cell |
cell
the relation content as text...
|
protected java.util.Set<java.lang.String> |
cellids
Stores encountered cell ids
|
protected java.lang.Object |
cl1
the first entity of a cell
|
protected java.lang.Object |
cl2
the second entity of a cell
|
protected java.lang.String |
content
the content found as text...
|
(package private) Ontology<java.lang.Object> |
curronto |
protected boolean |
embedded
Is the Alignment RDF for embedded in a larger XML structure to be parsed.
|
protected Extensions |
extensions
Cell extensions (default null)
|
protected java.lang.String |
id
the cell id as text...
|
(package private) static org.slf4j.Logger |
logger |
protected java.lang.String |
measure
the measure content as text...
|
(package private) Ontology<java.lang.Object> |
onto1
the first Ontology
|
(package private) Ontology<java.lang.Object> |
onto2
the second Ontology
|
protected int |
parseLevel
The parsing level, if equal to 3 we are in the Alignment
if equal to 5 we are in a cell
and can find metadata
|
protected javax.xml.parsers.SAXParser |
parser
XML Parser
|
protected java.lang.String |
relation
the relation content as text...
|
protected java.lang.String |
sem
the semantics of the cell (default first-order)...
|
protected java.lang.String |
uri
a URI to a process
|
Constructor and Description |
---|
XMLParser()
Creates an XML Parser.
|
XMLParser(boolean validate) |
XMLParser(int validate)
Creates an XML Parser.
|
Modifier and Type | Method and Description |
---|---|
void |
characters(char[] ch,
int start,
int length)
From a patch proposed by Sabine Massmann
Get around some nasty double parsing bug.
|
void |
endElement(java.lang.String namespaceURI,
java.lang.String pName,
java.lang.String qName)
Called by the XML parser at the end of an element.
|
private java.lang.Object |
getEntity(java.lang.Object ontology,
java.lang.String name) |
void |
initAlignment(URIAlignment al)
Allows to have the parser filling an existing alignment instead
of creating a new one
|
Alignment |
parse(java.io.InputStream s)
Parses a string instead of a URI
|
Alignment |
parse(java.io.Reader r)
Parses a reader, used for reading from a string
|
Alignment |
parse(java.lang.String uri)
Parses the document corresponding to the URI given in parameter
If the current process has links (import or include) to others documents then they are
parsed.
|
void |
setEmbedded(boolean b) |
void |
startElement(java.lang.String namespaceURI,
java.lang.String pName,
java.lang.String qname,
org.xml.sax.Attributes atts)
Called by the XML parser at the begining of an element.
|
static final org.slf4j.Logger logger
protected java.lang.String uri
Ontology<java.lang.Object> onto1
Ontology<java.lang.Object> curronto
Ontology<java.lang.Object> onto2
protected URIAlignment alignment
protected java.lang.String content
protected java.lang.Object cl1
protected java.lang.Object cl2
protected Cell cell
protected java.lang.String relation
protected java.lang.String id
protected java.util.Set<java.lang.String> cellids
protected java.lang.String sem
protected Extensions extensions
protected java.lang.String measure
protected javax.xml.parsers.SAXParser parser
protected int parseLevel
protected boolean embedded
protected int alignLevel
public XMLParser() throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException
org.xml.sax.SAXException
- when syntax errors are encounteredjavax.xml.parsers.ParserConfigurationException
- when the parser cannot be configuredpublic XMLParser(int validate) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException
validate:
- 0 if non validating, more otherwise
This should become a booleanorg.xml.sax.SAXException
- when syntax errors are encounteredjavax.xml.parsers.ParserConfigurationException
- when the parser cannot be configuredpublic XMLParser(boolean validate) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
public void setEmbedded(boolean b)
public Alignment parse(java.lang.String uri) throws AlignmentException
uri
- URI of the document to parse
Note: SAXParser has a parse( String uri ) method but it does not do content negotiation
Hence we have to reimplement it (2014)AlignmentException
- when something goes wrongpublic Alignment parse(java.io.Reader r) throws AlignmentException
r
- the reader from which to parseAlignmentException
- when something goes wrongpublic Alignment parse(java.io.InputStream s) throws AlignmentException
s
- String the string to parseAlignmentException
- when something goes wrongpublic void initAlignment(URIAlignment al)
al
- URIAlignment the alignment to be returned by the parser
Note that this function is also useful for reseting the parser
and using it once again by parser.initAlignment( null )
Otherwise, this may lead to errors.public void startElement(java.lang.String namespaceURI, java.lang.String pName, java.lang.String qname, org.xml.sax.Attributes atts) throws org.xml.sax.SAXException
startElement
in interface org.xml.sax.ContentHandler
startElement
in class org.xml.sax.helpers.DefaultHandler
namespaceURI:
- The namespace of the current elementpName:
- The local name of the current elementqname:
- The name of the current elementatts:
- The attributes name of the current elementorg.xml.sax.SAXException
- when something goes wrongprivate java.lang.Object getEntity(java.lang.Object ontology, java.lang.String name) throws org.xml.sax.SAXException
org.xml.sax.SAXException
public void characters(char[] ch, int start, int length)
characters
in interface org.xml.sax.ContentHandler
characters
in class org.xml.sax.helpers.DefaultHandler
ch:
- an array of chars from the string part of XMLstart:
- the beging of the string to extractlength:
- the length of the string to extractpublic void endElement(java.lang.String namespaceURI, java.lang.String pName, java.lang.String qName) throws org.xml.sax.SAXException
endElement
in interface org.xml.sax.ContentHandler
endElement
in class org.xml.sax.helpers.DefaultHandler
namespaceURI:
- The namespace of the current elementpName:
- The local name of the current elementqName:
- The name of the current elementorg.xml.sax.SAXException
- when something goes wrong(C) INRIA & friends, 2003-2020