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:
rdf:instance
: specifes that a tag denotes an instance of a class
rdf:for
: specifes the subject URI of the property
rdf:resource
: specifes the object URI of the property
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 |
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
StrawmanParser
public StrawmanParser()
StrawmanParser
public StrawmanParser(boolean useDigests,
boolean warn)
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:
- the Namespace URI;
- the local name; and
- 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:
- the Namespace URI and local name are required when
the namespaces property is true (the default), and are
optional when the namespaces property is false (if one is
specified, both must be);
- the qualified name is required when the namespace-prefixes property
is true, and is optional when the namespace-prefixes property
is false (the default).
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