public SparqlAutoCompleter(SparqlQuerySyntax? syntax)
        {
            //Alter the Regex patterns
            this.PrefixRegexPattern = this.PrefixRegexPattern.Substring(1, this.PrefixRegexPattern.Length-6);
            this.BlankNodePattern = @"_:(\p{L}|\d)(\p{L}|\p{N}|-|_)*";

            //Add Prefix Definitions to Keywords
            this._keywords.AddRange(AutoCompleteManager.PrefixData);

            //If not Query Syntax don't add any Query Keywords
            if (syntax == null) return;

            //Add Keywords relevant to the Syntax
            this._syntax = (SparqlQuerySyntax)syntax;
            foreach (String keyword in SparqlSpecsHelper.SparqlQuery10Keywords)
            {
                this._keywords.Add(new KeywordCompletionData(keyword));
                this._keywords.Add(new KeywordCompletionData(keyword.ToLower()));
            }

            if (syntax != SparqlQuerySyntax.Sparql_1_0)
            {
                foreach (String keyword in SparqlSpecsHelper.SparqlQuery11Keywords)
                {
                    this._keywords.Add(new KeywordCompletionData(keyword));
                    this._keywords.Add(new KeywordCompletionData(keyword.ToLower()));
                }
            }

            //Sort the Keywords
            this._keywords.Sort();
        }
Exemple #2
0
 /// <summary>
 /// Creates a new Instance of the Tokeniser
 /// </summary>
 /// <param name="input">The Input Stream to generate Tokens from</param>
 /// <param name="syntax">Syntax Mode to use when parsing</param>
 public SparqlTokeniser(BlockingTextReader input, SparqlQuerySyntax syntax)
     : base(input)
 {
     this._in = input;
     this.Format = "SPARQL";
     this._syntax = syntax;
 }
 /// <summary>
 /// Creates a new SPARQL Query Parser Context for parsing sub-queries.
 /// </summary>
 /// <param name="parent">Parent Query Parser Context.</param>
 /// <param name="tokens">Tokens that need parsing to form a subquery.</param>
 protected internal SparqlQueryParserContext(SparqlQueryParserContext parent, ITokenQueue tokens)
     : base(new NullHandler(), null)
 {
     _traceParsing          = parent.TraceParsing;
     _traceTokeniser        = parent.TraceTokeniser;
     _queue                 = tokens;
     _subqueryMode          = true;
     _query                 = new SparqlQuery(true);
     _factories             = parent.ExpressionFactories;
     _syntax                = parent.SyntaxMode;
     _exprParser.SyntaxMode = _syntax;
 }
