Create the Parser object

The parser can be created directly from a known name such as rdfxml for the W3C Recommendation RDF/XML syntax:

  raptor_parser* rdf_parser;

  rdf_parser = raptor_new_parser(world, "rdfxml");

or the name can be discovered from an description as discussed in Querying Functionality

The parser can also be created by identifying the syntax by a URI, specifying the syntax by a MIME Type, providng an identifier for the content such as filename or URI string or giving some initial content bytes that can be used to guess. Using the raptor_new_parser_for_content() function, all of these can be given as optional parameters, using NULL or 0 for undefined parameters. The constructor will then use as much of this information as possible.

  raptor_parser* rdf_parser;

Create a parser that reads the MIME Type for RDF/XML application/rdf+xml

  rdf_parser = raptor_new_parser_for_content(world, NULL, "application/rdf+xml", NULL, 0, NULL);

Create a parser that can read a syntax identified by the URI for Turtle http://www.dajobe.org/2004/01/turtle/, which has no registered MIME Type at this date:

  syntax_uri = raptor_new_uri(world, "http://www.dajobe.org/2004/01/turtle/");

  rdf_parser = raptor_new_parser_for_content(world, syntax_uri, NULL, NULL, 0, NULL);

Create a parser that recognises the identifier foo.rss:

  rdf_parser = raptor_new_parser_for_content(world, NULL, NULL, NULL, 0, "foo.rss");

Create a parser that recognises the content in buffer:

  rdf_parser = raptor_new_parser_for_content(world, NULL, NULL, buffer, len, NULL);

Any of the constructor calls can return NULL if no matching parser could be found, or the construction failed in another way.



Navigation: Redland Home Page

Copyright 2000-2014 Dave Beckett