Representation of an XML processing instruction node.
Inheritance: TreeNode
 internal DomProcessingInstruction(ProcessingInstruction node)
     : base(node.Name, node.Value, (XmlDocument)node.Document.XmlNode)
 {
     _node = node;
 }
Example #2
0
File: Node.cs Project: wushian/Nxdb
        internal static Node Get(DBNode dbNode, Database database, bool check = true)
        {
            if (dbNode == null)
            {
                throw new ArgumentNullException("dbNode");
            }
            if (database == null)
            {
                throw new ArgumentNullException("database");
            }

            // Copy the DBNode if it wasn't created from scratch
            if (check)
            {
                // Is it already created?
                Node node = database.GetNode(dbNode.pre);
                if (node != null)
                {
                    return(node);
                }

                // Otherwise, copy the DBNode so we can make a new Node
                dbNode = dbNode.copy();
            }

            // Create the appropriate database node class
            Node     newNode;
            NodeType nodeType = dbNode.nodeType();

            if (nodeType == org.basex.query.item.NodeType.ELM)
            {
                newNode = new Element(dbNode, database);
            }
            else if (nodeType == org.basex.query.item.NodeType.TXT)
            {
                newNode = new Text(dbNode, database);
            }
            else if (nodeType == org.basex.query.item.NodeType.ATT)
            {
                newNode = new Attribute(dbNode, database);
            }
            else if (nodeType == org.basex.query.item.NodeType.DOC)
            {
                newNode = new Document(dbNode, database);
            }
            else if (nodeType == org.basex.query.item.NodeType.COM)
            {
                newNode = new Comment(dbNode, database);
            }
            else if (nodeType == org.basex.query.item.NodeType.PI)
            {
                newNode = new ProcessingInstruction(dbNode, database);
            }
            else
            {
                throw new ArgumentException("Invalid node type");
            }

            // Cache and return the node
            database.SetNode(dbNode.pre, newNode);
            return(newNode);
        }