/// <summary> /// Matches the production. /// <br/> /// root(document-element == RDF,children == list(RDF)) /// </summary> /// <param name="outputGraph">Graph to add the generated triples.</param> internal override void Match(Graph outputGraph) { if (isRDFElementPresent) { List <EventElement> rootElements = new List <EventElement>(); if (FindRootRDFElements(innerDocument.Root, rootElements)) { foreach (EventElement element in rootElements) { ProductionRdf rootProduction = new ProductionRdf(element); rootProduction.Match(outputGraph); } } else { throw new RdfXmlParserException(Constants.ErrorMessageIds.MsgDocNoRDFElement); } } else { List <EventElement> elementList = new List <EventElement>(); foreach (XElement xmlElement in innerDocument.Elements()) { elementList.Add(new EventElement(xmlElement)); } ProductionNodeElementList nodeElementList = new ProductionNodeElementList(elementList); nodeElementList.Match(outputGraph); } }
/// <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> /// Matches production, /// <br/> /// start-element(URI == rdf:RDF, attributes == set()) /// nodeElementList /// end-element() /// </summary> /// <param name="outputGraph">Graph to add the generated triples.</param> internal override void Match(Graph outputGraph) { if (innerElement.Uri != RDFUri) { throw new RdfXmlParserException(Constants.ErrorMessageIds.MsgRdfInvalidRootElement, innerElement.LineInfo); } if (innerElement.Attributes.Count() != 0) { throw new RdfXmlParserException(Constants.ErrorMessageIds.MsgRdfNoAttrAllowed, innerElement.LineInfo); } ProductionNodeElementList nodeElementList = new ProductionNodeElementList(innerElement.Children); nodeElementList.Match(outputGraph); }