/// <summary>
        /// validates property element based on following syntax rules and create triples,
        /// <br/>
        /// start-element(URI == propertyElementURIs ),
        /// attributes == set(idAttr?, datatypeAttr?))
        /// text()
        /// end-element()
        /// </summary>
        /// <param name="outputGraph">Graph to add the generated triples.</param>
        internal override void Match(Graph outputGraph)
        {
            try
            {
                //Validate uri.
                ProductionPropertyElementUris propertyElementUris =
                    new ProductionPropertyElementUris(innerElement.Uri);
                propertyElementUris.Match(outputGraph);
            }
            catch (RdfXmlParserException ex)
            {
                throw new RdfXmlParserException(ex.ErrorMessageId, innerElement.LineInfo);
            }

            // Validate attributes.
            // attributes == set(idAttr?, datatypeAttr?))
            Collection <Production> set = new Collection <Production>();

            foreach (EventAttribute attribute in innerElement.Attributes)
            {
                Production production = GetProductionAttribute(attribute);
                if (production != null)
                {
                    set.Add(production);
                }
                else
                {
                    throw new RdfXmlParserException(
                              Constants.ErrorMessageIds.MsgLiteralPropertyElementIdOrDataTypeAttr,
                              innerElement.LineInfo);
                }
            }

            if (set.Where(tuple => tuple is ProductionIdAttribute).Count() > 1)
            {
                throw new RdfXmlParserException(Constants.ErrorMessageIds.MsgLiteralPropertyElementMoreThanOneIdAttr, innerElement.LineInfo);
            }

            if (set.Where(tuple => tuple is ProductionDataTypeAttribute).Count() > 1)
            {
                throw new RdfXmlParserException(Constants.ErrorMessageIds.MsgLiteralPropertyElementMoreThanOneDataTypeAttr, innerElement.LineInfo);
            }

            if (innerElement.Children.Count() > 0)
            {
                throw new RdfXmlParserException(Constants.ErrorMessageIds.MsgLiteralPropertyElementNoChildElements, innerElement.LineInfo);
            }

            foreach (Production attribute in set)
            {
                attribute.Match(outputGraph);
            }

            //Generate Triples.
            GenerateTriples(outputGraph);
        }
