Difference between revisions of "Metadata API"

From Apache OpenOffice Wiki
Jump to: navigation, search
(Description)
(update with latest draft)
Line 36: Line 36:
  
 
the RDF model part:
 
the RDF model part:
- XRDFRepository
+
- XRepository
 
   a set of named RDF graphs
 
   a set of named RDF graphs
 
   basically, this is where the metadata lives
 
   basically, this is where the metadata lives
  
- XRDFNamedGraph
+
- XNamedGraph
 
   a single named graph
 
   a single named graph
 
   this likely would be implemented as just a shim with the graph name and
 
   this likely would be implemented as just a shim with the graph name and
 
   pointer to the repository
 
   pointer to the repository
  
- XRDFNode, XRDFResource, XRDFBlankNode, XRDFURI, XRDFLiteral
+
- XNode, XResource, XBlankNode, XURI, XLiteral
 
   RDF node types
 
   RDF node types
 
   these would ideally be value types, but we do need subtype polymorphism...
 
   these would ideally be value types, but we do need subtype polymorphism...
  
- XRDFStatement
+
- XStatement
 
   RDF triple: subject, predicate, object
 
   RDF triple: subject, predicate, object
  
  
 
the document integration part:
 
the document integration part:
- XRDFRepositorySupplier
+
- XRepositorySupplier
   implemented at the document to supply the (per-document) XRDFRepository
+
   implemented at the document to supply the (per-document) XRepository
  
 
- XManifestAccess
 
- XManifestAccess
Line 72: Line 72:
  
  
module com {  module sun {  module star {  module util /*FIXME: or lang or something*/ {
+
module com {  module sun {  module star {  module beans {
  
 
//=============================================================================
 
//=============================================================================
Line 97: Line 97:
 
}; }; }; };
 
}; }; }; };
  
//FIXME: where to put this module? here? below css.document? below css.xml?
 
 
module com {  module sun {  module star {  module rdf {
 
module com {  module sun {  module star {  module rdf {
  
Line 104: Line 103:
  
 
//FIXME paint a picture
 
//FIXME paint a picture
     XRDFNode
+
     XNode
 
     |
 
     |
     |---XRDFLiteral
+
     |---XLiteral
 
     |
 
     |
     XRDFResource
+
     XResource
 
     |
 
     |
     |---XRDFBlankNode
+
     |---XBlankNode
 
     |
 
     |
     XRDFURI
+
     XURI
  
 
     @since OOo 3.0
 
     @since OOo 3.0
  
     @see XRDFRepository
+
     @see XRepository
 
  */
 
