/// <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(OwlDatatypeProperty node, Object parent) { XmlElement parentElement = parent as XmlElement; if (parentElement != null) { XmlElement propertyElement = _owlDocument.CreateElement("owl:DatatypeProperty", OwlNamespaceCollection.OwlNamespace); // Add the name attribute to the node AddNameAttribute(propertyElement, node); // Generate all the edges going out of this node if (!_visited.Contains(node)) { VisitEdges(node, propertyElement); } // Attach the node eventually to its parent parentElement.AppendChild(propertyElement); _visited.Add(node); } }
/// <summary> /// Adds an OWL Resource of type owl:DatatypeProperty to the graph</summary> /// <param name="nodeUri">The Uri of the resource.</param> /// <returns>Returns a reference to the newly added resource.</returns> /// <exception cref="UriFormatException">The specified nodeUri is not a well formed Uri.</exception> private OwlDatatypeProperty AddDatatypePropertyToGraph(string nodeUri) { //if the uri is null then create a blank node uri if(nodeUri == null) nodeUri = GetBlankNodeUri(null); OwlNode node = (OwlNode)_owlGraph[nodeUri]; if((node != null) && (node is OwlDatatypeProperty)) return (OwlDatatypeProperty)node; OwlNode typeNode = (OwlNode)_owlGraph.AddNode(OwlNamespaceCollection.OwlNamespace+"DatatypeProperty"); if(node == null) { node = new OwlDatatypeProperty(nodeUri,typeNode); _owlGraph.AddEdge(((OwlDatatypeProperty)node).Type); _owlGraph.AddNode(node); return (OwlDatatypeProperty)node; } OwlDatatypeProperty newNode = new OwlDatatypeProperty(nodeUri,typeNode); _owlGraph.AddEdge(newNode.Type); MoveEdges(node, newNode); _owlGraph.Nodes.Remove(node); _owlGraph.AddNode(newNode); return newNode; }
/// <summary> /// Parses the OWL syntax on an edge. /// </summary> /// <param name="node">The XML Node representing the OWL edge</param> /// <param name="rEdge">The edge</param> /// <param name="parentNode">The parent OWL node</param> /// <returns>True if the edge was given an ID and attached to the parent node</returns> private bool ParseEdgeSyntax(XmlNode node, OwlEdge rEdge, OwlNode parentNode) { //first get the NameSpace URI, NameSpace prefix and the LocalName for the node String nameSpaceURI = node.NamespaceURI; String nameSpacePrefix = node.Prefix; String localName = node.LocalName; if(IsNonSyntacticElement(node)) { rEdge.ID = nameSpaceURI + localName; if(rEdge.ID == (OwlNamespaceCollection.RdfNamespace + "type")) { OwlNode typeNode; if(rEdge.ChildNode.ID == (OwlNamespaceCollection.OwlNamespace + "DatatypeProperty")) { typeNode = (OwlNode)_owlGraph.AddNode(OwlNamespaceCollection.OwlNamespace+"DatatypeProperty"); OwlDatatypeProperty newNode = new OwlDatatypeProperty(parentNode.ID,typeNode); _owlGraph.AddEdge(newNode.Type); MoveEdges(parentNode, newNode); _owlGraph.Nodes.Remove(parentNode); _owlGraph.AddNode(newNode); rEdge.AttachParentNode(newNode); return true; } if(rEdge.ChildNode.ID == (OwlNamespaceCollection.OwlNamespace + "ObjectProperty")) { typeNode = (OwlNode)_owlGraph.AddNode(OwlNamespaceCollection.OwlNamespace+"ObjectProperty"); OwlObjectProperty newNode = new OwlObjectProperty(parentNode.ID,typeNode); _owlGraph.AddEdge(newNode.Type); MoveEdges(parentNode, newNode); _owlGraph.Nodes.Remove(parentNode); _owlGraph.AddNode(newNode); rEdge.AttachParentNode(newNode); return true; } } rEdge.AttachParentNode(parentNode); return true; } if(IsSyntacticElement(node)) { OnError("Cannot use " + node.Name + " as a property element"); return false; } // It is an instance of a property rEdge.ID = nameSpaceURI + localName; rEdge.AttachParentNode(parentNode); return true; // OnWarning("Unknown property element "+ node.Name); // return false; }
/// <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(OwlDatatypeProperty node, Object parent) { XmlElement parentElement = parent as XmlElement; if(parentElement != null) { XmlElement propertyElement = _owlDocument.CreateElement("owl:DatatypeProperty", OwlNamespaceCollection.OwlNamespace); // Add the name attribute to the node AddNameAttribute(propertyElement, node); // Generate all the edges going out of this node if(!node.Visited) { VisitEdges(node, propertyElement); } // Attach the node eventually to its parent parentElement.AppendChild(propertyElement); node.Visited = true; } }
/// <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(OwlDatatypeProperty node, Object parent);
/// <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(OwlDatatypeProperty node, Object parent);