Exemple #4
0
        /// <summary>
        /// Creates a new auto-complete for the specific SPARQL syntax
        /// </summary>
        /// <param name="editor">Text Editor</param>
        /// <param name="syntax">SPARQL Syntax</param>
        public SparqlAutoCompleter(ITextEditorAdaptor <T> editor, SparqlQuerySyntax?syntax)
            : base(editor)
        {
            //Alter the Regex patterns
            this.PrefixRegexPattern = this.PrefixRegexPattern.Substring(1, this.PrefixRegexPattern.Length - 6);
            this.BlankNodePattern   = @"_:(\p{L}|\d)(\p{L}|\p{N}|-|_)*";

            //Add Prefix Definitions to Keywords
            this._keywords.Add(new SparqlStyleBaseDeclarationData());
            this._keywords.Add(new SparqlStyleDefaultPrefixDeclarationData());
            foreach (VocabularyDefinition vocab in AutoCompleteManager.Vocabularies)
            {
                this._keywords.Add(new SparqlStylePrefixDeclarationData(vocab.Prefix, vocab.NamespaceUri));
            }

            //If not Query Syntax don't add any Query Keywords
            if (syntax == null)
            {
                return;
            }

            //Add Keywords relevant to the Syntax
            this._syntax = (SparqlQuerySyntax)syntax;
            foreach (String keyword in SparqlSpecsHelper.SparqlQuery10Keywords)
            {
                this._keywords.Add(new KeywordData(keyword));
                this._keywords.Add(new KeywordData(keyword.ToLower()));
            }

            if (syntax != SparqlQuerySyntax.Sparql_1_0)
            {
                foreach (String keyword in SparqlSpecsHelper.SparqlQuery11Keywords)
                {
                    this._keywords.Add(new KeywordData(keyword));
                    this._keywords.Add(new KeywordData(keyword.ToLower()));
                }
            }

            //Sort the Keywords
            this._keywords.Sort();
        }
        /// <summary>
        /// Creates a new Query Handler Configuration
        /// </summary>
        /// <param name="context">HTTP Context</param>
        /// <param name="g">Configuration Graph</param>
        /// <param name="objNode">Object Node</param>
        public BaseQueryHandlerConfiguration(HttpContext context, IGraph g, INode objNode)
            : base(context, g, objNode)
        {
            //Get the Query Processor to be used
            ISparqlQueryProcessor processor;
            INode procNode = ConfigurationLoader.GetConfigurationNode(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyQueryProcessor));
            if (procNode == null) throw new DotNetRdfConfigurationException("Unable to load Query Handler Configuration as the RDF configuration file does not specify a dnr:queryProcessor property for the Handler");
            Object temp = ConfigurationLoader.LoadObject(g, procNode);
            if (temp is ISparqlQueryProcessor)
            {
                processor = (ISparqlQueryProcessor)temp;
            }
            else
            {
                throw new DotNetRdfConfigurationException("Unable to load Query Handler Configuration as the RDF configuration file specifies a value for the Handlers dnr:updateProcessor property which cannot be loaded as an object which implements the ISparqlQueryProcessor interface");
            }
            this._processor = processor;

            //SPARQL Query Default Config
            this._defaultGraph = ConfigurationLoader.GetConfigurationValue(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyDefaultGraphUri)).ToSafeString();
            this._defaultTimeout = ConfigurationLoader.GetConfigurationInt64(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyTimeout), this._defaultTimeout);
            this._defaultPartialResults = ConfigurationLoader.GetConfigurationBoolean(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyPartialResults), this._defaultPartialResults);

            //Handler Configuration
            this._showQueryForm = ConfigurationLoader.GetConfigurationBoolean(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyShowQueryForm), this._showQueryForm);
            String defQueryFile = ConfigurationLoader.GetConfigurationString(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyDefaultQueryFile));
            if (defQueryFile != null)
            {
                defQueryFile = ConfigurationLoader.ResolvePath(defQueryFile);
                if (File.Exists(defQueryFile))
                {
                    using (StreamReader reader = new StreamReader(defQueryFile))
                    {
                        this._defaultQuery = reader.ReadToEnd();
                        reader.Close();
                    }
                }
            }

            //Get Query Syntax to use
            try
            {
                String syntaxSetting = ConfigurationLoader.GetConfigurationString(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertySyntax));
                if (syntaxSetting != null)
                {
                    this._syntax = (SparqlQuerySyntax)Enum.Parse(typeof(SparqlQuerySyntax), syntaxSetting);
                }
            }
            catch (Exception ex)
            {
                throw new DotNetRdfConfigurationException("Unable to set the Syntax for the HTTP Handler identified by the Node '" + objNode.ToString() + "' as the value given for the dnr:syntax property was not a valid value from the enum VDS.RDF.Parsing.SparqlQuerySyntax", ex);
            }

            //Get the SPARQL Describe Algorithm
            INode describeNode = ConfigurationLoader.GetConfigurationNode(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyDescribeAlgorithm));
            if (describeNode != null)
            {
                if (describeNode.NodeType == NodeType.Literal)
                {
                    String algoClass = ((ILiteralNode)describeNode).Value;
                    try
                    {
                        Object desc = Activator.CreateInstance(Type.GetType(algoClass));
                        if (desc is ISparqlDescribe)
                        {
                            this._describer = (ISparqlDescribe)desc;
                        }
                        else
                        {
                            throw new DotNetRdfConfigurationException("Unable to set the Describe Algorithm for the HTTP Handler identified by the Node '" + objNode.ToString() + "' as the value given for the dnr:describeAlgorithm property was not a type name of a type that implements the ISparqlDescribe interface");
                        }
                    }
                    catch (DotNetRdfConfigurationException)
                    {
                            throw;
                    }
                    catch (Exception ex)
                    {
                        throw new DotNetRdfConfigurationException("Unable to set the Describe Algorithm for the HTTP Handler identified by the Node '" + objNode.ToString() + "' as the value given for the dnr:describeAlgorithm property was not a type name for a type that can be instantiated", ex);
                    }
                }
            }

            //Get the Service Description Graph
            INode descripNode = ConfigurationLoader.GetConfigurationNode(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyServiceDescription));
            if (descripNode != null)
            {
                Object descrip = ConfigurationLoader.LoadObject(g, descripNode);
                if (descrip is IGraph)
                {
                    this._serviceDescription = (IGraph)descrip;
                }
                else
                {
                    throw new DotNetRdfConfigurationException("Unable to set the Service Description Graph for the HTTP Handler identified by the Node '" + objNode.ToString() + "' as the value given for the dnr:serviceDescription property points to an Object which could not be loaded as an object which implements the required IGraph interface");
                }
            }

            //Get the Query Optimiser
            INode queryOptNode = ConfigurationLoader.GetConfigurationNode(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyQueryOptimiser));
            if (queryOptNode != null)
            {
                Object queryOpt = ConfigurationLoader.LoadObject(g, queryOptNode);
                if (queryOpt is IQueryOptimiser)
                {
                    this._queryOptimiser = (IQueryOptimiser)queryOpt;
                }
                else
                {
                    throw new DotNetRdfConfigurationException("Unable to set the Query Optimiser for the HTTP Handler identified by the Node '" + queryOptNode.ToString() + "' as the value given for the dnr:queryOptimiser property points to an Object which could not be loaded as an object which implements the required IQueryOptimiser interface");
                }
            }

            //Get the Algebra Optimisers
            foreach (INode algOptNode in ConfigurationLoader.GetConfigurationData(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyAlgebraOptimiser)))
            {
                Object algOpt = ConfigurationLoader.LoadObject(g, algOptNode);
                if (algOpt is IAlgebraOptimiser)
                {
                    this._algebraOptimisers.Add((IAlgebraOptimiser)algOpt);
                }
                else
                {
                    throw new DotNetRdfConfigurationException("Unable to set the Algebra Optimiser for the HTTP Handler identified by the Node '" + algOptNode.ToString() + "' as the value given for the dnr:algebraOptimiser property points to an Object which could not be loaded as an object which implements the required IAlgebraOptimiser interface");
                }
            }
        }
