Show / Hide Table of Contents

Class StringParser

Static Helper Class which allows raw strings of RDF/SPARQL Results to be parsed directly.

Inheritance
System.Object
StringParser
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: VDS.RDF.Parsing
Assembly: dotNetRdf.dll
Syntax
public static class StringParser
Remarks

The API structure for dotNetRDF means that our IRdfReader classes which are our Parsers only have to support parsing from a file or a stream. For most applications this is fine but there may be occassions when you wish to parse a small fragment of RDF and you don't want to have to put it into a file before you can parse it.

Methods

| Improve this Doc View Source

GetDatasetParser(string)

Uses the format detection rules to determine the most likely RDF Dataset Parser.

Declaration
public static IStoreReader GetDatasetParser(string data)
Parameters
Type Name Description
string data

Raw RDF Dataset String.

Returns
Type Description
IStoreReader
Remarks

The API structure for dotNetRDF means that our IRdfReader classes which are our Parsers only have to support parsing from a file or a stream. For most applications this is fine but there may be occassions when you wish to parse a small fragment of RDF and you don't want to have to put it into a file before you can parse it.

| Improve this Doc View Source

GetParser(string)

Uses the rules described in the remarks for the Parse() to return the most likely Parser.

Declaration
public static IRdfReader GetParser(string data)
Parameters
Type Name Description
string data

Raw RDF String.

Returns
Type Description
IRdfReader
Remarks

The API structure for dotNetRDF means that our IRdfReader classes which are our Parsers only have to support parsing from a file or a stream. For most applications this is fine but there may be occassions when you wish to parse a small fragment of RDF and you don't want to have to put it into a file before you can parse it.

| Improve this Doc View Source

GetResultSetParser(string)

Uses the format detection rules to return the most likely SPARQL Results parser.

Declaration
public static ISparqlResultsReader GetResultSetParser(string data)
Parameters
Type Name Description
string data

Raw SPARQL Results String.

Returns
Type Description
ISparqlResultsReader
Remarks

The API structure for dotNetRDF means that our IRdfReader classes which are our Parsers only have to support parsing from a file or a stream. For most applications this is fine but there may be occassions when you wish to parse a small fragment of RDF and you don't want to have to put it into a file before you can parse it.

| Improve this Doc View Source

Parse(IGraph, string, IRdfReader)

Parses a raw RDF String using the given IRdfReader.

Declaration
public static void Parse(IGraph g, string data, IRdfReader reader)
Parameters
Type Name Description
IGraph g

Graph to load into.

string data

Raw RDF String.

IRdfReader reader

Parser to use to read the data.

Remarks

Use this when you have a raw RDF string and you know the syntax the RDF is in.

| Improve this Doc View Source

Parse(IGraph, string)

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

Declaration
public static void Parse(IGraph g, string data)
Parameters
Type Name Description
IGraph g

Graph to load into.

string data

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
| Improve this Doc View Source

ParseDataset(ITripleStore, string, IStoreReader)

Parses a raw RDF Dataset String using the given Parser.

Declaration
public static void ParseDataset(ITripleStore store, string data, IStoreReader reader)
Parameters
Type Name Description
ITripleStore store

Store to load into.

string data

Raw RDF Dataset String.

IStoreReader reader

Parser to use.

Remarks

The API structure for dotNetRDF means that our IRdfReader classes which are our Parsers only have to support parsing from a file or a stream. For most applications this is fine but there may be occassions when you wish to parse a small fragment of RDF and you don't want to have to put it into a file before you can parse it.

| Improve this Doc View Source

ParseDataset(ITripleStore, string)

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

Declaration
public static void ParseDataset(ITripleStore store, string data)
Parameters
Type Name Description
ITripleStore store

Store to load into.

string data

Raw RDF Dataset 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.

| Improve this Doc View Source

ParseResultSet(SparqlResultSet, string, ISparqlResultsReader)

Parses a raw SPARQL Results String using the given Parser.

Declaration
public static void ParseResultSet(SparqlResultSet results, string data, ISparqlResultsReader reader)
Parameters
Type Name Description
SparqlResultSet results

SPARQL Result Set to fill.

string data

Raw SPARQL Results String.

ISparqlResultsReader reader

Parser to use.

Remarks

The API structure for dotNetRDF means that our IRdfReader classes which are our Parsers only have to support parsing from a file or a stream. For most applications this is fine but there may be occassions when you wish to parse a small fragment of RDF and you don't want to have to put it into a file before you can parse it.

| Improve this Doc View Source

ParseResultSet(SparqlResultSet, string)

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

Declaration
public static void ParseResultSet(SparqlResultSet results, string data)
Parameters
Type Name Description
SparqlResultSet results

SPARQL Result Set to fill.

string data

Raw SPARQL Results 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.

  • Improve this Doc
  • View Source
In This Article
  • Methods
    • GetDatasetParser(string)
    • GetParser(string)
    • GetResultSetParser(string)
    • Parse(IGraph, string, IRdfReader)
    • Parse(IGraph, string)
    • ParseDataset(ITripleStore, string, IStoreReader)
    • ParseDataset(ITripleStore, string)
    • ParseResultSet(SparqlResultSet, string, ISparqlResultsReader)
    • ParseResultSet(SparqlResultSet, string)
Back to top Generated by DocFX