Click or drag to resize

StringParserParse Method (IGraph, String)

Parses a raw RDF String (attempts to auto-detect the format).

Namespace:  VDS.RDF.Parsing
Assembly:  dotNetRDF (in dotNetRDF.dll) Version:
Syntax
public static void Parse(
	IGraph g,
	string data
)

Parameters

g
Type: VDS.RDFIGraph
Graph to load into.
data
Type: SystemString
Raw RDF String.
Remarks

Auto-detection is based on testing the string to see if it contains certain keyword constructs which might indicate a particular syntax has been used. This detection may not always be accurate and it may choose a parser which is less expressive than the actual syntax e.g. TurtleParser instead of Notation3Parser as it tends to guess downwards.

For example if you parsed a Notation 3 string that contained Graph Literals but didn't use any of the Notation 3 specific directives like @keywords it would be assumed to be Turtle but then would fail to parse

The auto-detection rules used are as follows:

  1. If it contains <?xml and <rdf:RDF then it's most likely RDF/XML
  2. If it contains <html then it's most likely HTML with possibly RDFa embedded
  3. If it contains @prefix or @base then its Turtle/Notation 3
    1. If it contains @keywords, @forall or @forsome then it's Notation 3
    2. Otherwise it's Turtle
  4. If it contains all of a set of terms and symbols that occur in RDF/JSON then it's most likely RDF/JSON. These terms are "value","type",{,},[ and ]
  5. Otherwise try it as NTriples, NTriples has no real distinctive syntax so hard to test if it's NTriples other than by parsing it
See Also