From: Rob V. <rv...@vd...> - 2010-07-31 10:03:19
|
Hi Jeen Yes there was a bug in the parser which is now fixed in SVN as of revision 857 and will be in the next release but the main problem is that much of your syntax is invalid and so actually gets ignored. For example if I run your webpage through the W3C validator I only get the following triples: <http://www.wurvoc.org/vocabularies/om-1.6/Kelvin_scale> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.wurvoc.org/vocabularies/om-1.6/Ratio_scale>. <http://www.wurvoc.org/vocabularies/om-1.6/Kelvin_scale> <http://www.w3.org/1999/xhtml/vocab#stylesheet> <http://www.wurvoc.org/css/wurvoc-vocabularies.css>. <http://www.wurvoc.org/vocabularies/om-1.6/Kelvin_scale> <http://creativecommons.org/ns#attributionURL> <http://www.wurvoc.org/>. <http://www.wurvoc.org/vocabularies/om-1.6/Kelvin_scale> <http://www.w3.org/2000/01/rdf-schema#isDefinedBy> <http://www.wurvoc.org/vocabularies/om-1.6/>. <http://www.wurvoc.org/vocabularies/om-1.6/Kelvin_scale> <http://www.w3.org/1999/xhtml/vocab#license> <http://creativecommons.org/licenses/by/3.0/nl/>. <http://www.wurvoc.org/vocabularies/om-1.6/Kelvin_scale> <http://www.w3.org/2000/01/rdf-schema#label> "Kelvin scale"@en. Also when you invoke it with the code you sent me you are feeding in a raw HTTP response stream so the Graph is not aware of it's Base URI so even the few legal triples in your syntax cannot be generated, you need to explicitly specify the Base Uri of the Graph like so before loading into it: g.BaseUri = new Uri("http://www.wurvoc.org/vocabularies/om-1.6/Kelvin_scale"); Alternatively you can add a <base href="http://www.wurvoc.org/vocabularies/om-1.6/Kelvin_scale" /> elememt to the <head> of your XHTML document. I found that other RDFa validators will only produce output similar to the above, my RDFa parser with the fix applied will produce a couple more of triples than that but they don't appear to be the URIs you are intending (comparing with the RDF/XML version) and are only generated as my parser in the latest SVN builds of dotNetRDF has RDFa 1.1 support so interprets some invalid RDFa 1.0 as valid RDFa 1.1 syntax In several places you have either used prefixes you haven't defined or you are using CURIEs without any prefix which appears to be the main issue with your RDFa. I'm not an expert in RDFa so I'd ask on the pub...@w3... mailing list for help with getting your syntax correct The alternative way to load RDF from the web is to use the UriLoader class so you don't have to explicitly state the parser to be used, only problem I noticed when trying this with your URL is that it gives back the RDF/XML instead because of the Accept header which the UriLoader will send. One final thing that might be of use to you is that you can attach an event handler to the Warning event of the parser so that you get warning messages about invalid CURIEs and URIs e.g. parser.Warning += new RdfReaderWarning(this.HandleError); Hope this helps Best Regards, Rob Vesse ---------------------------------------- From: "Broekstra, Jeen" <jee...@wu...> Sent: 30 July 2010 14:20 To: "dot...@li..." <dot...@li...> Subject: [dotNetRDF-develop] NullReferenceException in RdfaParser Hi there, I have just started trying out DotNetRDF, and sofar am very impressed. Great work! However, I have ran into a problem. I am trying to use the RdfaParser in a simple test project, but get a NullReferenceException: System.NullReferenceException was unhandled Message="Object reference not set to an instance of an object." Source="dotNetRDF" StackTrace: at VDS.RDF.Triple..ctor(INode subj, INode pred, INode obj) at VDS.RDF.Parsing.RdfAParser.ProcessElement(RdfAParserContext context, RdfAEvaluationContext evalContext, HtmlNode currElement) at VDS.RDF.Parsing.RdfAParser.ProcessElement(RdfAParserContext context, RdfAEvaluationContext evalContext, HtmlNode currElement) at VDS.RDF.Parsing.RdfAParser.ProcessElement(RdfAParserContext context, RdfAEvaluationContext evalContext, HtmlNode currElement) at VDS.RDF.Parsing.RdfAParser.ProcessElement(RdfAParserContext context, RdfAEvaluationContext evalContext, HtmlNode currElement) at VDS.RDF.Parsing.RdfAParser.ProcessElement(RdfAParserContext context, RdfAEvaluationContext evalContext, HtmlNode currElement) at VDS.RDF.Parsing.RdfAParser.ProcessElement(RdfAParserContext context, RdfAEvaluationContext evalContext, HtmlNode currElement) at VDS.RDF.Parsing.RdfAParser.ProcessElement(RdfAParserContext context, RdfAEvaluationContext evalContext, HtmlNode currElement) at VDS.RDF.Parsing.RdfAParser.ProcessElement(RdfAParserContext context, RdfAEvaluationContext evalContext, HtmlNode currElement) at VDS.RDF.Parsing.RdfAParser.ProcessElement(RdfAParserContext context, RdfAEvaluationContext evalContext, HtmlNode currElement) at VDS.RDF.Parsing.RdfAParser.Parse(RdfAParserContext context) at VDS.RDF.Parsing.RdfAParser.Load(IGraph g, StreamReader input) at DotNetRDFTest.Program.Main(String[] args) in D:\Documents\Visual Studio 2008\Projects\DotNetRDFTest\Program.cs:line 24 The code I am executing is quite simple: Graph g = new Graph(); RdfAParser parser = new RdfAParser(); StreamReader reader = new StreamReader(WebRequest.Create("http://www.wurvoc.org/vocabularies/om-1.6/Kelvin_scale").GetResponse().GetResponseStream()); parser.Load(g, reader); The exception occurs on the parser.Load. It may be that the RDFa document I am parsing contains syntax errors (I've generated it myself, but I'm still struggling a bit with the exact RDFa syntax). Regardless, it seems to me that the parser should handle unexpected content more gracefully than with a NRE :) Is this a bug in the parser, or am I doing something wrong in invoking it? Cheers, Jeen PS using DotNetRDF 0.2.2 alpha and .Net 3.5. Also included a ref to the HtmlAgilityPack. -- dr. J. Broekstra Wageningen UR, Food & Biobased Research Intelligent Systems group P.O. Box 17, 6700 AA Wageningen Wageningen Campus, Building 118, Bornse Weilanden 9, 6708 WG Wageningen Tel. +31 (0)317 480145 http://www.fbresearch.nl/InformationManagement ------------------------------------------------------------------------------ The Palm PDK Hot Apps Program offers developers who use the Plug-In Development Kit to bring their C/C++ apps to Palm for a share of $1 Million in cash or HP Products. Visit us here for more details: http://p.sf.net/sfu/dev2dev-palm _______________________________________________ Dotnetrdf-develop mailing list Dot...@li... https://lists.sourceforge.net/lists/listinfo/dotnetrdf-develop |