openRDF.org Welcome Guest   | Login   
  Search  
  Index  | Recent Threads  | Who's Online  | User List  | Search  | Help  | RSS feeds

Forum has been closed down
This forum has been closed down due to extensive spamming activities. Please use the mailing list instead.


Quick Go »
Thread Status: Normal
Total posts in this thread: 7
[Add To My Favorites] [Watch this Thread]
Author
Previous Thread This topic has been viewed 10416 times and has 6 replies Next Thread
Mar 31, 2005 6:25:36 PM

yonasj
Regular
Member's Avatar

Canada
Joined: Dec 20, 2004
Posts: 38
Status: Offline
XML/RDF parsing bug with empty literals.

Hello,

I have found a bug in the RDF parsing. Here is a sample file that triggers the bug.



<?xml version="1.0"?>
<rdf:RDF
xmlns="http://www.maketechnologies.com/BREW/UseCase#"
xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:j.0="http://protege.stanford.edu/plugins/owl/protege#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:xsa="http://www.maketechnologies.com/BREW/XSA.owl#"
xmlns:cpas="http://brew/Domain-CPAS#"
xmlns:daml="http://www.daml.org/2001/03/daml+oil#"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:his="http://brew/Domain-HIS#"
xml:base="http://www.maketechnologies.com/BREW/UseCase">

<xsa:StepList rdf:ID="RoyalState_Individual_810">
<xsa:Step_step_number rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
></xsa:Step_step_number>
<xsa:Step_step_number rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
>Correct</xsa:Step_step_number>
</xsa:StepList>

</rdf:RDF>


After loading this RDF into a memory repositroy using Sesame 1.1.2 an incorrect statement is created.

The correct statement is:

RoyalState_Individual_810 Step_step_number "Correct"^^http://www.w3.org/2001/XMLSchema#string

The incorrect statement is:
RoyalState_Individual_810 Step_step_number _:node0

Here a BNode is being created.

The BNode has one statement about it. That statement is:

_:node0 rdf:type http://www.w3.org/2001/XMLSchema#string

I beleive that the correct behaviour would be to create a statement where the value is a 0 length string...

Yonas.
Show Printable Version of Post        http://www.yonasland.com [Link] Report threatening or abusive post: please login first  Go to top 
Mar 31, 2005 7:15:11 PM

yonasj
Regular
Member's Avatar

Canada
Joined: Dec 20, 2004
Posts: 38
Status: Offline
Re: XML/RDF parsing bug with empty literals.

BTW: You will need to disable validation.
Show Printable Version of Post        http://www.yonasland.com [Link] Report threatening or abusive post: please login first  Go to top 
Apr 1, 2005 9:05:42 AM

arjohn
OpenRDF project lead
Member's Avatar

The Netherlands
Joined: Jan 23, 2004
Posts: 1289
Status: Offline
Re: XML/RDF parsing bug with empty literals.

The W3C RDF Validation Service accepts this data as legal RDF. I'll look into it.
----------------------------------------
Arjohn Kampman, OpenRDF project lead, Aduna
Show Printable Version of Post        Hidden to Guest [Link] Report threatening or abusive post: please login first  Go to top 
Apr 1, 2005 2:02:16 PM

arjohn
OpenRDF project lead
Member's Avatar

The Netherlands
Joined: Jan 23, 2004
Posts: 1289
Status: Offline
Re: XML/RDF parsing bug with empty literals.

It looks like Sesame's parser is right according to a spec, but I find this very strange. Probably, this is an error in the RDF/XML specification. I'll contact the editors of the spec to find out what is the right thing to do.
----------------------------------------
Arjohn Kampman, OpenRDF project lead, Aduna
Show Printable Version of Post        Hidden to Guest [Link] Report threatening or abusive post: please login first  Go to top 
Apr 4, 2005 10:11:21 PM

uSeRNaMe
Visitor



Joined: Dec 23, 2004
Posts: 2
Status: Offline

Re: XML/RDF parsing bug with empty literals.

I have experienced this problem as well; it seems that Protege produces RDF like yonasj has posted.

I've modified the RdfXmlParser class to accomodate this:

private void _processPropertyElt(String namespaceURI, String localName, String qName, Atts atts, boolean isEmptyElt)
throws SAXException
{
...
// parseType == null
else if (isEmptyElt) {

Att datatype = atts.getAtt(RDF.NAMESPACE, "datatype");

// empty element without an rdf:parseType attribute
if (atts.size() == 0) {
// element had no attributes, or only the optional rdf:ID
NodeElement subject = (NodeElement)_peekStack(1);
Literal lit = _createLiteral("", _xmlLang, null);
_reportStatement(subject.getResource(), propURI, lit);
_handleReification(lit);
}
else if( atts.size() == 1 && datatype != null ){

NodeElement subject = (NodeElement)_peekStack(1);
Literal lit = _createLiteral("", _xmlLang, datatype.getValue());
_reportStatement(subject.getResource(), propURI, lit);
_handleReification(lit);
}

else {
...
}


I believe this fix is spec-compliant and solves this issue.

Please find the source attached in full.
----------------------------------------
Attachment RdfXmlParser.java (39344 bytes) (Download Count: 24) (RdfXmlParser.java - support for empty literals with rdf:datatype defined)

Show Printable Version of Post     [Link] Report threatening or abusive post: please login first  Go to top 
Apr 5, 2005 10:49:43 AM

arjohn
OpenRDF project lead
Member's Avatar

The Netherlands
Joined: Jan 23, 2004
Posts: 1289
Status: Offline
Re: XML/RDF parsing bug with empty literals.

Issue has been logged as [RIO-14]. Error in the specification has been reported on the www-rdf-comments mailing list: http://lists.w3.org/Archives/Public/www-rdf-comments/2005AprJun/0000.html
----------------------------------------
Arjohn Kampman, OpenRDF project lead, Aduna
Show Printable Version of Post        Hidden to Guest [Link] Report threatening or abusive post: please login first  Go to top 
Apr 5, 2005 1:44:03 PM

arjohn
OpenRDF project lead
Member's Avatar

The Netherlands
Joined: Jan 23, 2004
Posts: 1289
Status: Offline
Re: XML/RDF parsing bug with empty literals.

A fix for this issue is included in Sesame 1.1.3 and Rio 1.0.3, which have just been uploaded to sourceforge.net.

@uSeRNaMe: thanks for the code. I checked in a slightly modified version of the code to fix this issue.
----------------------------------------
Arjohn Kampman, OpenRDF project lead, Aduna
Show Printable Version of Post        Hidden to Guest [Link] Report threatening or abusive post: please login first  Go to top 
[Show Printable Version of Thread]