You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by "Andy Seaborne (JIRA)" <ji...@apache.org> on 2014/11/21 16:35:34 UTC

[jira] [Created] (JENA-815) RDF XML Literals

Andy Seaborne created JENA-815:
----------------------------------

             Summary: RDF XML Literals
                 Key: JENA-815
                 URL: https://issues.apache.org/jira/browse/JENA-815
             Project: Apache Jena
          Issue Type: Improvement
          Components: RDF API, RDF/XML
    Affects Versions: Jena 2.12.1
            Reporter: Andy Seaborne


As part of Jena3, we can (re)consider the support for RDF XML literals.

h3. Context

In Jena2 (and RDF 1.0) they are special (it is the required datatype).
This is lessen in RDF 1.1.

There is support for RDF XML Literals through the "well formedness"
flag carried around by literals is their {{LiteralLabel}}.  It records whether
the literal is asserting it is valid exclusive canonical XML (i.e. valid RDF XML Literal by RDF 1.0 rules).

The flag is only relevant for RDF/XML output.

In the RDF API I found:

{noformat}
   Statement.hasWellFormedXML
   Literal.isWellFormedXML
   Model.add(s, p, o, flag)
   Model.createLiteral
{noformat}


Except for tests, {{Literal.isWellFormedXML}} is only called from
the RDF/XML writer (class Unparser) and {{Statement.hasWellFormedXML}} isn't called at all.

The flag effects whether the RDF/XML writer includes the literal as
{{parseType='literal'}} and inlines the XML, so you get nicely nested structures, or whether it used {{datatype=rdf:XMLLIteral}} and writes
the lexical form encoded.

The flag is set when a literal is created (see {{LiteralLabel.setValue}}).

h3. Possible changes

h4. Leave as-is.

h4. Remove from RDF API, retain in Node.

# Deprecate for Jena2 the RDF API operations exposing the well-formedness flag.
# The {{Unparser}} needs to unwrap the node from the literal and test the "XML directly" flag.

h4. Remove RDF XML Literals as specially handled in Node.

# Deprecate for Jena2 the RDF API operations exposing the well-formedness flag.
# At Jena3, remove the well-formed ness flag in Node
# The {{Unparser}} needs to test a literal before output.
# Don't set/test in {{LiteralLabel.setValue}}.

This is cleaner architecturally, but at the expense of parsing at output.

*Note*

There is a whole, separate discussion about whether {{Node}} 
ought to be value-supporting or not (i.e. moved to the RDF API).  
It should at least be delayed until needed to avoid overhead.

h3. Examples

Input (TTL): Legal RDF/XML Literal:
{noformat}
:x :property "<a></a>"^^rdf:XMLLiteral .
{noformat}
Output:
{noformat}
  <rdf:Description rdf:about="http://example/x">
    <property rdf:parseType="Literal"><a></a></property>
  </rdf:Description>
{noformat}

Input (TTL): Illegal RDF/XML Literal:
{noformat}
:x :property "<a>"^^rdf:XMLLiteral .
{noformat}
Output:
{noformat}
<rdf:Description rdf:about="http://example/x">
    <property rdf:datatype="http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral"
    >&lt;a&gt;</property>
{noformat}




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)