/// <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(OwlRestriction node, Object parent) { XmlElement parentElement = parent as XmlElement; if (parentElement != null) { XmlElement restrictionElement = _owlDocument.CreateElement("owl:Restriction", OwlNamespaceCollection.OwlNamespace); // If the node is not a blank one if (!node.IsAnonymous()) { // Add the name as one of its attributes AddNameAttribute(restrictionElement, node); } // Generate all the edges going out of this node if (!_visited.Contains(node)) { VisitEdges(node, restrictionElement); } // Attach the node eventually to its parent parentElement.AppendChild(restrictionElement); _visited.Add(node); } }
/// <summary> /// Adds an OWL Resource of type owl:Restriction 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 OwlRestriction AddRestrictionToGraph(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 OwlRestriction)) return (OwlRestriction)node; OwlNode typeNode = (OwlNode)_owlGraph.AddNode(OwlNamespaceCollection.OwlNamespace+"Restriction"); if(node == null) { node = new OwlRestriction(nodeUri,typeNode); _owlGraph.AddEdge(((OwlRestriction)node).Type); _owlGraph.AddNode(node); return (OwlRestriction)node; } OwlRestriction newNode = new OwlRestriction(nodeUri,typeNode); _owlGraph.AddEdge(newNode.Type); MoveEdges(node, newNode); _owlGraph.Nodes.Remove(node); _owlGraph.AddNode(newNode); return newNode; }
/// <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(OwlRestriction node, Object parent) { XmlElement parentElement = parent as XmlElement; if(parentElement != null) { XmlElement restrictionElement = _owlDocument.CreateElement("owl:Restriction", OwlNamespaceCollection.OwlNamespace); // If the node is not a blank one if(!node.IsAnonymous()) { // Add the name as one of its attributes AddNameAttribute(restrictionElement, node); } // Generate all the edges going out of this node if(!node.Visited) VisitEdges(node, restrictionElement); // Attach the node eventually to its parent parentElement.AppendChild(restrictionElement); 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(OwlRestriction node, Object parent);