  */
interface XRDFNode
+
interface XNode
 
{
 
{
 
     [readonly, attribute] string StringValue;
 
     [readonly, attribute] string StringValue;
Line 132: Line 131:
 
     @since OOo 3.0
 
     @since OOo 3.0
  
     @see XRDFRepository
+
     @see XRepository
 
  */
 
  */
interface XRDFResource : XRDFNode
+
interface XResource : XNode
 
{
 
{
 
};
 
};
Line 148: Line 147:
 
     @since OOo 3.0
 
     @since OOo 3.0
  
     @see XRDFRepository
+
     @see XRepository
 
  */
 
  */
interface XRDFBlankNode : XRDFResource
+
interface XBlankNode : XResource
 
{
 
{
 
};
 
};
Line 165: Line 164:
 
     @since OOo 3.0
 
     @since OOo 3.0
  
     @see XRDFRepository
+
     @see XRepository
 
  */
 
  */
interface XRDFURI : XRDFResource
+
interface XURI : XResource
 
{
 
{
 
     [readonly, attribute] string LocalName;
 
     [readonly, attribute] string LocalName;
Line 178: Line 177:
 
     @since OOo 3.0
 
     @since OOo 3.0
  
     @see XRDFRepository
+
     @see XRepository
 
  */
 
  */
interface XRDFLiteral : XRDFNode
+
interface XLiteral : XNode
 
{
 
{
 +
    [readonly, attribute] string Value;
 
     [readonly, attribute] string Language;
 
     [readonly, attribute] string Language;
     [readonly, attribute] string Datatype;
+
     [readonly, attribute] XURI  Datatype;
 
     //FIXME: TODO: have not looked at handling all kinds of types, maybe just have an any attr here...
 
     //FIXME: TODO: have not looked at handling all kinds of types, maybe just have an any attr here...
 
};
 
};
  
//FIXME: do we need a factory for Nodes?
+
//=============================================================================
/* or instead, use new style services:*/
+
/** represents a blank node that may occur in a RDF graph.
  
service RDFBlankNode : XRDFBlankNode
+
    @since OOo 3.0
 +
 
 +
    @see XRepository
 +
*/
 +
service BlankNode : XBlankNode
 
{
 
{
// FIXME: hmmm, does it make sense to allow creating arbitrary blank nodes?
+
    //-------------------------------------------------------------------------
// maybe we should have no-param create() that guarantees uniqueness of the new node?
+
    /** create a blank RDF node.
 +
 
 +
        <p>
 +
        Be careful! With this constructor you can create a node that aliases
 +
        another node that already exists in some repository.
 +
        That may or may not be what you want.
 +
        If you want to create a new blank node that is guaranteed to be unique,
 +
        use <method>XRepository::createBlankNode</method>
 +
        <p>
 +
 
 +
        @param NodeID
 +
            the ID for the blank node.
 +
 
 +
        @see <method>XRepository::createBlankNode</method>
 +
    */
 
     create( [in] string NodeID );
 
     create( [in] string NodeID );
    /** create a new, unique blank node */
 
    // FIXME hmm, unique as in distinct from all blank nodes in all repositories? argh...
 
//    create();
 
 
};
 
};
  
service RDFURI : XRDFURI
+
//=============================================================================
 +
/** represents an URI node that may occur in a RDF graph.
 +
 
 +
    @since OOo 3.0
 +
 
 +
    @see XRepository
 +
*/
 +
service URI : XURI
 
{
 
{
 +
 +
    //-------------------------------------------------------------------------
 +
    /** creates an URI RDF node.
 +
 +
        @param Value
 +
            the URI, represented as string.
 +
 +
        @throws com::sun::star::lang::IllegalArgumentException
 +
            if the argument does not represent a valid URI
 +
    */
 
     create( [in] string Value )
 
     create( [in] string Value )
 
         raises( com::sun::star::lang::IllegalArgumentException );
 
         raises( com::sun::star::lang::IllegalArgumentException );
     create2( [in] string Namespace, [in] string LocalName )
+
 
 +
     //-------------------------------------------------------------------------
 +
    /** creates an URI RDF node from namespace prefix and local name.
 +
 
 +
        @param Namespace
 +
            the namespace prefix of the URI, represented as string.
 +
 
 +
        @param Namespace
 +
            the local name of the URI, represented as string.
 +
 
 +
        @throws com::sun::star::lang::IllegalArgumentException
 +
            if the arguments do not represent a valid URI
 +
    */
 +
    createNS( [in] string Namespace, [in] string LocalName )
 
         raises( com::sun::star::lang::IllegalArgumentException );
 
         raises( com::sun::star::lang::IllegalArgumentException );
 
};
 
};
  
service RDFLiteral : XRDFLiteral
+
//=============================================================================
 +
/** represents a literal that may occur in a RDF graph.
 +
 
 +
    @since OOo 3.0
 +
 
 +
    @see XRepository
 +
*/
 +
service Literal : XLiteral
 
{
 
{
 +
    //-------------------------------------------------------------------------
 +
    /** creates a plain literal RDF node.
 +
 +
        @param Value
 +
            the string value of the literal
 +
    */
 
     create( [in] string Value );
 
     create( [in] string Value );
     createWithType( [in] string Value, [in] string Type );
+
 
 +
    //-------------------------------------------------------------------------
 +
    /** creates a typed literal RDF node.
 +
 
 +
        @param Value
 +
            the string value of the literal
 +
 
 +
        @param Type
 +
            the data type of the literal
 +
    */
 +
     createWithType( [in] string Value, [in] XURI Type );
 +
 
 +
    //-------------------------------------------------------------------------
 +
    /** creates a literal RDF node with a language.
 +
 
 +
        @param Value
 +
            the string value of the literal
 +
 
 +
        @param Language
 +
            the language of the literal
 +
    */
 
     createWithLanguage( [in] string Value, [in] string Language );
 
     createWithLanguage( [in] string Value, [in] string Language );
 +
 
     // NOTE: there is no createWithTypeAndLanguage!
 
     // NOTE: there is no createWithTypeAndLanguage!
 
};
 
};
Line 222: Line 301:
 
     @since OOo 3.0
 
     @since OOo 3.0
  
     @see XRDFRepository
+
     @see XRepository
 
  */
 
  */
//FIXME hmm, if Stmt inherited from XRDFNode, we would get convenient reification...
+
//FIXME hmm, if Stmt inherited from XNode, we would get convenient reification...
//  for some value of convenient: actually this would require that we be able to deterministically compute a unique Resource  
+
//  for some value of convenient: actually this would require that we be able
// from only the contents of the triple, like e.g. a cryptographic hash (so we can use it as the subject of reification)
+
// to deterministically compute a unique Resource from only the contents of the
interface XRDFStatement // : XRDFNode
+
// triple, like e.g. a cryptographic hash (so we can use it as the subject of reification)
 +
// furthermore, is there a *standard way* to do it? if not, would not be interoperable?
 +
// another idea: if we dont inherit XNode, why not make this a struct?
 +
// better yet, why not have a Triple<XResource,XResource,XNode>?
 +
interface XStatement // : XNode
 
{
 
{
     [readonly, attribute] XRDFResource Subject;
+
     [readonly, attribute] XResource Subject;
     [readonly, attribute] XRDFResource Predicate;
+
     [readonly, attribute] XResource Predicate;
     [readonly, attribute] XRDFNode     Object;
+
     [readonly, attribute] XNode     Object;
 +
    [readonly, attribute] XURI      Graph;
 
};
 
};
  
//FIXME: would a base RDFException make sense?
 
  
 
//=============================================================================
 
//=============================================================================
Line 241: Line 324:
 
     @since OOo 3.0
 
     @since OOo 3.0
  
     @see XRDFRepository
+
     @see XRepository
 
  */
 
  */
exception RDFParseException : com::sun::star::uno::Exception
+
exception ParseException : com::sun::star::uno::Exception
 
{
 
{
 
};
 
};
Line 253: Line 336:
 
     @since OOo 3.0
 
     @since OOo 3.0
  
     @see XRDFRepository
+
     @see XRepository
 
  */
 
  */
exception RDFQueryException : com::sun::star::uno::Exception
+
exception QueryException : com::sun::star::uno::Exception
 
{
 
{
 
};
 
};
Line 265: Line 348:
 
     @since OOo 3.0
 
     @since OOo 3.0
  
     @see XRDFRepository
+
     @see XRepository
 
  */
 
  */
exception RDFRepositoryException : com::sun::star::uno::Exception
+
exception RepositoryException : com::sun::star::uno::Exception
 
{
 
{
 
};
 
};
Line 277: Line 360:
 
     @since OOo 3.0
 
     @since OOo 3.0
  
     @see XRDFRepository
+
     @see XRepository
 
  */
 
  */
interface XRDFRepositorySupplier
+
interface XRepositorySupplier
 
{
 
{
 
     //-------------------------------------------------------------------------
 
     //-------------------------------------------------------------------------
Line 285: Line 368:
  
 
         @returns
 
         @returns
             an object of type <type>XRDFRepository</type>
+
             an object of type <type>XRepository</type>
 
     */
 
     */
     XRDFRepostiory getRDFRepository();
+
     XRepository getRDFRepository();
  
 
};
 
};
Line 309: Line 392:
 
     @since OOo 3.0
 
     @since OOo 3.0
  
     @see XRDFRepositorySupplier
+
     @see XRepositorySupplier
 
  */
 
  */
interface XRDFRepository
+
interface XRepository
 
{
 
{
 +
    //-------------------------------------------------------------------------
 +
    /** creates a fresh unique blank node.
 +
 +
        @returns
 +
            a newly generated blank node which is unique in this repository
 +
    */
 +
    XBlankNode createBlankNode();
 +
  
 
     //-------------------------------------------------------------------------
 
     //-------------------------------------------------------------------------
Line 338: Line 429:
 
         @throws com::sun::star::datatransfer::UnsupportedFlavorException
 
         @throws com::sun::star::datatransfer::UnsupportedFlavorException
 
             if the format requested is unknown or not supported
 
             if the format requested is unknown or not supported
 
//FIXME: what if GraphName is already in the repository? replace it, or throw? i think i prefer throwing...
 
  
 
         @throws com::sun::star::container::ElementExistException
 
         @throws com::sun::star::container::ElementExistException
Line 345: Line 434:
 
             repository
 
             repository
  
         @throws RDFParseException
+
         @throws ParseException
 
             if the input does not conform to the specified file format.
 
             if the input does not conform to the specified file format.
  
         @throws RDFRepositoryException
+
         @throws RepositoryException
 
             if an error occurs when accessing the repository.
 
             if an error occurs when accessing the repository.
  
Line 354: Line 443:
 
             if an I/O error occurs.
 
             if an I/O error occurs.
  
         @see RDFFileFormat
+
         @see FileFormat
 
     */
 
     */
     void importGraph([in] RDFFileFormat Format,
+
     void importGraph([in] FileFormat Format,
 
                 [in] com::sun::star::io::XInputStream InStream,
 
                 [in] com::sun::star::io::XInputStream InStream,
                 [in] string GraphName)
+
                 [in] XURI GraphName)
 
         raises( com::sun::star::lang::IllegalArgumentException,
 
         raises( com::sun::star::lang::IllegalArgumentException,
 
                 com::sun::star::datatransfer::UnsupportedFlavorException,
 
                 com::sun::star::datatransfer::UnsupportedFlavorException,
 
                 com::sun::star::container::ElementExistException,
 
                 com::sun::star::container::ElementExistException,
                 RDFParseException,
+
                 ParseException,
                 RDFRepositoryException,
+
                 RepositoryException,
 
                 com::sun::star::io::IOException );
 
                 com::sun::star::io::IOException );
  
Line 394: Line 483:
 
             if a graph with the given GraphName does not exist
 
             if a graph with the given GraphName does not exist
  
         @throws RDFRepositoryException
+
         @throws RepositoryException
 
             if an error occurs when accessing the repository.
 
             if an error occurs when accessing the repository.
  
Line 400: Line 489:
 
             if an I/O error occurs.
 
             if an I/O error occurs.
  
         @see RDFFileFormat
+
         @see FileFormat
 
     */
 
     */
     void exportGraph([in] RDFFileFormat Format,
+
     void exportGraph([in] FileFormat Format,
 
                 [in] com::sun::star::io::XOutputStream OutStream,
 
                 [in] com::sun::star::io::XOutputStream OutStream,
                 [in] string GraphName)
+
                 [in] XURI GraphName)
 
         raises( com::sun::star::lang::IllegalArgumentException,
 
         raises( com::sun::star::lang::IllegalArgumentException,
 
                 com::sun::star::datatransfer::UnsupportedFlavorException,
 
                 com::sun::star::datatransfer::UnsupportedFlavorException,
 
                 com::sun::star::container::NoSuchElementException,
 
                 com::sun::star::container::NoSuchElementException,
                 RDFRepositoryException,
+
                 RepositoryException,
 
                 com::sun::star::io::IOException );
 
                 com::sun::star::io::IOException );
  
Line 418: Line 507:
 
             a list containing the names of the graphs in the repository
 
             a list containing the names of the graphs in the repository
  
         @throws RDFRepositoryException
+
         @throws RepositoryException
 
             if an error occurs when accessing the repository.
 
             if an error occurs when accessing the repository.
 
     */
 
     */
     sequence<string> getGraphNames()
+
     sequence<XURI> getGraphNames()
         raises( RDFRepositoryException );
+
         raises( RepositoryException );
  
 
     //-------------------------------------------------------------------------
 
     //-------------------------------------------------------------------------
Line 433: Line 522:
 
             the graph with the given name if it exists, else <NULL/>
 
             the graph with the given name if it exists, else <NULL/>
  
         @throws RDFRepositoryException
+
         @throws RepositoryException
 
             if an error occurs when accessing the repository.
 
             if an error occurs when accessing the repository.
 
     */
 
     */
     XRDFNamedGraph getGraph([in] string GraphName)
+
     XNamedGraph getGraph([in] XURI GraphName)
         raises( RDFRepositoryException );
+
         raises( RepositoryException );
  
 
     //-------------------------------------------------------------------------
 
     //-------------------------------------------------------------------------
Line 444: Line 533:
 
         <p>
 
         <p>
 
         The name must be unique within the repository.
 
         The name must be unique within the repository.
        The name must be a valid file name in an ODF package.
 
//FIXME: clarify a bit more?
 
 
         </p>
 
         </p>
  
Line 460: Line 547:
 
             if a graph with the given GraphName already exists
 
             if a graph with the given GraphName already exists
  
         @throws RDFRepositoryException
+
         @throws RepositoryException
 
             if an error occurs when accessing the repository.
 
             if an error occurs when accessing the repository.
 
     */
 
     */
     XRDFNamedGraph createGraph([in] string GraphName)
+
     XNamedGraph createGraph([in] XURI GraphName)
 
         raises( com::sun::star::container::ElementExistException,
 
         raises( com::sun::star::container::ElementExistException,
 
                 com::sun::star::lang::IllegalArgumentException,
 
                 com::sun::star::lang::IllegalArgumentException,
                 RDFRepositoryException );
+
                 RepositoryException );
  
 
     //-------------------------------------------------------------------------
 
     //-------------------------------------------------------------------------
Line 473: Line 560:
  
 
         <p>
 
         <p>
         This invalidates any instances of XRDFNamedGraph for the parameter.
+
         This invalidates any instances of XNamedGraph for the parameter.
 
         </p>
 
         </p>
  
Line 482: Line 569:
 
             if a graph with the given GraphName does not exist
 
             if a graph with the given GraphName does not exist
  
         @throws RDFRepositoryException
+
         @throws RepositoryException
 
             if an error occurs when accessing the repository.
 
             if an error occurs when accessing the repository.
 
     */
 
     */
     void destroyGraph([in] string GraphName)
+
     void destroyGraph([in] XURI GraphName)
 
         raises( com::sun::star::container::NoSuchElementException,
 
         raises( com::sun::star::container::NoSuchElementException,
                 RDFRepositoryException );
+
                 RepositoryException );
 
+
   
 
+
 
+
 
+
 
     //-------------------------------------------------------------------------
 
     //-------------------------------------------------------------------------
     /** executes a SPARQL "SELECT" query.
+
     /** gets matching RDF statements from the repository.
//FIXME: remove this? seems redundant? do we want to have _both_ iterator-returning and sequence-returning queries???
+
  
 
         <p>
 
         <p>
         This method runs a SPARQL query that returns a list of variable
+
         Any parameter may be <NULL/>, which acts as a wildcard.
        bindings, i.e., a query beginning with "SELECT".
+
         For example, to get all statements about myURI:
         The result is basically a (rectangular) table with labeled columns,
+
         <code>getStatements(myURI, null, null)</code>
         where individual cells may be <NULL/>.
+
 
         </p>
 
         </p>
  
         @param Query
+
         @param Subject
             the SPARQL query string
+
             the subject of the RDF triple.
  
         @returns
+
         @param Predicate
             a pair, containing
+
             the predicate of the RDF triple.
            <li>a list of query variable names (column labels)</li>
+
            <li>a list of query results (rows),
+
                each being a list of bindings for the above variables</li>
+
  
         @throws RDFQueryException
+
         @param Object
             if the query string is malformed, or evaluation fails
+
             the object of the RDF triple.
 +
 
 +
        @returns
 +
            an iterator over all RDF statements in the repository that match
 +
            the parameters, represented as an
 +
            enumeration of <type>XStatement</type>
 +
           
 +
        @throws com::sun::star::lang::IllegalArgumentException
 +
            if ... //FIXME: TODO: other cases?
  
         @throws RDFRepositoryException
+
         @throws RepositoryException
 
             if an error occurs when accessing the repository.
 
             if an error occurs when accessing the repository.
 +
 +
        @see XStatement
 +
        @see XNamedGraph::getStatements
 
     */
 
     */
     Pair<sequence<string>,sequence<sequence<XRDFNode> > > querySelect([in] string Query)
+
     com::sun::star::container::XEnumeration/*<XStatement>*/ getStatements(
         raises( RDFQueryException,
+
            [in] XResource Subject,
                 RDFRepositoryException );
+
            [in] XResource Predicate,
 +
            [in] XNode Object)
 +
         raises( com::sun::star::lang::IllegalArgumentException,
 +
                 RepositoryException );
 +
 
 +
// Enumeration< XStatement > getStatementsRDFa(s,p,o)
 +
 
  
 
     //-------------------------------------------------------------------------
 
     //-------------------------------------------------------------------------
Line 542: Line 638:
 
//FIXME: do we need example result here, or is this clear enough?
 
//FIXME: do we need example result here, or is this clear enough?
  
         @throws RDFQueryException
+
         @throws QueryException
 
             if the query string is malformed, or evaluation fails
 
             if the query string is malformed, or evaluation fails
  
         @throws RDFRepositoryException
+
         @throws RepositoryException
 
             if an error occurs when accessing the repository.
 
             if an error occurs when accessing the repository.
 +
 +
        @see XQuerySelectResult
 
     */
 
     */
//    Pair<sequence<string>,XRDFIterator<sequence<XRDFNode>>> querySelect([in] string Query)
+
//    Pair<sequence<string>,XRDFIterator<sequence<XNode>>> querySelect([in] string Query)
    Pair<sequence<string>,com::sun::star::container::XEnumeration/*<sequence<XRDFNode>>*/> querySelect([in] string Query)
+
//    Pair<sequence<string>,com::sun::star::container::XEnumeration/*<sequence<XNode>>*/> querySelect([in] string Query)
         raises( RDFQueryException,
+
    XQuerySelectResult querySelect([in] string Query)
                 RDFRepositoryException );
+
         raises( QueryException,
 +
                 RepositoryException );
  
 
     //-------------------------------------------------------------------------
 
     //-------------------------------------------------------------------------
Line 565: Line 664:
  
 
         @returns
 
         @returns
             an iterator over the query result graph
+
             an iterator over the query result graph, represented as an
 +
            enumeration of <type>XStatement</type>
  
         @throws RDFQueryException
+
         @throws QueryException
 
             if the query string is malformed, or evaluation fails
 
             if the query string is malformed, or evaluation fails
  
         @throws RDFRepositoryException
+
         @throws RepositoryException
 
             if an error occurs when accessing the repository.
 
             if an error occurs when accessing the repository.
 +
 +
        @see XStatement
 
     */
 
     */
//    XRDFIterator<XRDFStatement> queryConstruct([in] string Query)
+
//    XRDFIterator<XStatement> queryConstruct([in] string Query)
     com::sun::star::container::XEnumeration/*<XRDFStatement>*/ queryConstruct([in] string Query)
+
     com::sun::star::container::XEnumeration/*<XStatement>*/ queryConstruct([in] string Query)
         raises( RDFQueryException,
+
         raises( QueryException,
                 RDFRepositoryException );
+
                 RepositoryException );
  
 
     //-------------------------------------------------------------------------
 
     //-------------------------------------------------------------------------
Line 592: Line 694:
 
             the boolean query result
 
             the boolean query result
  
         @throws RDFQueryException
+
         @throws QueryException
 
             if the query string is malformed, or evaluation fails
 
             if the query string is malformed, or evaluation fails
  
         @throws RDFRepositoryException
+
         @throws RepositoryException
 
             if an error occurs when accessing the repository.
 
             if an error occurs when accessing the repository.
 
     */
 
     */
 
     boolean queryAsk([in] string Query)
 
     boolean queryAsk([in] string Query)
         raises( RDFQueryException,
+
         raises( QueryException,
                 RDFRepositoryException );
+
                 RepositoryException );
  
 
//FIXME: how to handle inference? as a query parameter? in constructor?
 
//FIXME: how to handle inference? as a query parameter? in constructor?
Line 619: Line 721:
 
         <li>If the RDFaContent parameter is the empty string, add the following
 
         <li>If the RDFaContent parameter is the empty string, add the following
 
             RDF statement to an unspecified named graph:
 
             RDF statement to an unspecified named graph:
             <li>Subject Predicate XRDFLiteral(Object->getText())</li>
+
             <li>Subject Predicate XLiteral(Object->getText())</li>
 
         </li>
 
         </li>
 
         <li>If the RDFaContent parameter is not the empty string, add the
 
         <li>If the RDFaContent parameter is not the empty string, add the
 
             following RDFa statements to an unspecified named graph:
 
             following RDFa statements to an unspecified named graph:
             <li>Subject Predicate XRDFLiteral(RDFaContent^^RDFaDatatype)</li>
+
             <li>Subject Predicate XLiteral(RDFaContent^^RDFaDatatype)</li>
             <li>Subject rdfs:label XRDFLiteral(Object->getText())</li>
+
             <li>Subject rdfs:label XLiteral(Object->getText())</li>
 
         </li>
 
         </li>
 
         </p>
 
         </p>
Line 636: Line 738:
 
         or its literal content (RDFa)?
 
         or its literal content (RDFa)?
 
         </p>
 
         </p>
 +
//FIXME: updates???
  
 
         @param Subject
 
         @param Subject
Line 649: Line 752:
 
             the rdfa:content attribute (may be the empty string).
 
             the rdfa:content attribute (may be the empty string).
  
         @param RDFaContent
+
         @param RDFaDatatype
 
             the rdfa:datatype attribute (may be the empty string).
 
             the rdfa:datatype attribute (may be the empty string).
  
Line 656: Line 759:
 
             or Object is of a type that can not have RDFa meta data attached.
 
             or Object is of a type that can not have RDFa meta data attached.
  
         @throws RDFRepositoryException
+
         @throws RepositoryException
 
             if an error occurs when accessing the repository.
 
             if an error occurs when accessing the repository.
 
     */
 
     */
 
// FIXME: if repo does not do transactions, this is maybe not atomic. error handling?
 
// FIXME: if repo does not do transactions, this is maybe not atomic. error handling?
 
// FIXME: how to call this ? setStatementFromContent? setStatementUsingContentLiteral?
 
// FIXME: how to call this ? setStatementFromContent? setStatementUsingContentLiteral?
     void setStatementRDFa([in] XRDFURI Subject,
+
     void setStatementRDFa([in] XURI Subject,
             [in] XRDFURI Predicate,
+
             [in] XURI Predicate,
 
             [in] com::sun::star::text::XTextRange Object,
 
             [in] com::sun::star::text::XTextRange Object,
 
             [in] string RDFaContent,
 
             [in] string RDFaContent,
 
             [in] string RDFaDatatype)
 
             [in] string RDFaDatatype)
 
         raises( com::sun::star::lang::IllegalArgumentException,
 
         raises( com::sun::star::lang::IllegalArgumentException,
                 RDFRepositoryException );
+
                 RepositoryException );
  
 
     //-------------------------------------------------------------------------
 
     //-------------------------------------------------------------------------
Line 685: Line 788:
 
             RDFa meta data attached.
 
             RDFa meta data attached.
  
         @throws RDFRepositoryException
+
         @throws RepositoryException
 
             if an error occurs when accessing the repository.
 
             if an error occurs when accessing the repository.
 
     */
 
     */
 
     void removeStatementRDFa([in] com::sun::star::text::XTextRange Object)
 
     void removeStatementRDFa([in] com::sun::star::text::XTextRange Object)
 
         raises( com::sun::star::lang::IllegalArgumentException,
 
         raises( com::sun::star::lang::IllegalArgumentException,
                 RDFRepositoryException );
+
                 RepositoryException );
  
 
     //-------------------------------------------------------------------------
 
     //-------------------------------------------------------------------------
Line 712: Line 815:
 
             RDFa meta data attached.
 
             RDFa meta data attached.
  
         @throws RDFRepositoryException
+
         @throws RepositoryException
 
             if an error occurs when accessing the repository.
 
             if an error occurs when accessing the repository.
 
     */
 
     */
     Pair<XRDFStatement,XRDFStatement> getStatementRDFa(
+
     Pair<XStatement,XStatement> getStatementRDFa(
 
             [in] XMetadatable Element)
 
             [in] XMetadatable Element)
 
         raises( com::sun::star::lang::IllegalArgumentException,
 
         raises( com::sun::star::lang::IllegalArgumentException,
                 RDFRepositoryException );
+
                 RepositoryException );
 +
 
 +
    //-------------------------------------------------------------------------
 +
    /** gets matching RDFa statements from the repository.
 +
 
 +
        <p>
 +
        This method exists because RDFa statements are not part of any named
 +
        graph, and thus they cannot be enumerated with
 +
        <method>XNamedGraph::getStatements</method>.
 +
        </p>
 +
 
 +
        <p>
 +
        Any parameter may be <NULL/>, which acts as a wildcard.
 +
        For example, to get all statements about myURI:
 +
        <code>getStatementsRDFa(myURI, null, null)</code>
 +
        </p>
 +
 
 +
        @param Subject
 +
            the subject of the RDF triple.
 +
 
 +
        @param Predicate
 +
            the predicate of the RDF triple.
 +
 
 +
        @param Object
 +
            the object of the RDF triple.
 +
 
 +
        @returns
 +
            an iterator over all RDF statements in the repository that match
 +
            the parameters, represented as an
 +
            enumeration of <type>XStatement</type>
 +
           
 +
        @throws com::sun::star::lang::IllegalArgumentException
 +
            if ... //FIXME: TODO: other cases?
 +
 
 +
        @throws RepositoryException
 +
            if an error occurs when accessing the repository.
 +
 
 +
        @see XStatement
 +
        @see XRepository::getStatements
 +
        @see XNamedGraph::getStatements
 +
    */
 +
    com::sun::star::container::XEnumeration/*<XStatement>*/ getStatementsRDFa(
 +
            [in] XResource Subject,
 +
            [in] XResource Predicate,
 +
            [in] XNode Object)
 +
        raises( com::sun::star::lang::IllegalArgumentException,
 +
                RepositoryException );
  
 
};
 
};
Line 728: Line 877:
 
     @since OOo 3.0
 
     @since OOo 3.0
  
     @see XRDFRepository
+
     @see XRepository
     @see XRDFRepositorySupplier
+
     @see XRepositorySupplier
 
  */
 
  */
service RDFRepository : XRDFRepository
+
service Repository : XRepository
 
{
 
{
 
     /** constructs repository with in-memory storage.
 
     /** constructs repository with in-memory storage.
Line 737: Line 886:
 
     create();
 
     create();
 
     // FIXME: if we want to support HTTP/SQL-based storage, or inference, define more constructors here
 
     // FIXME: if we want to support HTTP/SQL-based storage, or inference, define more constructors here
 +
};
 +
 +
 +
//=============================================================================
 +
/** represents the result of a SPARQL "SELECT" query.
 +
 +
    <p>
 +
    The result consists of:
 +
    <li>a list of query variable names (column labels)</li>
 +
    <li>an iterator of query results (rows),
 +
        each being a list of bindings for the above variables</li>
 +
    Note that each query result retrieved via
 +
    <method>com::sun::star::container::XEnumeration::nextElement</method>
 +
    has the type
 +
    <type>sequence&lt;XNode&gt;</type>,
 +
    the length of the sequence being the same as the number of query variables.
 +
    </p>
 +
 +
    @since OOo 3.0
 +
 +
    @see <method>XRepository::querySelect</method>
 +
    @see XNode
 +
*/
 +
interface XQuerySelectResult : com::sun::star::container::XEnumeration
 +
{
 +
    //-------------------------------------------------------------------------
 +
    /** get the names of the query variables.
 +
 +
        <p>
 +
        </p>
 +
    */
 +
    sequence<string> getBindingNames();
 
};
 
};
  
Line 744: Line 925:
  
 
// FIXME: do we need this at all???
 
// FIXME: do we need this at all???
// we could do all this at the XRDFRepository, w/ graph URI parameter
+
// we could do all this at the XRepository, w/ graph URI parameter
 
// but i find it more convenient to have this extra type
 
// but i find it more convenient to have this extra type
// also, it allows inheriting from XRDFNode, with useful semantics:
+
// also, it allows inheriting from XNode, with useful semantics:
  
 
     <p>
 
     <p>
     Note that this interface inherits from XRDFResource: the
+
     Note that this interface inherits from XResource: the
 
     name of the graph is the string value of the RDF node.
 
     name of the graph is the string value of the RDF node.
 
     This is so that you can easily make RDF statements about named graphs.
 
     This is so that you can easily make RDF statements about named graphs.
Line 756: Line 937:
 
     <p>
 
     <p>
 
     Note that instances may be destroyed via
 
     Note that instances may be destroyed via
     <method>XRDFRepository::destoryGraph()</method>.
+
     <method>XRepository::destoryGraph</method>.
 
     If a graph is destroyed, subsequent calls to <method>addStatement</method>,
 
     If a graph is destroyed, subsequent calls to <method>addStatement</method>,
 
     <method>removeStatement</method> will fail with an
 
     <method>removeStatement</method> will fail with an
Line 764: Line 945:
 
     @since OOo 3.0
 
     @since OOo 3.0
  
     @see XRDFRepository
+
     @see XRepository
 
  */
 
  */
interface XRDFNamedGraph : XRDFResource
+
interface XNamedGraph : XURI
 
{
 
{
 
     //-------------------------------------------------------------------------
 
     //-------------------------------------------------------------------------
Line 778: Line 959:
 
             the name of the graph
 
             the name of the graph
 
     */
 
     */
     string getName();
+
     XURI getName();
  
 
     //-------------------------------------------------------------------------
 
     //-------------------------------------------------------------------------
 
     /** removes all statements from the graph.
 
     /** removes all statements from the graph.
  
         @throws RDFRepositoryException
+
         @throws com::sun::star::container::NoSuchElementException
 +
            if this graph does not exist in the repository any more
 +
 
 +
        @throws RepositoryException
 
             if an error occurs when accessing the repository.
 
             if an error occurs when accessing the repository.
 
     */
 
     */
 
     void clear()
 
     void clear()
         raises( RDFRepositoryException );
+
         raises( com::sun::star::container::NoSuchElementException,
 +
                RepositoryException );
  
 
     //-------------------------------------------------------------------------
 
     //-------------------------------------------------------------------------
Line 795: Line 980:
 
         Note that the ODF elements that can have metadata attached all
 
         Note that the ODF elements that can have metadata attached all
 
         implement the interface XMetadatable, which inherits from
 
         implement the interface XMetadatable, which inherits from
         XRDFResource, meaning that you can simply pass them in as
+
         XResource, meaning that you can simply pass them in as
 
         parameters here, and it will magically work.
 
         parameters here, and it will magically work.
 
         </p>
 
         </p>
Line 814: Line 999:
 
             if this graph does not exist in the repository any more
 
             if this graph does not exist in the repository any more
  
         @throws RDFRepositoryException
+
         @throws RepositoryException
 
             if an error occurs when accessing the repository.
 
             if an error occurs when accessing the repository.
 
     */
 
     */
     void addStatement([in] XRDFResource Subject,
+
     void addStatement([in] XResource Subject,
             [in] XRDFResource Predicate,
+
             [in] XResource Predicate,
             [in] XRDFNode Object)
+
             [in] XNode Object)
 
         raises( com::sun::star::lang::IllegalArgumentException,
 
         raises( com::sun::star::lang::IllegalArgumentException,
 
                 com::sun::star::container::NoSuchElementException,
 
                 com::sun::star::container::NoSuchElementException,
                 RDFRepositoryException );
+
                 RepositoryException );
  
 
     //-------------------------------------------------------------------------
 
     //-------------------------------------------------------------------------
     /** remove RDF statements from the graph.
+
     /** removes matching RDF statements from the graph.
  
 
         <p>
 
         <p>
 
         Note that the ODF elements that can have metadata attached all
 
         Note that the ODF elements that can have metadata attached all
 
         implement the interface XMetadatable, which inherits from
 
         implement the interface XMetadatable, which inherits from
         XRDFResource, meaning that you can simply pass them in as
+
         XResource, meaning that you can simply pass them in as
 
         parameters here, and it will magically work.
 
         parameters here, and it will magically work.
 
         </p>
 
         </p>
Line 855: Line 1,040:
 
             if this graph does not exist in the repository any more
 
             if this graph does not exist in the repository any more
  
         @throws RDFRepositoryException
+
         @throws RepositoryException
 
             if an error occurs when accessing the repository.
 
             if an error occurs when accessing the repository.
 
     */
 
     */
     void removeStatements([in] XRDFResource Subject,
+
     void removeStatements([in] XResource Subject,
             [in] XRDFResource Predicate,
+
             [in] XResource Predicate,
             [in] XRDFNode Object)
+
             [in] XNode Object)
 
         raises( com::sun::star::lang::IllegalArgumentException,
 
         raises( com::sun::star::lang::IllegalArgumentException,
 
                 com::sun::star::container::NoSuchElementException,
 
                 com::sun::star::container::NoSuchElementException,
                 RDFRepositoryException );
+
                 RepositoryException );
  
 
     //-------------------------------------------------------------------------
 
     //-------------------------------------------------------------------------
     /** gets RDF statements from a graph.
+
     /** gets matching RDF statements from a graph.
  
 
         <p>
 
         <p>
 
         Note that the ODF elements that can have metadata attached all
 
         Note that the ODF elements that can have metadata attached all
 
         implement the interface XMetadatable, which inherits from
 
         implement the interface XMetadatable, which inherits from
         XRDFResource, meaning that you can simply pass them in as
+
         XResource, meaning that you can simply pass them in as
 
         parameters here, and it will magically work.
 
         parameters here, and it will magically work.
 
         </p>
 
         </p>
Line 892: Line 1,077:
 
         @returns
 
         @returns
 
             an iterator over all RDF statements in the graph that match
 
             an iterator over all RDF statements in the graph that match
             the parameters
+
             the parameters, represented as an
 +
            enumeration of <type>XStatement</type>
 
              
 
              
 
         @throws com::sun::star::lang::IllegalArgumentException
 
         @throws com::sun::star::lang::IllegalArgumentException
Line 900: Line 1,086:
 
             if this graph does not exist in the repository any more
 
             if this graph does not exist in the repository any more
  
         @throws RDFRepositoryException
+
         @throws RepositoryException
 
             if an error occurs when accessing the repository.
 
             if an error occurs when accessing the repository.
 +
 +
        @see XStatement
 +
        @see XRepository::getStatements
 
     */
 
     */
     XEnumeration/*<XRDFStatement>*/ getStatements([in] XRDFResource Subject,
+
     com::sun::star::container::XEnumeration/*<XStatement>*/ getStatements(
             [in] XRDFResource Predicate,
+
            [in] XResource Subject,
             [in] XRDFNode Object)
+
             [in] XResource Predicate,
 +
             [in] XNode Object)
 
         raises( com::sun::star::lang::IllegalArgumentException,
 
         raises( com::sun::star::lang::IllegalArgumentException,
 
                 com::sun::star::container::NoSuchElementException,
 
                 com::sun::star::container::NoSuchElementException,
                 RDFRepositoryException );
+
                 RepositoryException );
  
 
};
 
};
Line 919: Line 1,109:
 
     <p>
 
     <p>
 
     These constants are mainly for use with
 
     These constants are mainly for use with
     <method>XRDFRepository::importGraph()</method>
+
     <method>XRepository::importGraph</method>
     and <method>XRDFRepository::exportGraph()</method>.
+
     and <method>XRepository::exportGraph</method>.
 
     </p>
 
     </p>
  
 
     @since OOo 3.0
 
     @since OOo 3.0
  
     @see XRDFRepository
+
     @see XRepository
 
  */
 
  */
constants RDFFileFormat
+
constants FileFormat
 
{
 
{
 
     /// <a href="http://www.w3.org/TR/rdf-syntax-grammar/">RDF/XML</a>
 
     /// <a href="http://www.w3.org/TR/rdf-syntax-grammar/">RDF/XML</a>
     const string RDF_XML   = "application/rdf+xml";
+
     const short RDF_XML     = 0;    // "application/rdf+xml";
 +
    // argh! idlc does not even do string constants!
  
 
     /// <a href="http://www.w3.org/DesignIssues/Notation3">N3 (Notation-3)</a>
 
     /// <a href="http://www.w3.org/DesignIssues/Notation3">N3 (Notation-3)</a>
     const string N3         = "text/rdf+n3";
+
     const short N3         = 1;    // "text/rdf+n3";
  
 
     /// <a href="http://www.w3.org/TR/rdf-testcases/#ntriples">N-Triples</a>
 
     /// <a href="http://www.w3.org/TR/rdf-testcases/#ntriples">N-Triples</a>
     const string NTRIPLES   = "text/plain"; // argh!!!
+
     const short NTRIPLES   = 2;    // "text/plain"; // argh!!!
  
 
     /// <a href="http://www.wiwiss.fu-berlin.de/suhl/bizer/TriG/Spec/">TriG</a>
 
     /// <a href="http://www.wiwiss.fu-berlin.de/suhl/bizer/TriG/Spec/">TriG</a>
     const string TRIG       = "application/x-trig";
+
     const short TRIG       = 3;    // "application/x-trig";
  
 
     /// <a href="http://sw.nokia.com/trix/TriX.html">TriX</a>
 
     /// <a href="http://sw.nokia.com/trix/TriX.html">TriX</a>
     const string TRIX       = "if only the damn server were up i'd know";
+
     const short TRIX       = 4;    // "if only the damn server were up i'd know";
  
 
     /// <a href="http://www.dajobe.org/2004/01/turtle/">Turtle</a>
 
     /// <a href="http://www.dajobe.org/2004/01/turtle/">Turtle</a>
     const string TURTLE     = "application/turtle";
+
     const short TURTLE     = 5;    // "application/turtle";
  
 
};
 
};
Line 954: Line 1,145:
 
     @since OOo 3.0
 
     @since OOo 3.0
  
     @see XRDFRepository
+
     @see XRepository
 
  */
 
  */
 
constants RDFNamespaces
 
constants RDFNamespaces
 
{
 
{
 
     //FIXME const structs are not legal IDL
 
     //FIXME const structs are not legal IDL
     ///
+
     //FIXME neither are string constants!
 
     const StringPair RDF = "rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
 
     const StringPair RDF = "rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
  
Line 973: Line 1,164:
 
     <p>
 
     <p>
 
     To make using ODF elements as part of RDF statements more convenient,
 
     To make using ODF elements as part of RDF statements more convenient,
     this interface inherits from XRDFResource.
+
     this interface inherits from XResource.
 
     </p>
 
     </p>
  
 
     @since OOo 3.0
 
     @since OOo 3.0
  
     @see XRDFRepository
+
     @see XRepository
 
  */
 
  */
//FIXME: inherit from XRDFResource ??? we can call createMapping, or just use the XmlId...
+
//FIXME: inherit from XResource ??? we can call createMapping, or just use the XmlId...
interface XMetadatable : XRDFResource
+
interface XMetadatable : XResource
 
{
 
{
 
     //-------------------------------------------------------------------------
 
     //-------------------------------------------------------------------------
Line 1,011: Line 1,202:
 
     Such a mapping works by associating the XML ID of the ODF element with
 
     Such a mapping works by associating the XML ID of the ODF element with
 
     the URI by an RDF statement of the form:
 
     the URI by an RDF statement of the form:
     URI pkg:idref XmlId.
+
     <code>URI pkg:idref XmlId.</code>
 
     </p>
 
     </p>
  
 
     <p>
 
     <p>
     Note that this interface inherits from <type>XRDFResource</type>: the
+
     Note that this interface inherits from <type>XResource</type>: the
 
     UUID of the package is the string value of the RDF node.
 
     UUID of the package is the string value of the RDF node.
 
     This is so that you can easily make RDF statements about the package.
 
     This is so that you can easily make RDF statements about the package.
Line 1,022: Line 1,213:
 
     @since OOo 3.0
 
     @since OOo 3.0
  
     @see XRDFRepository
+
     @see XRepository
 
  */
 
  */
 
  // This is supposed to be implemented by the _document_, not the repository
 
  // This is supposed to be implemented by the _document_, not the repository
Line 1,032: Line 1,223:
 
// XPackageMetadata?
 
// XPackageMetadata?
 
// any other permutation?
 
// any other permutation?
interface XManifestAccess : XRDFResource
+
//interface XManifestAccess : XResource
 +
interface XDocumentMetadataAccess : XURI
 
{
 
{
 
     //-------------------------------------------------------------------------
 
     //-------------------------------------------------------------------------
Line 1,088: Line 1,280:
 
             the URI associated with the element
 
             the URI associated with the element
 
     */
 
     */
//    XRDFURI createMapping(XMetadatable Element);
+
//    XURI createMapping(XMetadatable Element);
     XRDFURI getOrCreateURIForElement([in] XMetadatable Element);
+
     XURI getOrCreateURIForElement([in] XMetadatable Element);
  
 
     //-------------------------------------------------------------------------
 
     //-------------------------------------------------------------------------
Line 1,108: Line 1,300:
 
     */
 
     */
 
   // this one uses parameter uri
 
   // this one uses parameter uri
//    void createMapping([in] XMetadatable Element, [in] XRDFURI URI);
+
//    void createMapping([in] XMetadatable Element, [in] XURI URI);
     void createMappingForElement([in] XMetadatable Element, [in] XRDFURI URI);
+
     void createMappingForElement([in] XMetadatable Element, [in] XURI URI);
  
 
     //-------------------------------------------------------------------------
 
     //-------------------------------------------------------------------------
Line 1,120: Line 1,312:
 
             the URI associated with the element, or <NULL/>
 
             the URI associated with the element, or <NULL/>
 
     */
 
     */
     XRDFURI getURIForElement([in] XMetadatable Element);
+
     XURI getURIForElement([in] XMetadatable Element);
  
 
};
 
};

Revision as of 12:36, 2 May 2008

Description

This is a draft proposal for a RDF metadata API.

Resource Description Framework The ODF metadata specification

Comments

Leo Sauermann 31.3.2008 (I am a long-time RDF user and contributed to RDF2Go, Sesame, and used Jena for years, the java apis, also did other stuff with rdf in python and php)

  • For the RDFFileFormat, use the mimetypes listed in RDF2go.
  • You can make a method in Statement - getReifiedStatement - that returns a reified statement.
  • Make XRDFReifiedStatement a subclass of XRDFResource - add getStatement there to return the statment it reifies (this is like in Jena ReifiedStatement/Java)
  • destroyGraph sounds weird - deleteGraph?
  • I would do an Interface for the querySelect results. (XRDFQueryResultTable). They can be serialized and deserialized, ...passing a nice object around is maybe better here
  • You should add query methods to RDFRepository for finding statements find(s,p,o, [optional[context]]). These return QUADS - statements with a fourth column, the graph name
  • add XRDFContextStatement with a XRDFREsource as context - then you can return these as results of find mehtods in RDFRepository
  • add addStatement and RemoveStatement to RDFRepository, but passing in XRDFContextStatement
  • RDFNamespaces: add RDFS, Dublin Core, FOAF.
  • although its not conformant, making a constructor for blank nodes with a passeable string can be handy sometimes. Still, better don't do it...hm. not very helpful :-)
  • On the long run, you may want to add transactions:
    • XRDFRepositorySupplier is the main repository then.
    • XRDFRepository is a transaction.
    • XRDFRepository gets the methods: commit, rollback, isChanged(), setAutoCommit (true/false - setting to true commits after each command), getAutoCommit...

API Draft

/*
 
API for RDF (Resource Description Framework) metadata & such.
 
the main parts:
 
 
the RDF model part:
- XRepository
  a set of named RDF graphs
  basically, this is where the metadata lives
 
- XNamedGraph
  a single named graph
  this likely would be implemented as just a shim with the graph name and
  pointer to the repository
 
- XNode, XResource, XBlankNode, XURI, XLiteral
  RDF node types
  these would ideally be value types, but we do need subtype polymorphism...
 
- XStatement
  RDF triple: subject, predicate, object
 
 
the document integration part:
- XRepositorySupplier
  implemented at the document to supply the (per-document) XRepository
 
- XManifestAccess
  implemented at the document; contains integration between document content
  and meta-data
 
- XMetadatable:
  this must be implemented by every ODF element in the various document
  types that may have xml:id attribute;
  basically, it makes the XML ID attribute available
 
 
note that the two parts must communicate only via this API; no XUnoTunnel etc. allowed.
 
 */
 
 
module com {   module sun {   module star {   module beans {
 
//=============================================================================
/** A tuple, or pair.
 
    <p>
    This structure allows for conveniently packing together two values of
    any type, and could be useful as the result type of methods.
    </p>
 
    @since OOo 3.0
 */
struct Pair<T, U> {
 
    /// first object
    T First;
 
    /// second object
    U Second;
};
 
//=============================================================================
 
}; }; }; };
 
module com {   module sun {   module star {   module rdf {
 
//=============================================================================
/** represents a node that may occur in a RDF graph.
 
//FIXME paint a picture
    XNode
    |
    |---XLiteral
    |
    XResource
    |
    |---XBlankNode
    |
    XURI
 
    @since OOo 3.0
 
    @see XRepository
 */
interface XNode
{
    [readonly, attribute] string StringValue;
};
 
//=============================================================================
/** represents a resource node that may occur in a RDF graph.
 
    <p>
    Note that this interface exists only to separate resources from literals.
    </p>
 
    @since OOo 3.0
 
    @see XRepository
 */
interface XResource : XNode
{
};
 
//=============================================================================
/** represents a blank node that may occur in a RDF graph.
 
    <p>
    Blank nodes are distinct, but have no URI; in other words,
    they are resources that are anonymous.
    </p>
 
    @since OOo 3.0
 
    @see XRepository
 */
interface XBlankNode : XResource
{
};
 
//=============================================================================
/** represents an URI node that may occur in a RDF graph.
 
//FIXME: URI or IRI or what?
    <p>
    Note that this is actually an IRI, but the RDF literature speaks of URIs
    only, so we chose to use established terminology.
    </p>
 
    @since OOo 3.0
 
    @see XRepository
 */
interface XURI : XResource
{
    [readonly, attribute] string LocalName;
    [readonly, attribute] string Namespace;
};
 
//=============================================================================
/** represents a literal that may occur in a RDF graph.
 
    @since OOo 3.0
 
    @see XRepository
 */
interface XLiteral : XNode
{
    [readonly, attribute] string Value;
    [readonly, attribute] string Language;
    [readonly, attribute] XURI   Datatype;
    //FIXME: TODO: have not looked at handling all kinds of types, maybe just have an any attr here...
};
 
//=============================================================================
/** represents a blank node that may occur in a RDF graph.
 
    @since OOo 3.0
 
    @see XRepository
 */
service BlankNode : XBlankNode
{
    //-------------------------------------------------------------------------
    /** create a blank RDF node.
 
        <p>
        Be careful! With this constructor you can create a node that aliases
        another node that already exists in some repository.
        That may or may not be what you want.
        If you want to create a new blank node that is guaranteed to be unique,
        use <method>XRepository::createBlankNode</method>
        <p>
 
        @param NodeID
            the ID for the blank node.
 
        @see <method>XRepository::createBlankNode</method>
     */
    create( [in] string NodeID );
};
 
//=============================================================================
/** represents an URI node that may occur in a RDF graph.
 
    @since OOo 3.0
 
    @see XRepository
 */
service URI : XURI
{
 
    //-------------------------------------------------------------------------
    /** creates an URI RDF node.
 
        @param Value
            the URI, represented as string.
 
        @throws com::sun::star::lang::IllegalArgumentException
            if the argument does not represent a valid URI
     */
    create( [in] string Value )
        raises( com::sun::star::lang::IllegalArgumentException );
 
    //-------------------------------------------------------------------------
    /** creates an URI RDF node from namespace prefix and local name.
 
        @param Namespace 
            the namespace prefix of the URI, represented as string.
 
        @param Namespace 
            the local name of the URI, represented as string.
 
        @throws com::sun::star::lang::IllegalArgumentException
            if the arguments do not represent a valid URI
     */
    createNS( [in] string Namespace, [in] string LocalName )
        raises( com::sun::star::lang::IllegalArgumentException );
};
 
//=============================================================================
/** represents a literal that may occur in a RDF graph.
 
    @since OOo 3.0
 
    @see XRepository
 */
service Literal : XLiteral
{
    //-------------------------------------------------------------------------
    /** creates a plain literal RDF node.
 
        @param Value
            the string value of the literal
     */
    create( [in] string Value );
 
    //-------------------------------------------------------------------------
    /** creates a typed literal RDF node.
 
        @param Value
            the string value of the literal
 
        @param Type
            the data type of the literal
     */
    createWithType( [in] string Value, [in] XURI Type );
 
    //-------------------------------------------------------------------------
    /** creates a literal RDF node with a language.
 
        @param Value
            the string value of the literal
 
        @param Language
            the language of the literal
     */
    createWithLanguage( [in] string Value, [in] string Language );
 
    // NOTE: there is no createWithTypeAndLanguage!
};
 
 
//=============================================================================
/** represents a RDF statement, or triple.
 
    @since OOo 3.0
 
    @see XRepository
 */
//FIXME hmm, if Stmt inherited from XNode, we would get convenient reification...
//  for some value of convenient: actually this would require that we be able
// to deterministically compute a unique Resource  from only the contents of the
// triple, like e.g. a cryptographic hash (so we can use it as the subject of reification)
// furthermore, is there a *standard way* to do it? if not, would not be interoperable?
// another idea: if we dont inherit XNode, why not make this a struct?
// better yet, why not have a Triple<XResource,XResource,XNode>?
interface XStatement // : XNode
{
    [readonly, attribute] XResource Subject;
    [readonly, attribute] XResource Predicate;
    [readonly, attribute] XNode     Object;
    [readonly, attribute] XURI      Graph;
};
 
 
//=============================================================================
/** represents an error condition that is signalled on parsing an RDF file.
 
    @since OOo 3.0
 
    @see XRepository
 */
exception ParseException : com::sun::star::uno::Exception
{
};
 
//=============================================================================
/** represents an error condition that is signalled on evaluating a query
    against an RDF Repository.
 
    @since OOo 3.0
 
    @see XRepository
 */
exception QueryException : com::sun::star::uno::Exception
{
};
 
//=============================================================================
/** represents an error condition that is signalled on accessing an RDF
    Repository.
 
    @since OOo 3.0
 
    @see XRepository
 */
exception RepositoryException : com::sun::star::uno::Exception
{
};
 
 
//=============================================================================
/** provides access to an RDF Repository.
 
    @since OOo 3.0
 
    @see XRepository
 */
interface XRepositorySupplier
{
    //-------------------------------------------------------------------------
    /** provides the RDF Repository associated with this object.
 
        @returns
            an object of type <type>XRepository</type>
     */
    XRepository getRDFRepository();
 
};
 
//=============================================================================
/** provides access to a set of named RDF graphs.
 
    <p>
    A repository for storing information according to the data model of the
    <a href="http://www.w3.org/RDF/">Resource Description Framework</a>.
    The RDF triples are stored as a set of named RDF graphs.
    Importing and exporting files in the
    <a href="http://www.w3.org/TR/rdf-syntax-grammar/">RDF/XML</a>
    format is supported.
    Support for other file formats is optional.
    Support for querying the repository with the
    <a href="http://www.w3.org/TR/rdf-sparql-query/">SPARQL</a>
    query language is provided.
    </p>
 
    @since OOo 3.0
 
    @see XRepositorySupplier
 */
interface XRepository
{
    //-------------------------------------------------------------------------
    /** creates a fresh unique blank node.
 
        @returns
            a newly generated blank node which is unique in this repository
     */
    XBlankNode createBlankNode();
 
 
    //-------------------------------------------------------------------------
    /** imports a named graph into the repository.
 
        <p>
        Implementations must support RDF/XML format.
        Support for other RDF formats is optional.
        If the format is not supported by the implementation, an
        <type>UnsupportedFlavorException</type> is raised.
        </p>
 
        @param Format
            the format of the input file
 
        @param InStream
            the input stream, containing an RDF file in the specified format
 
        @param GraphName
            the name of the graph that is imported
 
        @throws com::sun::star::lang::IllegalArgumentException
            if the given stream is <NULL/>
 
        @throws com::sun::star::datatransfer::UnsupportedFlavorException
            if the format requested is unknown or not supported
 
        @throws com::sun::star::container::ElementExistException
            if a graph with the given GraphName already exists in the
            repository
 
        @throws ParseException
            if the input does not conform to the specified file format.
 
        @throws RepositoryException
            if an error occurs when accessing the repository.
 
        @throws com::sun::star::io::IOException
            if an I/O error occurs.
 
        @see FileFormat
     */
    void importGraph([in] FileFormat Format,
                [in] com::sun::star::io::XInputStream InStream,
                [in] XURI GraphName)
        raises( com::sun::star::lang::IllegalArgumentException,
                com::sun::star::datatransfer::UnsupportedFlavorException,
                com::sun::star::container::ElementExistException,
                ParseException,
                RepositoryException,
                com::sun::star::io::IOException );
 
    //-------------------------------------------------------------------------
    /** exports a named graph from the repository.
 
        <p>
        Implementations must support RDF/XML format.
        Support for other RDF formats is optional.
        If the format is not supported by the implementation, an
        <type>UnsupportedFlavorException</type> is raised.
        </p>
 
        @param Format
            the format of the output file
 
        @param OutStream
            the target output stream
 
        @param GraphName
            the name of the graph that is to be exported
 
        @throws com::sun::star::lang::IllegalArgumentException
            if the given stream is <NULL/>
 
        @throws com::sun::star::datatransfer::UnsupportedFlavorException
            if the format requested is unknown or not supported
 
        @throws com::sun::star::container::NoSuchElementException
            if a graph with the given GraphName does not exist
 
        @throws RepositoryException
            if an error occurs when accessing the repository.
 
        @throws com::sun::star::io::IOException
            if an I/O error occurs.
 
        @see FileFormat
     */
    void exportGraph([in] FileFormat Format,
                [in] com::sun::star::io::XOutputStream OutStream,
                [in] XURI GraphName)
        raises( com::sun::star::lang::IllegalArgumentException,
                com::sun::star::datatransfer::UnsupportedFlavorException,
                com::sun::star::container::NoSuchElementException,
                RepositoryException,
                com::sun::star::io::IOException );
 
    //-------------------------------------------------------------------------
    /** gets the names of all the graphs in the repository.
//FIXME: except "unspecified" graphs for RDFa, i guess...
 
        @returns
            a list containing the names of the graphs in the repository
 
        @throws RepositoryException
            if an error occurs when accessing the repository.
     */
    sequence<XURI> getGraphNames()
        raises( RepositoryException );
 
    //-------------------------------------------------------------------------
    /** gets a graph by its name.
 
        @param GraphName
            the name of the graph that is to be returned
 
        @returns
            the graph with the given name if it exists, else <NULL/>
 
        @throws RepositoryException
            if an error occurs when accessing the repository.
     */
    XNamedGraph getGraph([in] XURI GraphName)
        raises( RepositoryException );
 
    //-------------------------------------------------------------------------
    /** creates a graph with the given name.
 
        <p>
        The name must be unique within the repository.
        </p>
 
        @param GraphName
            the name of the graph that is to be created
 
        @returns
            the graph with the given name
 
        @throws com::sun::star::lang::IllegalArgumentException
            if the given GraphName is invalid
 
        @throws com::sun::star::container::ElementExistException
            if a graph with the given GraphName already exists
 
        @throws RepositoryException
            if an error occurs when accessing the repository.
     */
    XNamedGraph createGraph([in] XURI GraphName)
        raises( com::sun::star::container::ElementExistException,
                com::sun::star::lang::IllegalArgumentException,
                RepositoryException );
 
    //-------------------------------------------------------------------------
    /** destroys the graph with the given name, and removes it from the
        repository.
 
        <p>
        This invalidates any instances of XNamedGraph for the parameter.
        </p>
 
        @param GraphName
            the name of the graph that is to be destroyed
 
        @throws com::sun::star::container::NoSuchElementException
            if a graph with the given GraphName does not exist
 
        @throws RepositoryException
            if an error occurs when accessing the repository.
     */
    void destroyGraph([in] XURI GraphName)
        raises( com::sun::star::container::NoSuchElementException,
                RepositoryException );
 
    //-------------------------------------------------------------------------
    /** gets matching RDF statements from the repository.
 
        <p>
        Any parameter may be <NULL/>, which acts as a wildcard.
        For example, to get all statements about myURI:
        <code>getStatements(myURI, null, null)</code>
        </p>
 
        @param Subject
            the subject of the RDF triple.
 
        @param Predicate 
            the predicate of the RDF triple.
 
        @param Object
            the object of the RDF triple.
 
        @returns
            an iterator over all RDF statements in the repository that match
            the parameters, represented as an
            enumeration of <type>XStatement</type>
 
        @throws com::sun::star::lang::IllegalArgumentException
            if ... //FIXME: TODO: other cases?
 
        @throws RepositoryException
            if an error occurs when accessing the repository.
 
        @see XStatement
        @see XNamedGraph::getStatements
     */
    com::sun::star::container::XEnumeration/*<XStatement>*/ getStatements(
            [in] XResource Subject,
            [in] XResource Predicate,
            [in] XNode Object)
        raises( com::sun::star::lang::IllegalArgumentException,
                RepositoryException );
 
// Enumeration< XStatement > getStatementsRDFa(s,p,o)
 
 
    //-------------------------------------------------------------------------
    /** executes a SPARQL "SELECT" query.
 
        <p>
        This method runs a SPARQL query that returns a list of variable
        bindings, i.e., a query beginning with "SELECT".
        The result is basically a (rectangular) table with labeled columns,
        where individual cells may be <NULL/>.
        </p>
 
        @param Query
            the SPARQL query string
 
        @returns
            a pair, containing
            <li>a list of query variable names (column labels)</li>
            <li>an iterator of query results (rows),
                each being a list of bindings for the above variables</li>
//FIXME: do we need example result here, or is this clear enough?
 
        @throws QueryException
            if the query string is malformed, or evaluation fails
 
        @throws RepositoryException
            if an error occurs when accessing the repository.
 
        @see XQuerySelectResult
     */
//    Pair<sequence<string>,XRDFIterator<sequence<XNode>>> querySelect([in] string Query)
//    Pair<sequence<string>,com::sun::star::container::XEnumeration/*<sequence<XNode>>*/> querySelect([in] string Query)
    XQuerySelectResult querySelect([in] string Query)
        raises( QueryException,
                RepositoryException );
 
    //-------------------------------------------------------------------------
    /** executes a SPARQL "CONSTRUCT" query.
 
        <p>
        This method runs a SPARQL query that constructs a result graph,
        i.e., a query beginning with "CONSTRUCT".
        </p>
 
        @param Query
            the SPARQL query string
 
        @returns
            an iterator over the query result graph, represented as an
            enumeration of <type>XStatement</type>
 
        @throws QueryException
            if the query string is malformed, or evaluation fails
 
        @throws RepositoryException
            if an error occurs when accessing the repository.
 
        @see XStatement
     */
//    XRDFIterator<XStatement> queryConstruct([in] string Query)
    com::sun::star::container::XEnumeration/*<XStatement>*/ queryConstruct([in] string Query)
        raises( QueryException,
                RepositoryException );
 
    //-------------------------------------------------------------------------
    /** executes a SPARQL "ASK" query.
 
        <p>
        This method runs a SPARQL query that computes a boolean,
        i.e., a query beginning with "ASK".
        </p>
 
        @param Query
            the SPARQL query string
 
        @returns
            the boolean query result
 
        @throws QueryException
            if the query string is malformed, or evaluation fails
 
        @throws RepositoryException
            if an error occurs when accessing the repository.
     */
    boolean queryAsk([in] string Query)
        raises( QueryException,
                RepositoryException );
 
//FIXME: how to handle inference? as a query parameter? in constructor?
// have a supportsInference() here? inference is, at most, optional...
 
 
//FIXME namespaces??? sesame has support for registering ns prefixes here.
// this might be convenient. or it might be superfluous.
 
    //-------------------------------------------------------------------------
    /** update the RDFa statement(s) that correspond to an ODF element in the
        repository.
 
        <p>
        This method will do the following steps:
        <li>Remove all RDFa statements that involve the Object parameter from
            the repository</li>
        <li>If the RDFaContent parameter is the empty string, add the following
            RDF statement to an unspecified named graph:
            <li>Subject Predicate XLiteral(Object->getText())</li>
        </li>
        <li>If the RDFaContent parameter is not the empty string, add the
            following RDFa statements to an unspecified named graph:
            <li>Subject Predicate XLiteral(RDFaContent^^RDFaDatatype)</li>
            <li>Subject rdfs:label XLiteral(Object->getText())</li>
        </li>
        </p>
 
        <p>
        RDFa statements are handled specially because they are not logically
        part of any graph.
        Also, they have rather unusual semantics. (Don't blame me, i didnt write that spec.)
        Also, just using addStatement for this would be ambiguous:
        if the object is a XMetadatable, do we insert the object itself (URI)
        or its literal content (RDFa)?
        </p>
//FIXME: updates???
 
        @param Subject
            the subject of the RDF triple.
 
        @param Predicate 
            the predicate of the RDF triple.
 
        @param Object
            the object of the RDF triple is the text content of this parameter.
 
        @param RDFaContent
            the rdfa:content attribute (may be the empty string).
 
        @param RDFaDatatype
            the rdfa:datatype attribute (may be the empty string).
 
        @throws com::sun::star::lang::IllegalArgumentException
            if any parameter is <NULL/>,
            or Object is of a type that can not have RDFa meta data attached.
 
        @throws RepositoryException
            if an error occurs when accessing the repository.
     */
// FIXME: if repo does not do transactions, this is maybe not atomic. error handling?
// FIXME: how to call this ? setStatementFromContent? setStatementUsingContentLiteral?
    void setStatementRDFa([in] XURI Subject,
            [in] XURI Predicate,
            [in] com::sun::star::text::XTextRange Object,
            [in] string RDFaContent,
            [in] string RDFaDatatype)
        raises( com::sun::star::lang::IllegalArgumentException,
                RepositoryException );
 
    //-------------------------------------------------------------------------
    /** remove the RDFa statement(s) that correspond to an ODF element from the
        repository.
 
        <p>
        RDFa statements are handled specially because they are not logically
        part of any graph. (Don't blame me.)
        </p>
 
        @param Object
            the element whose RDFa statement(s) should be removed
 
        @throws com::sun::star::lang::IllegalArgumentException
            if the given Element is <NULL/>, or of a type that can not have
            RDFa meta data attached.
 
        @throws RepositoryException
            if an error occurs when accessing the repository.
     */
    void removeStatementRDFa([in] com::sun::star::text::XTextRange Object)
        raises( com::sun::star::lang::IllegalArgumentException,
                RepositoryException );
 
    //-------------------------------------------------------------------------
    /** find the RDFa statement(s) associated with an ODF element.
 
        @param Element
            the ODF element for which RDFa statements should be found
 
        @returns
            <li>if the element has no RDFa meta-data attributes:
                Pair(<NULL/>, <NULL/>)</li>
            <li>if the element has RDFa meta-data attributes,
                and no rdfa:content attached:
                Pair(RDFa-statement, <NULL/>)</li>
            <li>if the element has RDFa meta-data attributes,
                and also rdfa:content attached:
                Pair(RDFa-statement, RDFa-labels-statement)</li>
 
        @throws com::sun::star::lang::IllegalArgumentException
            if the given Element is <NULL/>, or of a type that can not have
            RDFa meta data attached.
 
        @throws RepositoryException
            if an error occurs when accessing the repository.
     */
    Pair<XStatement,XStatement> getStatementRDFa(
            [in] XMetadatable Element)
        raises( com::sun::star::lang::IllegalArgumentException,
                RepositoryException );
 
    //-------------------------------------------------------------------------
    /** gets matching RDFa statements from the repository.
 
        <p>
        This method exists because RDFa statements are not part of any named
        graph, and thus they cannot be enumerated with
        <method>XNamedGraph::getStatements</method>.
        </p>
 
        <p>
        Any parameter may be <NULL/>, which acts as a wildcard.
        For example, to get all statements about myURI:
        <code>getStatementsRDFa(myURI, null, null)</code>
        </p>
 
        @param Subject
            the subject of the RDF triple.
 
        @param Predicate 
            the predicate of the RDF triple.
 
        @param Object
            the object of the RDF triple.
 
        @returns
            an iterator over all RDF statements in the repository that match
            the parameters, represented as an
            enumeration of <type>XStatement</type>
 
        @throws com::sun::star::lang::IllegalArgumentException
            if ... //FIXME: TODO: other cases?
 
        @throws RepositoryException
            if an error occurs when accessing the repository.
 
        @see XStatement
        @see XRepository::getStatements
        @see XNamedGraph::getStatements
     */
    com::sun::star::container::XEnumeration/*<XStatement>*/ getStatementsRDFa(
            [in] XResource Subject,
            [in] XResource Predicate,
            [in] XNode Object)
        raises( com::sun::star::lang::IllegalArgumentException,
                RepositoryException );
 
};
 
 
//=============================================================================
/** provides access to a set of named RDF graphs.
 
    @since OOo 3.0
 
    @see XRepository
    @see XRepositorySupplier
 */
service Repository : XRepository
{
    /** constructs repository with in-memory storage.
     */
    create();
    // FIXME: if we want to support HTTP/SQL-based storage, or inference, define more constructors here
};
 
 
//=============================================================================
/** represents the result of a SPARQL "SELECT" query.
 
    <p>
    The result consists of:
    <li>a list of query variable names (column labels)</li>
    <li>an iterator of query results (rows),
        each being a list of bindings for the above variables</li>
    Note that each query result retrieved via
    <method>com::sun::star::container::XEnumeration::nextElement</method>
    has the type
    <type>sequence&lt;XNode&gt;</type>,
    the length of the sequence being the same as the number of query variables. 
    </p>
 
    @since OOo 3.0
 
    @see <method>XRepository::querySelect</method>
    @see XNode
 */
interface XQuerySelectResult : com::sun::star::container::XEnumeration
{
    //-------------------------------------------------------------------------
    /** get the names of the query variables.
 
        <p>
        </p>
     */
     sequence<string> getBindingNames();
};
 
 
//=============================================================================
/** represents an RDF named graph that is stored in an RDF Repository.
 
// FIXME: do we need this at all???
// we could do all this at the XRepository, w/ graph URI parameter
// but i find it more convenient to have this extra type
// also, it allows inheriting from XNode, with useful semantics:
 
    <p>
    Note that this interface inherits from XResource: the
    name of the graph is the string value of the RDF node.
    This is so that you can easily make RDF statements about named graphs.
    </p>
 
    <p>
    Note that instances may be destroyed via
    <method>XRepository::destoryGraph</method>.
    If a graph is destroyed, subsequent calls to <method>addStatement</method>,
    <method>removeStatement</method> will fail with an
    <type>NoSuchElementException</type>.
    </p>
 
    @since OOo 3.0
 
    @see XRepository
 */
interface XNamedGraph : XURI
{
    //-------------------------------------------------------------------------
    /** returns the name of the graph.
 
        <p>
        The name is unique within the repository.
        </p>
 
        @returns
            the name of the graph
     */
    XURI getName();
 
    //-------------------------------------------------------------------------
    /** removes all statements from the graph.
 
        @throws com::sun::star::container::NoSuchElementException
            if this graph does not exist in the repository any more
 
        @throws RepositoryException
            if an error occurs when accessing the repository.
     */
    void clear()
        raises( com::sun::star::container::NoSuchElementException,
                RepositoryException );
 
    //-------------------------------------------------------------------------
    /** adds a RDF statement to the graph.
 
        <p>
        Note that the ODF elements that can have metadata attached all
        implement the interface XMetadatable, which inherits from
        XResource, meaning that you can simply pass them in as
        parameters here, and it will magically work.
        </p>
 
        @param Subject
            the subject of the RDF triple.
 
        @param Predicate 
            the predicate of the RDF triple.
 
        @param Object
            the object of the RDF triple.
 
        @throws com::sun::star::lang::IllegalArgumentException
            if any parameter is <NULL/> //FIXME: TODO: other cases?
 
        @throws com::sun::star::container::NoSuchElementException
            if this graph does not exist in the repository any more
 
        @throws RepositoryException
            if an error occurs when accessing the repository.
     */
    void addStatement([in] XResource Subject,
            [in] XResource Predicate,
            [in] XNode Object)
        raises( com::sun::star::lang::IllegalArgumentException,
                com::sun::star::container::NoSuchElementException,
                RepositoryException );
 
    //-------------------------------------------------------------------------
    /** removes matching RDF statements from the graph.
 
        <p>
        Note that the ODF elements that can have metadata attached all
        implement the interface XMetadatable, which inherits from
        XResource, meaning that you can simply pass them in as
        parameters here, and it will magically work.
        </p>
 
        <p>
        Any parameter may be <NULL/>, which acts as a wildcard.
        For example, to remove all statements about myURI:
        removeStatement(myURI, null, null)
        </p>
 
        @param Subject
            the subject of the RDF triple.
 
        @param Predicate 
            the predicate of the RDF triple.
 
        @param Object
            the object of the RDF triple.
 
        @throws com::sun::star::lang::IllegalArgumentException
            if ...  //FIXME: TODO: other cases?
 
        @throws com::sun::star::container::NoSuchElementException
            if this graph does not exist in the repository any more
 
        @throws RepositoryException
            if an error occurs when accessing the repository.
     */
    void removeStatements([in] XResource Subject,
            [in] XResource Predicate,
            [in] XNode Object)
        raises( com::sun::star::lang::IllegalArgumentException,
                com::sun::star::container::NoSuchElementException,
                RepositoryException );
 
    //-------------------------------------------------------------------------
    /** gets matching RDF statements from a graph.
 
        <p>
        Note that the ODF elements that can have metadata attached all
        implement the interface XMetadatable, which inherits from
        XResource, meaning that you can simply pass them in as
        parameters here, and it will magically work.
        </p>
 
        <p>
        Any parameter may be <NULL/>, which acts as a wildcard.
        For example, to get all statements about myURI:
        getStatements(myURI, null, null)
        </p>
 
        @param Subject
            the subject of the RDF triple.
 
        @param Predicate 
            the predicate of the RDF triple.
 
        @param Object
            the object of the RDF triple.
 
        @returns
            an iterator over all RDF statements in the graph that match
            the parameters, represented as an
            enumeration of <type>XStatement</type>
 
        @throws com::sun::star::lang::IllegalArgumentException
            if ... //FIXME: TODO: other cases?
 
        @throws com::sun::star::container::NoSuchElementException
            if this graph does not exist in the repository any more
 
        @throws RepositoryException
            if an error occurs when accessing the repository.
 
        @see XStatement
        @see XRepository::getStatements
     */
    com::sun::star::container::XEnumeration/*<XStatement>*/ getStatements(
            [in] XResource Subject,
            [in] XResource Predicate,
            [in] XNode Object)
        raises( com::sun::star::lang::IllegalArgumentException,
                com::sun::star::container::NoSuchElementException,
                RepositoryException );
 
};
 
 
 
//=============================================================================
/** Constants to specify the MIME types of RDF file formats.
 
    <p>
    These constants are mainly for use with
    <method>XRepository::importGraph</method>
    and <method>XRepository::exportGraph</method>.
    </p>
 
    @since OOo 3.0
 
    @see XRepository
 */
constants FileFormat
{
    /// <a href="http://www.w3.org/TR/rdf-syntax-grammar/">RDF/XML</a>
    const short RDF_XML     = 0;    // "application/rdf+xml";
    // argh! idlc does not even do string constants!
 
    /// <a href="http://www.w3.org/DesignIssues/Notation3">N3 (Notation-3)</a>
    const short N3          = 1;    // "text/rdf+n3";
 
    /// <a href="http://www.w3.org/TR/rdf-testcases/#ntriples">N-Triples</a>
    const short NTRIPLES    = 2;    // "text/plain"; // argh!!!
 
    /// <a href="http://www.wiwiss.fu-berlin.de/suhl/bizer/TriG/Spec/">TriG</a>
    const short TRIG        = 3;    // "application/x-trig";
 
    /// <a href="http://sw.nokia.com/trix/TriX.html">TriX</a>
    const short TRIX        = 4;    // "if only the damn server were up i'd know";
 
    /// <a href="http://www.dajobe.org/2004/01/turtle/">Turtle</a>
    const short TURTLE      = 5;    // "application/turtle";
 
};
 
//=============================================================================
/** Constants to specify some useful namespaces.
 
    @since OOo 3.0
 
    @see XRepository
 */
constants RDFNamespaces
{
    //FIXME const structs are not legal IDL
    //FIXME neither are string constants!
    const StringPair RDF = "rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
 
    const StringPair PKG = "pkg", "http://docs.oasis-open.org/opendocument/meta/package/common#";
    const StringPair ODF = "odf", "http://docs.oasis-open.org/opendocument/meta/package/odf#";
};
 
 
//=============================================================================
/** marks an object representing an ODF element that may have RDF meta data
    attached.
 
    <p>
    To make using ODF elements as part of RDF statements more convenient,
    this interface inherits from XResource.
    </p>
 
    @since OOo 3.0
 
    @see XRepository
 */
//FIXME: inherit from XResource ??? we can call createMapping, or just use the XmlId...
interface XMetadatable : XResource
{
    //-------------------------------------------------------------------------
    /** an XML ID, comprising the stream name and the xml:id attribute.
 
        <p>
        Note that this ID must be unique for the ODF document.
        This implies that the xml:id part must be unique for every stream.
        The ID may be omitted, in which case the value is the empty string.
        For Example: "content.xml#foo-element-1"
        </p>
     */
    [attribute] string XmlId {
        set raises ( com::sun::star::lang::IllegalArgumentException );
    };
};
 
 
//=============================================================================
/** misc stuff related to manifest.rdf.
 
    <p>
    This interface contains some methods that create connections between
    the content and the RDF metadata of an ODF document.
    The main idea is to make querying and manipulating the
    data in the metadata manifest easier.
    Among other things, the metadata manifest contains a mapping between ODF
    elements (in the content.xml and styles.xml streams) and URIs.
    Such a mapping works by associating the XML ID of the ODF element with
    the URI by an RDF statement of the form:
    <code>URI pkg:idref XmlId.</code>
    </p>
 
    <p>
    Note that this interface inherits from <type>XResource</type>: the
    UUID of the package is the string value of the RDF node.
    This is so that you can easily make RDF statements about the package.
    </p>
 
    @since OOo 3.0
 
    @see XRepository
 */
 // This is supposed to be implemented by the _document_, not the repository
// FIXME: how to name this?
// XDocumentMetadataAccess?
// XDocumentRDF?
// XDocumentRepositoryIntegration?
// XDocumentManifest?
// XPackageMetadata?
// any other permutation?
//interface XManifestAccess : XResource
interface XDocumentMetadataAccess : XURI
{
    //-------------------------------------------------------------------------
    /** get the UUID for the ODF package.
 
        @returns
            a universally unique ID that identifies this ODF package
     */
    string getPackageUUID();
 
    //-------------------------------------------------------------------------
    /** get the unique ODF element with the given XML ID.
 
        @param XmlId
            an XML ID, comprising the stream name and the xml:id attribute.
            For example: "content.xml#foo-element-1"
 
        @returns
            the ODF element with the given XML ID if it exists, else <NULL/>
     */
    XMetadatable getElementByXmlId([in] string XmlId);
 
    //-------------------------------------------------------------------------
    /** get the ODF element that corresponds to an URI.
 
        <p>
        Convenience method that uses the mapping established in the
        manifest.rdf to locate the ODF element corresponding to an URI.
        </p>
 
        @param URI
            an URI that may identify an ODF element
 
        @returns
            the ODF element that corresponds to the given URI, or <NULL/>
     */
    XMetadatable getElementByURI([in] string URI);
 
    //-------------------------------------------------------------------------
    /** create an URI for an ODF element.
 
        <p>
        Convenience method that generates an URI for the given ODF element,
        and inserts a mapping between the URI and the XML ID of the ODF element
        into the manifest.
        If the element does not have a XML ID yet, a new XML ID will be
        generated.
        If an URI for the element already exists, it will be returned.
        </p>
 
        @param Element
            the ODF element for which an URI should be created.
 
        @returns
            the URI associated with the element
     */
//    XURI createMapping(XMetadatable Element);
    XURI getOrCreateURIForElement([in] XMetadatable Element);
 
    //-------------------------------------------------------------------------
    /** establish mapping between an ODF Element and an URI in the manifest.
 
        <p>
        This method Convenience method that generates an URI for the given
        ODF element, and inserts a mapping between the URI and the XML ID
        of the ODF element into the manifest.
        If the element does not have a XML ID yet, a new XML ID will be
        generated.
        If there already exists an URI for the element, FIXME: throw or change mapping?
        </p>
 
        @param Element
            the ODF element for which an URI should be created
 
     */
   // this one uses parameter uri
//    void createMapping([in] XMetadatable Element, [in] XURI URI);
    void createMappingForElement([in] XMetadatable Element, [in] XURI URI);
 
    //-------------------------------------------------------------------------
    /** find the URI that is associated with an ODF element in the manifest.
 
        @param Element
            the ODF element for which the URI should be returned
 
        @returns
            the URI associated with the element, or <NULL/>
     */
    XURI getURIForElement([in] XMetadatable Element);
 
};
 
//=============================================================================
 
}; }; }; };
Personal tools