Exemple #6
0
 /// <summary>
 /// Creates a new SPARQL Query Validator using the given Syntax
 /// </summary>
 /// <param name="syntax">Query Syntax</param>
 public SparqlQueryValidator(SparqlQuerySyntax syntax)
 {
     _parser = new SparqlQueryParser(syntax);
 }
 /// <summary>
 /// Creates a new Instance of the Tokeniser
 /// </summary>
 /// <param name="input">The Input Stream to generate Tokens from</param>
 /// <param name="syntax">Syntax Mode to use when parsing</param>
 public SparqlTokeniser(StreamReader input, SparqlQuerySyntax syntax)
     : this(new BlockingTextReader(input), syntax) { }
 /// <summary>
 /// Creates a new SPARQL Query Parser Context for parsing sub-queries
 /// </summary>
 /// <param name="parent">Parent Query Parser Context</param>
 /// <param name="tokens">Tokens that need parsing to form a subquery</param>
 protected internal SparqlQueryParserContext(SparqlQueryParserContext parent, ITokenQueue tokens)
     : base(new NullHandler(), null)
 {
     this._traceParsing = parent.TraceParsing;
     this._traceTokeniser = parent.TraceTokeniser;
     this._queue = tokens;
     this._subqueryMode = true;
     this._query = new SparqlQuery(true);
     this._factories = parent.ExpressionFactories;
     this._syntax = parent.SyntaxMode;
     this._exprParser.SyntaxMode = this._syntax;
 }
Exemple #9
0
        /// <summary>
        /// Checks whether a given QName is valid in Sparql
        /// </summary>
        /// <param name="value">QName to check</param>
        /// <param name="syntax">SPARQL Syntax</param>
        /// <returns></returns>
        public static bool IsValidQName(String value, SparqlQuerySyntax syntax)
        {
            if (!value.Contains(':'))
            {
                //Must have a Colon in a QName
                return false;
            }
            else if (value.StartsWith(":"))
            {
                //No need to validate QName
                //Just validation Local Name
                char[] cs = value.ToCharArray(1, value.Length - 1);

                return IsPNLocal(cs, syntax);
            }
            else
            {
                //Split into Prefix and Local Name
                char[] prefix = value.ToCharArray(0, value.IndexOf(':'));
                char[] local = value.ToCharArray(value.IndexOf(':') + 1, value.Length - value.IndexOf(':')-1);

                return (IsPNPrefix(prefix) && IsPNLocal(local, syntax));
            }
        }
