/// <summary> /// Adds a literal to the Graph /// </summary> /// <param name="literalValue">A string representing the value of the literal.</param> /// <returns>An object that implements the IOwlLiteral interface. This is a reference to the newly added literal.</returns> /// <remarks>This method looks in the graph to determine whether a literal with the specified value (and a null datatype and langID) exists /// in the Graph. If the literal exists a reference to the existing literal is returned. If it does not exist then a new literal (with the specified value, and null datatype and LangID) /// is created, added to the graph and returned.</remarks> public IOwlLiteral AddLiteral(string literalValue) { OwlLiteral literal = (OwlLiteral)_literals[literalValue]; if (literal == null) { literal = new OwlLiteral(literalValue); _literals[literalValue] = literal; } return(literal); }
/// <summary> /// Implementation of the visit function to generate some output, used in the visitor pattern /// </summary> /// <param name="node">The actual node which needs to be generated</param> /// <param name="parent">The parent object of the node</param> public override void Visit(OwlLiteral node, Object parent) { XmlElement parentElement = parent as XmlElement; _messages.Add("Writing " + node.ID); if (parentElement != null) { // Set the datatype property on its parent XmlAttribute nameAttribute = _owlDocument.CreateAttribute("rdf", "datatype", OwlNamespaceCollection.RdfNamespace); nameAttribute.Value = node.Datatype; parentElement.Attributes.Append(nameAttribute); // Add the value of the literal parentElement.InnerXml = node.Value; _visited.Add(node); return; } }
/// <summary> /// Adds a literal to the Graph /// </summary> /// <param name="literalValue">A string representing the value of the literal.</param> /// <param name="langID">A string representing the Language ID of the literal.</param> /// <param name="datatypeUri">A string representing the datatype URI of the literal.</param> /// <returns>An object that implements the IOwlLiteral interface. This is a reference to the newly added literal.</returns> /// <exception cref="UriFormatException">The specified datatype URI is not null and is not a well formed URI.</exception> /// <remarks>This method looks in the graph to determine whether a literal with the specified value, datatype and langID exists /// in the Graph. If the literal exists a reference to the existing literal is returned. If it does not exist then a new literal with the specified value, datatype and LangID /// is created, added to the graph and returned. Any parameter supplied to this method, except literalValue, can be null or empty and it will be ignored.</remarks> public IOwlLiteral AddLiteral(string literalValue, string langID, string datatypeUri) { string literalID = literalValue; if ((langID != null) && (langID.Length != 0)) { literalID += "@" + langID; } if ((datatypeUri != null) && (datatypeUri.Length != 0)) { literalID += "^^" + datatypeUri; } OwlLiteral literal = (OwlLiteral)_literals[literalID]; if (literal == null) { literal = new OwlLiteral(literalValue, langID, datatypeUri); _literals[literalID] = literal; } return(literal); }
/// <summary> /// Adds a literal to the Graph /// </summary> /// <param name="literalValue">A string representing the value of the literal.</param> /// <param name="langID">A string representing the Language ID of the literal.</param> /// <param name="datatypeUri">A string representing the datatype URI of the literal.</param> /// <returns>An object that implements the IOwlLiteral interface. This is a reference to the newly added literal.</returns> /// <exception cref="UriFormatException">The specified datatype URI is not null and is not a well formed URI.</exception> /// <remarks>This method looks in the graph to determine whether a literal with the specified value, datatype and langID exists /// in the Graph. If the literal exists a reference to the existing literal is returned. If it does not exist then a new literal with the specified value, datatype and LangID /// is created, added to the graph and returned. Any parameter supplied to this method, except literalValue, can be null or empty and it will be ignored.</remarks> public IOwlLiteral AddLiteral(string literalValue, string langID, string datatypeUri) { string literalID = literalValue; if((langID != null) && (langID.Length != 0)) literalID +="@"+langID; if((datatypeUri != null) && (datatypeUri.Length != 0)) literalID +="^^"+datatypeUri; OwlLiteral literal = (OwlLiteral)_literals[literalID]; if(literal == null) { literal = new OwlLiteral(literalValue,langID,datatypeUri); _literals[literalID] = literal; } return literal; }
/// <summary> /// Adds a literal to the Graph /// </summary> /// <param name="literalValue">A string representing the value of the literal.</param> /// <returns>An object that implements the IOwlLiteral interface. This is a reference to the newly added literal.</returns> /// <remarks>This method looks in the graph to determine whether a literal with the specified value (and a null datatype and langID) exists /// in the Graph. If the literal exists a reference to the existing literal is returned. If it does not exist then a new literal (with the specified value, and null datatype and LangID) /// is created, added to the graph and returned.</remarks> public IOwlLiteral AddLiteral(string literalValue) { OwlLiteral literal = (OwlLiteral)_literals[literalValue]; if(literal == null) { literal = new OwlLiteral(literalValue); _literals[literalValue] = literal; } return literal; }
/// <summary> /// Implementation of the visit function to generate some output, used in the visitor pattern /// </summary> /// <param name="node">The actual node which needs to be generated</param> /// <param name="parent">The parent object of the node</param> public override void Visit(OwlLiteral node, Object parent) { XmlElement parentElement = parent as XmlElement; _messages.Add("Writing " + node.ID); if(parentElement != null) { // Set the datatype property on its parent XmlAttribute nameAttribute = _owlDocument.CreateAttribute("rdf", "datatype", OwlNamespaceCollection.RdfNamespace); nameAttribute.Value = node.Datatype; parentElement.Attributes.Append(nameAttribute); // Add the value of the literal parentElement.InnerXml = node.Value; node.Visited = true; return; } }
/// <summary> /// Implementation of the visit function to generate some output, used in the visitor pattern /// </summary> /// <param name="node">The actual node which needs to be generated</param> /// <param name="parent">The parent object of the node</param> public abstract void Visit(OwlLiteral node, Object parent);