Esempio n. 2
0
        /// <summary>
        /// Validates property element based on following syntax rules and creates triples,
        /// <br/>
        /// start-element(URI == propertyElementURIs ),
        /// attributes == set(idAttr?, parseCollection))
        /// nodeElementList
        /// end-element()
        /// </summary>
        /// <param name="outputGraph">Graph to add the generated triples.</param>
        internal override void Match(Graph outputGraph)
        {
            try
            {
                //Validate uri.
                //start-element(URI == propertyElementURIs )
                ProductionPropertyElementUris propertyElementUris =
                    new ProductionPropertyElementUris(innerElement.Uri);
                propertyElementUris.Match(outputGraph);
            }
            catch (RdfXmlParserException ex)
            {
                throw new RdfXmlParserException(ex.ErrorMessageId, innerElement.LineInfo);
            }

            // Validate attributes.
            // attributes == set(idAttr?, parseCollection))
            Collection <Production> set = new Collection <Production>();

            foreach (EventAttribute attribute in innerElement.Attributes)
            {
                Production production = GetProductionAttribute(attribute);
                if (production != null)
                {
                    set.Add(production);
                }
                else
                {
                    throw new RdfXmlParserException(
                              Constants.ErrorMessageIds.MsgParseTypeCollectionPropertyElementNoOtherAttrs,
                              innerElement.LineInfo);
                }
            }
            if (set.Where(tuple => tuple is ProductionIdAttribute).Count() > 1)
            {
                throw new RdfXmlParserException(Constants.ErrorMessageIds.MsgParseTypeCollectionPropertyElementMoreThanOneIdAttr, innerElement.LineInfo);
            }
            if (set.Where(tuple => tuple is ProductionParseCollection).Count() != 1)
            {
                throw new RdfXmlParserException(Constants.ErrorMessageIds.MsgParseTypeCollectionPropertyElementSingleCollectionAttr, innerElement.LineInfo);
            }

            foreach (Production attribute in set)
            {
                attribute.Match(outputGraph);
            }

            ProductionNodeElementList nodeElementList = new ProductionNodeElementList(innerElement.Children);

            nodeElementList.Match(outputGraph);

            //Generate triples.
            GenerateTriples(outputGraph);
        }
        /// <summary>
        /// validates resource property element based on following syntax rules and creates triples,
        /// <br/>
        /// start-element(URI == propertyElementURIs ),
        /// attributes == set(idAttr?))
        /// ws* nodeElement ws*
        /// end-element()
        /// </summary>
        /// <param name="outputGraph">Graph to add the generated triples.</param>
        internal override void Match(Graph outputGraph)
        {
            try
            {
                //Validate uri.
                //start-element(URI == propertyElementURIs )
                ProductionPropertyElementUris propertyElementUris =
                    new ProductionPropertyElementUris(innerElement.Uri);
                propertyElementUris.Match(outputGraph);
            }
            catch (RdfXmlParserException ex)
            {
                throw new RdfXmlParserException(ex.ErrorMessageId, innerElement.LineInfo);
            }

            //Validate attributes.
            Collection <Production> idAttrSet = new Collection <Production>();

            foreach (EventAttribute attribute in innerElement.Attributes)
            {
                if (attribute.Uri == IDUri)
                {
                    idAttrSet.Add(new ProductionIdAttribute(attribute));
                }
                else
                {
                    throw new RdfXmlParserException(
                              Constants.ErrorMessageIds.MsgResourcePropertyElementNoOtherAttr,
                              innerElement.LineInfo);
                }
            }

            //attributes == set(idAttr?))
            if (idAttrSet.Count > 1)
            {
                throw new RdfXmlParserException(Constants.ErrorMessageIds.MsgResourcePropertyElementMoreThanOneIdAttr, innerElement.LineInfo);
            }

            //ws* nodeElement ws*
            if (innerElement.Children.Count() != 1)
            {
                throw new RdfXmlParserException(Constants.ErrorMessageIds.MsgResourcePropertyElementSingleChildElement, innerElement.LineInfo);
            }

            foreach (Production attribute in idAttrSet)
            {
                attribute.Match(outputGraph);
            }

            //Generate Triples;
            GenerateTriples(outputGraph, idAttrSet.Count);
        }
        /// <summary>
        /// validates property element based on following syntax rules and create triples,
        /// <br/>
        /// start-element(URI == propertyElementURIs ),
        /// attributes == set(idAttr?, ( resourceAttr | nodeIdAttr )?, propertyAttr*))
        /// end-element()
        /// </summary>
        /// <param name="outputGraph">Graph to add the generated triples.</param>
        internal override void Match(Graph outputGraph)
        {
            try
            {
                //start-element(URI == propertyElementURIs ),
                ProductionPropertyElementUris propertyElementUris =
                    new ProductionPropertyElementUris(innerElement.Uri);
                propertyElementUris.Match(outputGraph);
            }
            catch (RdfXmlParserException ex)
            {
                throw new RdfXmlParserException(ex.ErrorMessageId, innerElement.LineInfo);
            }

            Collection <Production> set = new Collection <Production>();

            foreach (EventAttribute attribute in innerElement.Attributes)
            {
                set.Add(GetProductionAttribute(attribute));
            }

            // Validate attributes.
            //attributes == set(idAttr?, ( resourceAttr | nodeIdAttr )?, propertyAttr*))
            if (set.Where(tuple => tuple is ProductionIdAttribute).Count() > 1)
            {
                throw new RdfXmlParserException(Constants.ErrorMessageIds.MsgEmptyPropertyElementMoreThanOneIDAttr, innerElement.LineInfo);
            }

            if (set.Where(tuple => tuple is ProductionResourceAttribute ||
                          tuple is ProductionNodeIdAttribute).Count() > 1)
            {
                throw new RdfXmlParserException(Constants.ErrorMessageIds.MsgEmptyPropertyElementNotComplyToRule, innerElement.LineInfo);
            }

            foreach (Production attribute in set)
            {
                attribute.Match(outputGraph);
            }

            //Generate Triples.
            GenerateTriples(outputGraph);
        }
        /// <summary>
        /// Validates property element based on following syntax rules and creates triples,
        /// <br/>
        /// start-element(URI == propertyElementURIs ),
        /// attributes == set(idAttr?, parseResource))
        /// propertyEltList
        /// end-element()
        /// </summary>
        /// <param name="outputGraph">Graph to add the generated triples.</param>
        internal override void Match(Graph outputGraph)
        {
            try
            {
                ProductionPropertyElementUris propertyElementUris =
                    new ProductionPropertyElementUris(innerElement.Uri);
                propertyElementUris.Match(outputGraph);
            }
            catch (RdfXmlParserException ex)
            {
                throw new RdfXmlParserException(ex.ErrorMessageId, innerElement.LineInfo);
            }

            // Validate attributes.
            //attributes == set(idAttr?, parseResource))
            Collection <Production> set = new Collection <Production>();

            foreach (EventAttribute attribute in innerElement.Attributes)
            {
                Production production = GetProductionAttribute(attribute);
                if (production != null)
                {
                    set.Add(production);
                }
                else
                {
                    throw new RdfXmlParserException(
                              Constants.ErrorMessageIds.MsgParseTypeResourcePropertyElementNoOtherAttrs,
                              innerElement.LineInfo);
                }
            }

            if (set.Where(tuple => tuple is ProductionIdAttribute).Count() > 1)
            {
                throw new RdfXmlParserException(Constants.ErrorMessageIds.MsgParseTypeResourcePropertyElementMoreThanOneIdAttr, innerElement.LineInfo);
            }
            if (set.Where(tuple => tuple is ProductionParseResource).Count() != 1)
            {
                throw new RdfXmlParserException(Constants.ErrorMessageIds.MsgParseTypeResourcePropertyElementSingleParseResourceAttr, innerElement.LineInfo);
            }

            foreach (Production attribute in set)
            {
                attribute.Match(outputGraph);
            }

            //Generate Triples.
            BlankNode n = GenerateTriples(outputGraph);

            //If the element content c is not empty, then use event
            //n to create a new sequence of events as follows:
            //start-element(URI := rdf:Description,
            //subject := n,
            //attributes := set())
            //c
            //end-element()
            //Then process the resulting sequence using production nodeElement.
            if (innerElement.Children.Count() > 0)
            {
                EventElement element = new EventElement(Constants.Description,
                                                        Constants.RdfNamespace, innerElement.Children);
                element.Subject = n;

                ProductionNodeElement nodeElement = new ProductionNodeElement(element);
                nodeElement.Match(outputGraph);
            }
        }