/// <summary> /// Initializes a new instance of the ProductionResourcePropertyElement class. /// The constructor takes an EventElement to initialize itself. /// </summary> /// <param name="propertyElement">EventElement object to process.</param> internal ProductionResourcePropertyElement(EventElement propertyElement) { if (propertyElement == null) { throw new ArgumentNullException( string.Format(CultureInfo.InvariantCulture, Resources.MsgNullArgument, "propertyElement")); } innerElement = propertyElement; }
/// <summary> /// Initializes a new instance of the ProductionNodeElement class. /// The constructor takes an EventElement to initialize itself. /// </summary> /// <param name="nodeElement">EventElement object to process.</param> internal ProductionNodeElement(EventElement nodeElement) { if (nodeElement == null) { throw new ArgumentNullException( string.Format(CultureInfo.InvariantCulture, Resources.MsgNullArgument, "nodeElement")); } this.innerElement = nodeElement; }
/// <summary> /// Initializes a new instance of the ProductionRdf class. /// The constructor takes an EventElement to initialize itself. /// </summary> /// <param name="rdfElement">EventElement object to process</param> internal ProductionRdf(EventElement rdfElement) { if (rdfElement == null) { throw new ArgumentNullException( string.Format(CultureInfo.InvariantCulture, Resources.MsgNullArgument, "rdfElement")); } innerElement = rdfElement; }
/// <summary> /// Gets the children. /// </summary> /// <returns>Returns a list of Event Element</returns> private List <EventElement> GetChildren() { List <EventElement> childrenList = new List <EventElement>(); IEnumerable <XElement> eventlementList = innerElement.Elements(). Where(tuple => !string.IsNullOrEmpty(tuple.Name.NamespaceName)); foreach (XElement element in eventlementList) { EventElement child = new EventElement(element); child.Parent = this; childrenList.Add(child); } return(childrenList); }
/// <summary> /// Resolve given string by by interpreting string as a relative URI reference /// to the •base-uri• accessor of element as defined in W3C specification, /// http://www.w3.org/TR/2004/REC-rdf-syntax-grammar-20040210/#section-baseURIs. /// </summary> /// <param name="e">Event element.</param> /// <param name="a">Relative string to resolve.</param> /// <returns>Resoved RDFUriReference object.</returns> /// <exception cref="Zentity.Rdf.Xml.RdfXmlParserException">Invalid uri reference.</exception> internal static RDFUriReference Resolve(EventElement e, string a) { try { //TODO: Handle Possible Test Cases. //TODO: Case To Handle. a is empty and base Uri is default base Uri. Uri baseUri = new Uri(e.BaseUri); if (string.IsNullOrEmpty(a) && !string.IsNullOrEmpty(baseUri.Fragment)) { baseUri = new Uri(baseUri.AbsoluteUri.Replace(baseUri.Fragment, string.Empty)); } return(new RDFUriReference(baseUri, a)); } catch (UriFormatException ex) { throw new RdfXmlParserException(ex, Constants.ErrorMessageIds.MsgEventElementInvalidUri, e.LineInfo); } }
/// <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); } }