edu.stanford.db.rdf.syntax.strawman
Class StrawmanParser

java.lang.Object
  |
  +--org.xml.sax.helpers.DefaultHandler
        |
        +--edu.stanford.db.xml.util.GenericParser
              |
              +--edu.stanford.db.rdf.syntax.generic.GenericXML2RDF
                    |
                    +--edu.stanford.db.rdf.syntax.strawman.StrawmanParser
All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler, RDFParser

public class StrawmanParser
extends GenericXML2RDF

A parser for a simplified syntax for RDF. Supports arbitrary XML files. Uses three control attributes:

  1. rdf:instance: specifes that a tag denotes an instance of a class
  2. rdf:for: specifes the subject URI of the property
  3. rdf:resource: specifes the object URI of the property


Field Summary
static java.lang.String _Namespace
           
static QName RDF_FOR
           
static QName RDF_INSTANCE
           
static QName RDF_RESOURCE
           
static java.lang.String REVISION
           
 
Fields inherited from class edu.stanford.db.rdf.syntax.generic.GenericXML2RDF
consumer, nodeFactory
 
Fields inherited from class edu.stanford.db.xml.util.GenericParser
atoms, current, errorHandler, locator, namespaces, numInParent, parserClass, source
 
Constructor Summary
StrawmanParser()
           
StrawmanParser(boolean useDigests, boolean warn)
           
 
Method Summary
protected  Element createElement()
           
protected  Statement createStatement(Resource subject, Resource predicate, RDFNode object)
           
 void endElement(java.lang.String uri, java.lang.String name, java.lang.String qName)
          Receive notification of the end of an element.
static void main(java.lang.String[] args)
           
 void startElement(java.lang.String uri, java.lang.String name, java.lang.String qname, Attributes al)
          Receive notification of the beginning of an element.
protected  void updateDigest(StrawElement current, StrawArc arc)
           
 
Methods inherited from class edu.stanford.db.rdf.syntax.generic.GenericXML2RDF
_main, createLiteral, createLiteral, createResource, createResource, createResource, parse
 
Methods inherited from class edu.stanford.db.xml.util.GenericParser
_endElement, _startElement, addError, addNamespace, addWarning, characters, create, createQName, createXMLReader, createXMLReader, getDefaultParserClass, getInputSource, getNamespaces, getParserClass, getSourceURI, initXMLParser, preserveWhiteSpace, resolveEntity, setErrorHandler
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.w3c.rdf.syntax.RDFParser
setErrorHandler
 

Field Detail

REVISION

public static final java.lang.String REVISION

_Namespace

public static final java.lang.String _Namespace

RDF_INSTANCE

public static final QName RDF_INSTANCE

RDF_RESOURCE

public static final QName RDF_RESOURCE

RDF_FOR

public static final QName RDF_FOR
Constructor Detail

StrawmanParser

public StrawmanParser()

StrawmanParser

public StrawmanParser(boolean useDigests,
                      boolean warn)
Method Detail

startElement

public void startElement(java.lang.String uri,
                         java.lang.String name,
                         java.lang.String qname,
                         Attributes al)
                  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).

Overrides:
startElement in class GenericParser
Following copied from interface: org.xml.sax.ContentHandler
Parameters:
uri - The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.
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.
atts - 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

endElement

public void endElement(java.lang.String uri,
                       java.lang.String name,
                       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.

Overrides:
endElement in class GenericParser
Following copied from interface: org.xml.sax.ContentHandler
Parameters:
uri - The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.
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.

updateDigest

protected void updateDigest(StrawElement current,
                            StrawArc arc)
                     throws DigestException

createStatement

protected Statement createStatement(Resource subject,
                                    Resource predicate,
                                    RDFNode object)
                             throws ModelException
Overrides:
createStatement in class GenericXML2RDF

createElement

protected Element createElement()
Overrides:
createElement in class GenericParser

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception