/// <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(OwlCollection node, Object parent) { XmlElement parentElement = parent as XmlElement; if (parentElement != null) { // Set the datatype property on its parent XmlAttribute nameAttribute = _owlDocument.CreateAttribute("rdf", "parseType", OwlNamespaceCollection.RdfNamespace); nameAttribute.Value = "Collection"; parentElement.Attributes.Append(nameAttribute); IEnumerator e = node.GetEnumerator(); while (e.MoveNext()) { OwlNode n = (OwlNode)e.Current; n.Accept(this, parent); } } }
/// <summary> /// Builds an OWL Collection. /// </summary> /// <param name="propertyNode">The XML Node containing the children that will form the members of this list</param> /// <returns>The head of the collection. This is the first member of the list or a nil node if the list is empty</returns> private OwlCollection BuildCollection(XmlNode propertyNode) { // OwlNode rNode; // OwlNode collHead = null; // OwlEdge restEdge = null; // OwlEdge firstEdge; int count = propertyNode.ChildNodes.Count; OwlCollection collection = new OwlCollection(GetBlankNodeUri(null)); for(int i=0;i<count;i++) { // //build the blank node that is a member of this list // rNode = (OwlNode)_owlGraph.AddNode(GetBlankNodeUri(null)); // //if this is the first element of the cons list then set this as the head of the collection so we may return it later // if(i == 0) // collHead = rNode; // // //add an outgoing edge with name rdf:type from rdfNode to rdf:List // OwlEdge typeEdge = new OwlEdge(OwlNamespaceCollection.RdfNamespace+"type"); // _owlGraph.AddEdge(typeEdge); // OwlNode typeNode = (OwlNode)_owlGraph.AddNode(OwlNamespaceCollection.RdfNamespace+"List"); // rNode.AttachChildEdge(typeEdge); // typeEdge.AttachChildNode(typeNode); // // //create a new first edge // firstEdge = new OwlEdge(OwlNamespaceCollection.RdfNamespace+"first"); // rNode.AttachChildEdge(firstEdge); // //add the first edge to the graph // _owlGraph.AddEdge(firstEdge); // // OwlNode firstNode = (OwlNode)ProcessNode(propertyNode.ChildNodes[i],firstEdge); OwlNode newNode = (OwlNode)ProcessNode(propertyNode.ChildNodes[i],null); collection.Add(newNode); // //OwlNode firstNode = tempNode; // firstEdge.AttachChildNode(firstNode); // // if(restEdge != null) // rNode.AttachParentEdge(restEdge); // // //make the new rest Edge // restEdge = new OwlEdge(OwlNamespaceCollection.RdfNamespace+"rest"); // restEdge.AttachParentNode(rNode); // //add the new RestEdge to the graph // _owlGraph.AddEdge(restEdge); } // //ok we have exited the loop or bypassed it because there are no children // // rNode = (OwlNode)_owlGraph.AddNode(OwlNamespaceCollection.RdfNamespace+"nil"); // if(restEdge != null) // rNode.AttachParentEdge(restEdge); // // if(collHead == null) // collHead = rNode; // // return collHead; return collection; }
/// <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(OwlCollection node, Object parent) { XmlElement parentElement = parent as XmlElement; if(parentElement != null) { // Set the datatype property on its parent XmlAttribute nameAttribute = _owlDocument.CreateAttribute("rdf", "parseType", OwlNamespaceCollection.RdfNamespace); nameAttribute.Value = "Collection"; parentElement.Attributes.Append(nameAttribute); IEnumerator e = node.GetEnumerator(); while(e.MoveNext()) { OwlNode n = (OwlNode)e.Current; n.Accept(this, 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(OwlCollection node, Object parent);