dotnetrdf

An exception is raised when parsing files containing rdf:parseType="Collection"


An exception is raised when parsing files containing rdf:parseType="Collection".

VDS.RDF.Parsing.RdfParseException: [Line 44 Column 22] Expected an ElementEvent but encountered a 'VDS.RDF.Parsing.Events.RdfXml.TextEvent'
Occurred in Grammar Production 'PropertyElement'
[Source XML]
新編 洋樂歌謠曲選集 第二輯

   at VDS.RDF.Parsing.RdfXmlParser.GrammarProductionPropertyElement(RdfXmlParserContext context, IEventQueue`1 eventlist, IRdfXmlEvent parent)
   at VDS.RDF.Parsing.RdfXmlParser.GrammarProductionPropertyElementList(RdfXmlParserContext context, IEventQueue`1 eventlist, IRdfXmlEvent parent)
   at VDS.RDF.Parsing.RdfXmlParser.GrammarProductionNodeElement(RdfXmlParserContext context, IEventQueue`1 eventlist)
   at VDS.RDF.Parsing.RdfXmlParser.GrammarProductionParseTypeCollectionPropertyElement(RdfXmlParserContext context, IEventQueue`1 eventlist, IRdfXmlEvent parent)
   at VDS.RDF.Parsing.RdfXmlParser.GrammarProductionPropertyElement(RdfXmlParserContext context, IEventQueue`1 eventlist, IRdfXmlEvent parent)
   at VDS.RDF.Parsing.RdfXmlParser.GrammarProductionPropertyElementList(RdfXmlParserContext context, IEventQueue`1 eventlist, IRdfXmlEvent parent)
   at VDS.RDF.Parsing.RdfXmlParser.GrammarProductionNodeElement(RdfXmlParserContext context, IEventQueue`1 eventlist)
   at VDS.RDF.Parsing.RdfXmlParser.GrammarProductionNodeElementList(RdfXmlParserContext context, IEventQueue`1 eventlist)
   at VDS.RDF.Parsing.RdfXmlParser.GrammarProductionRDF(RdfXmlParserContext context, ElementEvent element)
   at VDS.RDF.Parsing.RdfXmlParser.ProcessEventQueue(RdfXmlParserContext context)
   at VDS.RDF.Parsing.RdfXmlParser.Parse(RdfXmlParserContext context)
   at VDS.RDF.Parsing.RdfXmlParser.Load(IRdfHandler handler, TextReader input, IUriFactory uriFactory)
   at VDS.RDF.Parsing.FileLoader.Load(IGraph g, String filename, IRdfReader parser)

The method is called as follows.

var g = new Graph();
FileLoader.Load(g, filePath);

RDF/XML sections with parsing errors.

    <dcterms:tableOfContents rdf:parseType="Collection">
      <dcterms:title>新編 洋樂歌謠曲選集 第二輯</dcterms:title>
    </dcterms:tableOfContents>

Target File

(Click on 'Output Bibliographic Record' to select the DC-NDL (RDF) format for download)

No error if the literal is not included, such as <dcterms:title></dcterms:title>

Can the above formats be supported? I don't need to be able to retrieve data, I just need to ignore the target element and not exit with an exception.


Solution

  • The problem is in the input data. The rdf:parseType="Collection" attribute indicates that the content should be a collection of RDF nodes, but in the data there is only a literal property.

    You can check this against the W3C Validator Service which also reports a fairly similar error.