Exemple #10
0
        /// <summary>
        /// Checks whether a given String matches the PN_LOCAL rule from the Sparql Specification
        /// </summary>
        /// <param name="cs">String as character array</param>
        /// <param name="syntax">SPARQL Syntax</param>
        /// <returns></returns>
        public static bool IsPNLocal(char[] cs, SparqlQuerySyntax syntax)
        {
            if (cs.Length == 0)
            {
                //Empty Local Names are valid
                return true;
            }

            //First character must be a digit or from PN_CHARS_U
            char first = cs[0];
            int start = 0;
            if (Char.IsDigit(first) || IsPNCharsU(first) ||
                (syntax != SparqlQuerySyntax.Sparql_1_0 && IsPLX(cs, 0, out start)))
            {
                if (start > 0)
                {
                    //Means the first thing was a PLX
                    //If the only thing in the local name was a PLX this is valid
                    if (start == cs.Length - 1) return true;
                    //If there are further characters we'll start
                }
                else
                {
                    //Otherwise we need to check the rest of the characters
                    start = 1;
                }

                //Check the rest of the characters
                if (cs.Length > start)
                {
                    for (int i = start; i < cs.Length; i++)
                    {
                        if (i < cs.Length - 1)
                        {
                            //Middle characters may be from PN_CHARS or '.'
                            int j = i;
                            if (!(cs[i] == '.' || IsPNChars(cs[i]) ||
                                  (syntax != SparqlQuerySyntax.Sparql_1_0 && IsPLX(cs, i, out j))
                                ))
                            {
                                return false;
                            }
                            if (i != j)
                            {
                                //This means we just saw a PLX
                                //Last thing being a PLX is valid
                                if (j == cs.Length - 1) return true;
                                //Otherwise adjust the index appropriately and continue checking further characters
                                i = j;
                            }
                        }
                        else
                        {
                            //Last Character must be from PN_CHARS if it wasn't a PLX which is handled elsewhere
                            return IsPNChars(cs[i]);
                        }
                    }

                    //Should never get here but have to add this to keep compiler happy
                    throw new RdfParseException("Local Name validation error in SparqlSpecsHelper.IsPNLocal(char[] cs)");
                }
                else
                {
                    return true;
                }
            }
            else
            {
                return false;
            }
        }
 /// <summary>
 /// Creates a new SPARQL Query Validator using the given Syntax
 /// </summary>
 /// <param name="syntax">Query Syntax</param>
 public SparqlQueryValidator(SparqlQuerySyntax syntax)
 {
     this._parser = new SparqlQueryParser(syntax);
 }
 public SparqlQueryPreprocessor(TextReader input, SparqlQuerySyntax syntax)
     : base(input, syntax)
 {
     QueryType = SparqlQueryType.Unknown;
 }
 /// <summary>
 /// Creates a new instance of the SPARQL Query Parser using the given Tokeniser which supports the given SPARQL Syntax
 /// </summary>
 /// <param name="queueMode">Token Queue Mode</param>
 /// <param name="syntax">SPARQL Syntax</param>
 public SparqlQueryParser(TokenQueueMode queueMode, SparqlQuerySyntax syntax)
 {
     this._queuemode = queueMode;
     this._syntax = syntax;
 }
 /// <summary>
 /// Creates a new instance of the SPARQL Query Parser which supports the given SPARQL Syntax
 /// </summary>
 /// <param name="syntax">SPARQL Syntax</param>
 public SparqlQueryParser(SparqlQuerySyntax syntax)
     : this(TokenQueueMode.QueueAllBeforeParsing, syntax) { }
Exemple #15
0
 /// <summary>
 /// Creates a new Instance of the Tokeniser
 /// </summary>
 /// <param name="input">The Input to generate Tokens from</param>
 /// <param name="syntax">Syntax Mode to use when parsing</param>
 public SparqlTokeniser(TextReader input, SparqlQuerySyntax syntax)
     : this(BlockingTextReader.Create(input), syntax)
 {
 }
