org.coode.owlapi.owlxmlparser
Class OWLXMLParserHandler

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by org.coode.owlapi.owlxmlparser.OWLXMLParserHandler
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public class OWLXMLParserHandler
extends org.xml.sax.helpers.DefaultHandler

Author: Matthew Horridge
The University Of Manchester
Bio-Health Informatics Group
Date: 13-Dec-2006

A handler which knows about OWLXML


Constructor Summary
OWLXMLParserHandler(OWLOntologyManager owlOntologyManager, OWLOntology ontology)
          Creates an OWLXML handler.
OWLXMLParserHandler(OWLOntologyManager owlOntologyManager, OWLOntology ontology, OWLElementHandler topHandler)
          Creates an OWLXML handler with the specified top level handler.
 
Method Summary
 void characters(char[] ch, int start, int length)
           
 void endDocument()
           
 void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)
           
 IRI getAbbreviatedIRI(java.lang.String abbreviatedIRI)
           
 java.net.URI getBase()
          Return the base URI for resolution of relative URIs
 int getColumnNumber()
           
 OWLDataFactory getDataFactory()
           
 IRI getIRI(java.lang.String iriStr)
           
 int getLineNumber()
          Gets the line number that the parser is at.
 OWLOntology getOntology()
           
 OWLOntologyManager getOWLOntologyManager()
           
 java.util.Map<java.lang.String,java.lang.String> getPrefixName2PrefixMap()
           
protected  void processXMLBase(org.xml.sax.Attributes attributes)
           
 org.xml.sax.InputSource resolveEntity(java.lang.String publicId, java.lang.String systemId)
           
 void setDocumentLocator(org.xml.sax.Locator locator)
           
 void startDocument()
           
 void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes)
           
 void startPrefixMapping(java.lang.String prefix, java.lang.String uri)
           
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, skippedEntity, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OWLXMLParserHandler

public OWLXMLParserHandler(OWLOntologyManager owlOntologyManager,
                           OWLOntology ontology)
Creates an OWLXML handler.

Parameters:
owlOntologyManager - The manager that should be used to obtain a data factory, imported ontologies etc.
ontology - The ontology that the XML representation will be parsed into.

OWLXMLParserHandler

public OWLXMLParserHandler(OWLOntologyManager owlOntologyManager,
                           OWLOntology ontology,
                           OWLElementHandler topHandler)
Creates an OWLXML handler with the specified top level handler. This allows OWL/XML representations of axioms to be embedded in abitrary XML documents e.g. DIG 2.0 documents. (The default handler behaviour expects the top level element to be an Ontology element).

Parameters:
owlOntologyManager - The manager that should be used to obtain a data factory, imported ontologies etc.
ontology - The ontology object that the XML representation should be parsed into.
topHandler - The handler for top level elements - may be null, in which case the parser will expect an Ontology element to be the root element.
Method Detail

setDocumentLocator

public void setDocumentLocator(org.xml.sax.Locator locator)
Specified by:
setDocumentLocator in interface org.xml.sax.ContentHandler
Overrides:
setDocumentLocator in class org.xml.sax.helpers.DefaultHandler

getLineNumber

public int getLineNumber()
Gets the line number that the parser is at.

Returns:
A positive integer that represents the line number or -1 if the line number is not known.

getColumnNumber

public int getColumnNumber()

getIRI

public IRI getIRI(java.lang.String iriStr)
           throws OWLParserException
Throws:
OWLParserException

getAbbreviatedIRI

public IRI getAbbreviatedIRI(java.lang.String abbreviatedIRI)
                      throws OWLParserException
Throws:
OWLParserException

getPrefixName2PrefixMap

public java.util.Map<java.lang.String,java.lang.String> getPrefixName2PrefixMap()

getOntology

public OWLOntology getOntology()

getDataFactory

public OWLDataFactory getDataFactory()

startDocument

public void startDocument()
                   throws org.xml.sax.SAXException
Specified by:
startDocument in interface org.xml.sax.ContentHandler
Overrides:
startDocument in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException

endDocument

public void endDocument()
                 throws org.xml.sax.SAXException
Specified by:
endDocument in interface org.xml.sax.ContentHandler
Overrides:
endDocument in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws org.xml.sax.SAXException
Specified by:
characters in interface org.xml.sax.ContentHandler
Overrides:
characters in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException

startElement

public void startElement(java.lang.String uri,
                         java.lang.String localName,
                         java.lang.String qName,
                         org.xml.sax.Attributes attributes)
                  throws org.xml.sax.SAXException
Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException

processXMLBase

protected void processXMLBase(org.xml.sax.Attributes attributes)

getBase

public java.net.URI getBase()
Return the base URI for resolution of relative URIs

Returns:
base URI or null if unavailable (xml:base not present and the document locator does not provide a URI)

endElement

public void endElement(java.lang.String uri,
                       java.lang.String localName,
                       java.lang.String qName)
                throws org.xml.sax.SAXException
Specified by:
endElement in interface org.xml.sax.ContentHandler
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException

startPrefixMapping

public void startPrefixMapping(java.lang.String prefix,
                               java.lang.String uri)
                        throws org.xml.sax.SAXException
Specified by:
startPrefixMapping in interface org.xml.sax.ContentHandler
Overrides:
startPrefixMapping in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException

resolveEntity

public org.xml.sax.InputSource resolveEntity(java.lang.String publicId,
                                             java.lang.String systemId)
                                      throws java.io.IOException,
                                             org.xml.sax.SAXException
Specified by:
resolveEntity in interface org.xml.sax.EntityResolver
Overrides:
resolveEntity in class org.xml.sax.helpers.DefaultHandler
Throws:
java.io.IOException
org.xml.sax.SAXException

getOWLOntologyManager

public OWLOntologyManager getOWLOntologyManager()