org.topbraid.rdfa.parser
Class RDFaParser

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by org.topbraid.rdfa.parser.RDFaParser
All Implemented Interfaces:
RDFaConstants, ContentHandler, DTDHandler, EntityResolver, ErrorHandler

public class RDFaParser
extends org.xml.sax.helpers.DefaultHandler
implements RDFaConstants

A class that creates a Graph from an RDFa source stream.

Author:
Holger Knublauch

Field Summary
 
Fields inherited from interface org.topbraid.rdfa.parser.RDFaConstants
ABOUT, BASE, CONTENT, DATATYPE, HEAD, HREF, ID, LANG, LINK, META, PROPERTY, REL, REV, ROLE, XML_BASE, XML_DATATYPE, XML_LANG, XMLNS
 
Constructor Summary
RDFaParser(java.io.InputStream is, java.lang.String baseURI)
           
 
Method Summary
 void characters(char[] ch, int start, int length)
          Receive notification of character data.
 void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)
          Receive notification of the end of an element.
 com.hp.hpl.jena.graph.Graph parse()
           
 void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, Attributes attributes)
          Receive notification of the beginning of an element.
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RDFaParser

public RDFaParser(java.io.InputStream is,
                  java.lang.String baseURI)
Method Detail

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws SAXException
Description copied from interface: ContentHandler
Receive notification of character data.

The Parser will call this method to report each chunk of character data. SAX parsers may return all contiguous character data in a single chunk, or they may split it into several chunks; however, all of the characters in any single event must come from the same external entity so that the Locator provides useful information.

The application must not attempt to read from the array outside of the specified range.

Note that some parsers will report whitespace in element content using the ignorableWhitespace method rather than this one (validating parsers must do so).

Specified by:
characters in interface ContentHandler
Overrides:
characters in class org.xml.sax.helpers.DefaultHandler
Parameters:
ch - The characters from the XML document.
start - The start position in the array.
length - The number of characters to read from the array.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
ContentHandler.ignorableWhitespace(char[], int, int), Locator

endElement

public void endElement(java.lang.String uri,
                       java.lang.String localName,
                       java.lang.String qName)
                throws SAXException
Description copied from interface: ContentHandler
Receive notification of the end of an element.

The SAX parser will invoke this method at the end of every element in the XML document; there will be a corresponding startElement event for every endElement event (even when the element is empty).

For information on the names, see startElement.

Specified by:
endElement in interface ContentHandler
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler
localName - The local name (without prefix), or the empty string if Namespace processing is not being performed.
qName - The qualified XML 1.0 name (with prefix), or the empty string if qualified names are not available.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.

parse

public com.hp.hpl.jena.graph.Graph parse()
                                  throws java.lang.Exception
Throws:
java.lang.Exception

startElement

public void startElement(java.lang.String uri,
                         java.lang.String localName,
                         java.lang.String qName,
                         Attributes attributes)
                  throws SAXException
Description copied from interface: ContentHandler
Receive notification of the beginning of an element.

The Parser will invoke this method at the beginning of every element in the XML document; there will be a corresponding endElement event for every startElement event (even when the element is empty). All of the element's content will be reported, in order, before the corresponding endElement event.

This event allows up to three name components for each element:

  1. the Namespace URI;
  2. the local name; and
  3. the qualified (prefixed) name.

Any or all of these may be provided, depending on the values of the http://xml.org/sax/features/namespaces and the http://xml.org/sax/features/namespace-prefixes properties:

Note that the attribute list provided will contain only attributes with explicit values (specified or defaulted): #IMPLIED attributes will be omitted. The attribute list will contain attributes used for Namespace declarations (xmlns* attributes) only if the http://xml.org/sax/features/namespace-prefixes property is true (it is false by default, and support for a true value is optional).

Specified by:
startElement in interface ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler
localName - The local name (without prefix), or the empty string if Namespace processing is not being performed.
qName - The qualified name (with prefix), or the empty string if qualified names are not available.
attributes - The attributes attached to the element. If there are no attributes, it shall be an empty Attributes object.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
ContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String), Attributes