Exemple #16
0
        /// <summary>
        /// Creates a new Base SPARQL Server Configuration based on information from a Configuration Graph
        /// </summary>
        /// <param name="context">HTTP Context</param>
        /// <param name="g">Configuration Graph</param>
        /// <param name="objNode">Object Node</param>
        public BaseSparqlServerConfiguration(HttpContext context, IGraph g, INode objNode)
            : base(context, g, objNode)
        {
            //Get the Query Processor to be used
            INode procNode = ConfigurationLoader.GetConfigurationNode(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyQueryProcessor));

            if (procNode != null)
            {
                Object temp = ConfigurationLoader.LoadObject(g, procNode);
                if (temp is ISparqlQueryProcessor)
                {
                    this._queryProcessor = (ISparqlQueryProcessor)temp;
                }
                else
                {
                    throw new DotNetRdfConfigurationException("Unable to load SPARQL Server Configuration as the RDF configuration file specifies a value for the Handlers dnr:queryProcessor property which cannot be loaded as an object which implements the ISparqlQueryProcessor interface");
                }
            }

            //SPARQL Query Default Config
            this._defaultGraph          = ConfigurationLoader.GetConfigurationValue(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyDefaultGraphUri)).ToSafeString();
            this._defaultTimeout        = ConfigurationLoader.GetConfigurationInt64(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyTimeout), this._defaultTimeout);
            this._defaultPartialResults = ConfigurationLoader.GetConfigurationBoolean(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyPartialResults), this._defaultPartialResults);

            //Handler Configuration
            this._showQueryForm = ConfigurationLoader.GetConfigurationBoolean(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyShowQueryForm), this._showQueryForm);
            String defQueryFile = ConfigurationLoader.GetConfigurationString(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyDefaultQueryFile));

            if (defQueryFile != null)
            {
                defQueryFile = ConfigurationLoader.ResolvePath(defQueryFile);
                if (File.Exists(defQueryFile))
                {
                    using (StreamReader reader = new StreamReader(defQueryFile))
                    {
                        this._defaultQuery = reader.ReadToEnd();
                        reader.Close();
                    }
                }
            }

            //Get Query Syntax to use
            try
            {
                String syntaxSetting = ConfigurationLoader.GetConfigurationString(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertySyntax));
                if (syntaxSetting != null)
                {
                    this._syntax = (SparqlQuerySyntax)Enum.Parse(typeof(SparqlQuerySyntax), syntaxSetting);
                }
            }
            catch (Exception ex)
            {
                throw new DotNetRdfConfigurationException("Unable to set the Syntax for the HTTP Handler identified by the Node '" + objNode.ToString() + "' as the value given for the dnr:syntax property was not a valid value from the enum VDS.RDF.Parsing.SparqlQuerySyntax", ex);
            }

            //Get the SPARQL Describe Algorithm
            INode describeNode = ConfigurationLoader.GetConfigurationNode(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyDescribeAlgorithm));

            if (describeNode != null)
            {
                if (describeNode.NodeType == NodeType.Literal)
                {
                    String algoClass = ((ILiteralNode)describeNode).Value;
                    try
                    {
                        Object desc = Activator.CreateInstance(Type.GetType(algoClass));
                        if (desc is ISparqlDescribe)
                        {
                            this._describer = (ISparqlDescribe)desc;
                        }
                        else
                        {
                            throw new DotNetRdfConfigurationException("Unable to set the Describe Algorithm for the HTTP Handler identified by the Node '" + objNode.ToString() + "' as the value given for the dnr:describeAlgorithm property was not a type name of a type that implements the ISparqlDescribe interface");
                        }
                    }
                    catch (DotNetRdfConfigurationException)
                    {
                        throw;
                    }
                    catch (Exception ex)
                    {
                        throw new DotNetRdfConfigurationException("Unable to set the Describe Algorithm for the HTTP Handler identified by the Node '" + objNode.ToString() + "' as the value given for the dnr:describeAlgorithm property was not a type name for a type that can be instantiated", ex);
                    }
                }
            }

            //Get the Query Optimiser
            INode queryOptNode = ConfigurationLoader.GetConfigurationNode(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyQueryOptimiser));

            if (queryOptNode != null)
            {
                Object queryOpt = ConfigurationLoader.LoadObject(g, queryOptNode);
                if (queryOpt is IQueryOptimiser)
                {
                    this._queryOptimiser = (IQueryOptimiser)queryOpt;
                }
                else
                {
                    throw new DotNetRdfConfigurationException("Unable to set the Query Optimiser for the HTTP Handler identified by the Node '" + queryOptNode.ToString() + "' as the value given for the dnr:queryOptimiser property points to an Object which could not be loaded as an object which implements the required IQueryOptimiser interface");
                }
            }

            //Get the Algebra Optimisers
            foreach (INode algOptNode in ConfigurationLoader.GetConfigurationData(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyAlgebraOptimiser)))
            {
                Object algOpt = ConfigurationLoader.LoadObject(g, algOptNode);
                if (algOpt is IAlgebraOptimiser)
                {
                    this._algebraOptimisers.Add((IAlgebraOptimiser)algOpt);
                }
                else
                {
                    throw new DotNetRdfConfigurationException("Unable to set the Algebra Optimiser for the HTTP Handler identified by the Node '" + algOptNode.ToString() + "' as the value given for the dnr:algebraOptimiser property points to an Object which could not be loaded as an object which implements the required IAlgebraOptimiser interface");
                }
            }

            //Then get the Update Processor to be used
            procNode = ConfigurationLoader.GetConfigurationNode(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyUpdateProcessor));
            if (procNode != null)
            {
                Object temp = ConfigurationLoader.LoadObject(g, procNode);
                if (temp is ISparqlUpdateProcessor)
                {
                    this._updateProcessor = (ISparqlUpdateProcessor)temp;
                }
                else
                {
                    throw new DotNetRdfConfigurationException("Unable to load SPARQL Server Configuration as the RDF configuration file specifies a value for the Handlers dnr:updateProcessor property which cannot be loaded as an object which implements the ISparqlUpdateProcessor interface");
                }
            }

            //Handler Settings
            this._showUpdateForm = ConfigurationLoader.GetConfigurationBoolean(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyShowUpdateForm), this._showUpdateForm);
            String defUpdateFile = ConfigurationLoader.GetConfigurationString(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyDefaultUpdateFile));

            if (defUpdateFile != null)
            {
                defUpdateFile = ConfigurationLoader.ResolvePath(defUpdateFile);
                if (File.Exists(defUpdateFile))
                {
                    using (StreamReader reader = new StreamReader(defUpdateFile))
                    {
                        this._defaultUpdate = reader.ReadToEnd();
                        reader.Close();
                    }
                }
            }

            //Then get the Protocol Processor to be used
            procNode = ConfigurationLoader.GetConfigurationNode(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyProtocolProcessor));
            if (procNode != null)
            {
                Object temp = ConfigurationLoader.LoadObject(g, procNode);
                if (temp is ISparqlHttpProtocolProcessor)
                {
                    this._protocolProcessor = (ISparqlHttpProtocolProcessor)temp;
                }
                else
                {
                    throw new DotNetRdfConfigurationException("Unable to load SPARQL Server Configuration as the RDF configuration file specifies a value for the Handlers dnr:protocolProcessor property which cannot be loaded as an object which implements the ISparqlHttpProtocolProcessor interface");
                }
            }

            if (this._queryProcessor == null && this._updateProcessor == null && this._protocolProcessor == null)
            {
                throw new DotNetRdfConfigurationException("Unable to load SPARQL Server Configuration as the RDF configuration file does not specify at least one of a Query/Update/Protocol processor for the server using the dnr:queryProcessor/dnr:updateProcessor/dnr:protocolProcessor properties");
            }

            //Get the Service Description Graph
            INode descripNode = ConfigurationLoader.GetConfigurationNode(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyServiceDescription));

            if (descripNode != null)
            {
                Object descrip = ConfigurationLoader.LoadObject(g, descripNode);
                if (descrip is IGraph)
                {
                    this._serviceDescription = (IGraph)descrip;
                }
                else
                {
                    throw new DotNetRdfConfigurationException("Unable to set the Service Description Graph for the HTTP Handler identified by the Node '" + objNode.ToString() + "' as the value given for the dnr:serviceDescription property points to an Object which could not be loaded as an object which implements the required IGraph interface");
                }
            }
        }
Exemple #17
0
 /// <summary>
 /// Creates a new instance of the <c>SparqlPreprocessor</c> class.
 /// </summary>
 /// <param name="input">A text reader.</param>
 /// <param name="syntax">SPARQL syntax level.</param>
 public SparqlPreprocessor(TextReader input, SparqlQuerySyntax syntax) :
     base(input, syntax)
 {
 }