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
)
Public Shared Sub Parse (
g As IGraph,
data As String
)
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:
- If it contains <?xml and <rdf:RDF then it's most likely RDF/XML
- If it contains <html then it's most likely HTML with possibly RDFa embedded
-
If it contains @prefix or @base then its Turtle/Notation 3
- If it contains @keywords, @forall or @forsome then it's Notation 3
- Otherwise it's Turtle
- 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 ]
- 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