com.mkdoc.sax
Class LinkTripleWriter

java.lang.Object
  |
  +--com.mkdoc.sax.AbstractContentHandler
        |
        +--com.mkdoc.sax.AbstractRdfContentHandler
              |
              +--com.mkdoc.sax.AbstractTripleWriter
                    |
                    +--com.mkdoc.sax.LinkTripleWriter
All Implemented Interfaces:
org.xml.sax.ContentHandler, ElementHandler, ElementTripleWriter, RdfContentHandler

public class LinkTripleWriter
extends AbstractTripleWriter
implements org.xml.sax.ContentHandler, ElementTripleWriter

Triple writer for XHTML link content.

Generates N-Triple style output without escaping for non-ASCII characters, see N-Triples. If used for file output, should have a .nt extension. If used for HTTP output, should declare content type text/plain.

Version:
0.6 2005-09-09
Author:
Philip Shaw
To do:
Reduce complexity of the printTriples method.

Field Summary
static java.lang.String LINK
          The local name of the link element.
 
Fields inherited from class com.mkdoc.sax.AbstractTripleWriter
manager, out
 
Fields inherited from class com.mkdoc.sax.AbstractRdfContentHandler
DC_PREFIX, DCTERMS_URI, NODE_PREFIX, NODE_SUFFIX, NS_XHTML1, profile, RDF_TYPE, RDF_VALUE, subject, URI_SCHEMES
 
Fields inherited from class com.mkdoc.sax.AbstractContentHandler
locator
 
Constructor Summary
LinkTripleWriter(FileStoreManager manager, java.net.URL url)
          Construct with an implicit output stream and initial URI.
 
Method Summary
 boolean acceptElement(java.lang.String uri, java.lang.String localName)
          Report whether an instance accepts named element types.
 void printTriples(java.lang.String sourceUri, org.xml.sax.Attributes attributes, java.io.PrintWriter printWriter)
          Make a set of subject, predicate, object triple statements.
 void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes)
          Extract link element content.
 
Methods inherited from class com.mkdoc.sax.AbstractTripleWriter
endDocument, startDocument
 
Methods inherited from class com.mkdoc.sax.AbstractRdfContentHandler
escape, expandPredicate, expandPredicates, expandScheme, getBNode, getBNodeId, getSubject, isUri, setApplicationProfile, setSubject
 
Methods inherited from class com.mkdoc.sax.AbstractContentHandler
characters, endElement, endPrefixMapping, getAttributeValue, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startPrefixMapping
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.xml.sax.ContentHandler
characters, endDocument, endElement, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping
 

Field Detail

LINK

public static final java.lang.String LINK
The local name of the link element.

Since:
Version 0.2 2005-02-15
See Also:
Constant Field Values
Constructor Detail

LinkTripleWriter

public LinkTripleWriter(FileStoreManager manager,
                        java.net.URL url)
Construct with an implicit output stream and initial URI.

For use as a stand-alone ContentHandler with its own output.

Parameters:
manager - A file store manager interface to write the triples to.
url - An initial URI subject.
Since:
Version 0.1 2005-02-14
Method Detail

acceptElement

public final boolean acceptElement(java.lang.String uri,
                                   java.lang.String localName)
Report whether an instance accepts named element types.

Specified by:
acceptElement in interface ElementHandler
Parameters:
uri - The namespace URI for the document type.
localName - The local name of the element to check.
Returns:
true if this type is capable of handling the specified element.
Since:
Version 0.2 2005-02-15

startElement

public final void startElement(java.lang.String uri,
                               java.lang.String localName,
                               java.lang.String qName,
                               org.xml.sax.Attributes attributes)
                        throws org.xml.sax.SAXException
Extract link element content.

Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class AbstractContentHandler
Parameters:
uri - The namespace URI for the element.
localName - The local element name.
qName - The qualified element name.
attributes - A set of attributes.
Throws:
org.xml.sax.SAXException - If the element is not a meta element.
Since:
Version 0.1 2005-02-14

printTriples

public final void printTriples(java.lang.String sourceUri,
                               org.xml.sax.Attributes attributes,
                               java.io.PrintWriter printWriter)
Make a set of subject, predicate, object triple statements.

Processes rel and rev links inversely; reverse relations give a reversal of the subject, predicate, object where the current document becomes the object of the statement.

Specified by:
printTriples in interface ElementTripleWriter
Parameters:
sourceUri - The URI of the source document of the metadata.
attributes - The link element attributes.
printWriter - The output stream for the triples.
Since:
Version 0.1 2005-02-14