Example #1
0
        public StyleSheet(XmlProcessingInstruction pi)
            : this(String.Empty)
        {
            Regex re = new Regex(@"(?<name>[a-z]+)=[""'](?<value>[^""']*)[""']");
            Match match = re.Match(pi.Data);

            while(match.Success)
            {
                string name = match.Groups["name"].Value;
                string val = match.Groups["value"].Value;

                switch(name)
                {
                    case "href":
                        _Href = val;
                        break;
                    case "type":
                        _Type = val;
                        break;
                    case "title":
                        _Title = val;
                        break;
                    case "media":
                        _Media = new MediaList(val);
                        break;
                }
                match = match.NextMatch();
            }

            ownerNode = pi;
        }
Example #2
0
        /// <summary>
        /// 执行sql
        /// </summary>
        /// <param name="strSql"></param>
        /// <param name="strDataSet"></param>
        /// <returns></returns>
        public int ExecQuery(string strSql, ref string strDataSet, string strXSLFileName)
        {
            this.command.Connection = this.con as OracleConnection;
            if (this.command.Transaction == null) //没有事务,用全局事务
            {
                this.command.Transaction = Neusoft.FrameWork.Management.PublicTrans.Trans as OracleTransaction;
            }
            this.command.CommandType = System.Data.CommandType.Text;
            this.command.Parameters.Clear();
            this.command.CommandText = strSql + "";
            try
            {
                this.TempReader1 = this.command.ExecuteReader();
                XmlDocument doc = new XmlDocument();
                XmlNode     root;
                XmlElement  node, row;
                doc.AppendChild(doc.CreateXmlDeclaration("1.0", "GB2312", ""));
                if (strXSLFileName != null && strXSLFileName != "")
                {
                    string PI = "type='text/xsl' href='" + strXSLFileName + "'";
                    System.Xml.XmlProcessingInstruction xmlProcessingInstruction = doc.CreateProcessingInstruction("xml-stylesheet", PI);
                    doc.AppendChild(xmlProcessingInstruction);
                }
                root = doc.CreateElement("Table");
                doc.AppendChild(root);
                while (this.TempReader1.Read())
                {
                    row = doc.CreateElement("Row");
                    for (int i = 0; i < this.TempReader1.FieldCount; i++)
                    {
                        node = doc.CreateElement("Column");
                        node.SetAttribute("Name", this.TempReader1.GetName(i).ToString());
                        node.InnerText = this.TempReader1[i].ToString() + "";
                        row.AppendChild(node);
                    }
                    root.AppendChild(row);
                }
                strDataSet = doc.OuterXml;
                TempReader1.Close();
            }
            catch (OracleException ex)
            {
                this.Err       = "执行产生错误!" + ex.Message;
                this.ErrCode   = strSql;
                this.DBErrCode = ex.Code;
                this.WriteErr();
                return(-1);
            }
            catch (Exception ex)
            {
                this.Err            = "执行语句产生错误!" + ex.Message;
                this.ErrorException = ex.InnerException + "+ " + ex.Source;
                this.ErrCode        = strSql;
                this.WriteErr();
                return(-1);
            }

            WriteDebug("执行查询sql语句!" + strSql);
            return(0);
        }
Example #3
0
File: Show.cs Project: rh/mix
        public void Print(XmlProcessingInstruction instruction)
        {
            if (SkipPI)
            {
                return;
            }

            Context.Output.Write("<?{0} {1}?>", instruction.Name, instruction.Value);
        }
Example #4
0
        protected override void ExecuteCore(XmlProcessingInstruction instruction)
        {
            if (instruction.ParentNode is XmlDocument)
            {
                return;
            }

            var element = instruction.OwnerDocument.CreateElement(instruction.Name);
            element.InnerText = instruction.Value;
            instruction.ParentNode.ReplaceChild(element, instruction);
        }
Example #5
0
        /// <summary>
        /// 执行sql
        /// </summary>
        /// <param name="strSql"></param>
        /// <param name="strDataSet"></param>
        /// <param name="strXSLFileName"></param>
        /// <param name="SettingXml"></param>
        /// <returns></returns>
        public int ExecQuery(string strSql, ref string strDataSet, string strXSLFileName, string SettingXml)
        {
            System.Data.OracleClient.OracleConnection con     = new System.Data.OracleClient.OracleConnection(strConn);
            System.Data.OracleClient.OracleCommand    command = new System.Data.OracleClient.OracleCommand();
            command.Connection  = con;
            command.CommandType = System.Data.CommandType.Text;
            command.Parameters.Clear();
            command.CommandText = strSql + "";
            try
            {
                System.Data.OracleClient.OracleDataReader TempReader1;
                TempReader1 = command.ExecuteReader();
                XmlDocument doc = new XmlDocument();
                XmlNode     root;
                XmlElement  node, row;
                doc.AppendChild(doc.CreateXmlDeclaration("1.0", "GB2312", ""));
                if (strXSLFileName != null && strXSLFileName != "")
                {
                    string PI = "type='text/xsl' href='" + strXSLFileName + "'";
                    System.Xml.XmlProcessingInstruction xmlProcessingInstruction = doc.CreateProcessingInstruction("xml-stylesheet", PI);
                    doc.AppendChild(xmlProcessingInstruction);
                }
                string Header = doc.OuterXml + "\n<DataSet>\n" + SettingXml;
                doc  = new XmlDocument();
                root = doc.CreateElement("Table");
                doc.AppendChild(root);
                while (TempReader1.Read())
                {
                    row = doc.CreateElement("Row");
                    for (int i = 0; i < TempReader1.FieldCount; i++)
                    {
                        node = doc.CreateElement("Column");
                        node.SetAttribute("Name", TempReader1.GetName(i).ToString());
                        node.InnerText = TempReader1[i].ToString() + "";
                        row.AppendChild(node);
                    }
                    root.AppendChild(row);
                }
                strDataSet = Header + "\n" + doc.OuterXml + "\n</DataSet>";
                TempReader1.Close();
            }
            catch (Exception ex)
            {
                this.Err            = "执行语句产生错误!" + ex.Message;
                this.ErrorException = ex.InnerException + "+ " + ex.Source;
                this.ErrCode        = strSql;
                this.WriteErr();
                return(-1);
            }

            WriteDebug("执行查询sql语句!" + strSql);
            return(0);
        }
Example #6
0
 protected override void ExecuteCore(XmlProcessingInstruction instruction)
 {
     var text = instruction.OwnerDocument.CreateTextNode(instruction.Value);
     instruction.ParentNode.ReplaceChild(text, instruction);
 }
Example #7
0
        public virtual XmlNode ImportNode(XmlNode node, bool deep)
        {
            if (node == null)
            {
                throw new NullReferenceException("Null node cannot be imported.");
            }

            switch (node.NodeType)
            {
            case XmlNodeType.Attribute:
                XmlAttribute srcAtt = node as XmlAttribute;
                XmlAttribute dstAtt = this.CreateAttribute(srcAtt.Prefix, srcAtt.LocalName, srcAtt.NamespaceURI);
                for (XmlNode n = srcAtt.FirstChild; n != null; n = n.NextSibling)
                {
                    dstAtt.AppendChild(this.ImportNode(n, deep));
                }
                return(dstAtt);

            case XmlNodeType.CDATA:
                return(this.CreateCDataSection(node.Value));

            case XmlNodeType.Comment:
                return(this.CreateComment(node.Value));

            case XmlNodeType.Document:
                throw new XmlException("Document cannot be imported.");

            case XmlNodeType.DocumentFragment:
                XmlDocumentFragment df = this.CreateDocumentFragment();
                if (deep)
                {
                    for (XmlNode n = node.FirstChild; n != null; n = n.NextSibling)
                    {
                        df.AppendChild(this.ImportNode(n, deep));
                    }
                }
                return(df);

            case XmlNodeType.DocumentType:
                throw new XmlException("DocumentType cannot be imported.");

            case XmlNodeType.Element:
                XmlElement src = (XmlElement)node;
                XmlElement dst = this.CreateElement(src.Prefix, src.LocalName, src.NamespaceURI);
                for (int i = 0; i < src.Attributes.Count; i++)
                {
                    XmlAttribute attr = src.Attributes [i];
                    if (attr.Specified)                         // copies only specified attributes
                    {
                        dst.SetAttributeNode((XmlAttribute)this.ImportNode(attr, deep));
                    }
                }
                if (deep)
                {
                    for (XmlNode n = src.FirstChild; n != null; n = n.NextSibling)
                    {
                        dst.AppendChild(this.ImportNode(n, deep));
                    }
                }
                return(dst);

            case XmlNodeType.EndElement:
                throw new XmlException("Illegal ImportNode call for NodeType.EndElement");

            case XmlNodeType.EndEntity:
                throw new XmlException("Illegal ImportNode call for NodeType.EndEntity");

            case XmlNodeType.EntityReference:
                return(this.CreateEntityReference(node.Name));

            case XmlNodeType.None:
                throw new XmlException("Illegal ImportNode call for NodeType.None");

            case XmlNodeType.ProcessingInstruction:
                XmlProcessingInstruction pi = node as XmlProcessingInstruction;
                return(this.CreateProcessingInstruction(pi.Target, pi.Data));

            case XmlNodeType.SignificantWhitespace:
                return(this.CreateSignificantWhitespace(node.Value));

            case XmlNodeType.Text:
                return(this.CreateTextNode(node.Value));

            case XmlNodeType.Whitespace:
                return(this.CreateWhitespace(node.Value));

            case XmlNodeType.XmlDeclaration:
                XmlDeclaration srcDecl = node as XmlDeclaration;
                return(this.CreateXmlDeclaration(srcDecl.Version, srcDecl.Encoding, srcDecl.Standalone));

            default:
                throw new InvalidOperationException("Cannot import specified node type: " + node.NodeType);
            }
        }
Example #8
0
        // LoadNodeDirect does not use creator functions on XmlDocument. It is used loading nodes that are children of entity nodes, 
        // because we do not want to let users extend these (if we would allow this, XmlDataDocument would have a problem, because 
        // they do not know that those nodes should not be mapped). It can be also used for an optimized load path when if the 
        // XmlDocument is not extended if XmlDocumentType and XmlDeclaration handling is added.
        private XmlNode LoadNodeDirect()
        {
            XmlReader r = _reader;
            XmlNode parent = null;
            do
            {
                XmlNode node = null;
                switch (r.NodeType)
                {
                    case XmlNodeType.Element:
                        bool fEmptyElement = _reader.IsEmptyElement;
                        XmlElement element = new XmlElement(_reader.Prefix, _reader.LocalName, _reader.NamespaceURI, _doc);
                        element.IsEmpty = fEmptyElement;

                        if (_reader.MoveToFirstAttribute())
                        {
                            XmlAttributeCollection attributes = element.Attributes;
                            do
                            {
                                XmlAttribute attr = LoadAttributeNodeDirect();
                                attributes.Append(attr); // special case for load
                            } while (r.MoveToNextAttribute());
                        }

                        // recursively load all children.
                        if (!fEmptyElement)
                        {
                            parent.AppendChildForLoad(element, _doc);
                            parent = element;
                            continue;
                        }
                        else
                        {
                            node = element;
                            break;
                        }

                    case XmlNodeType.EndElement:
                        Debug.Assert(parent.NodeType == XmlNodeType.Element);
                        if (parent.ParentNode == null)
                        {
                            return parent;
                        }
                        parent = parent.ParentNode;
                        continue;

                    case XmlNodeType.EntityReference:
                        node = LoadEntityReferenceNode(true);
                        break;

                    case XmlNodeType.EndEntity:
                        continue;

                    case XmlNodeType.Attribute:
                        node = LoadAttributeNodeDirect();
                        break;

                    case XmlNodeType.SignificantWhitespace:
                        node = new XmlSignificantWhitespace(_reader.Value, _doc);
                        break;

                    case XmlNodeType.Whitespace:
                        if (_preserveWhitespace)
                        {
                            node = new XmlWhitespace(_reader.Value, _doc);
                        }
                        else
                        {
                            continue;
                        }
                        break;

                    case XmlNodeType.Text:
                        node = new XmlText(_reader.Value, _doc);
                        break;

                    case XmlNodeType.CDATA:
                        node = new XmlCDataSection(_reader.Value, _doc);
                        break;

                    case XmlNodeType.ProcessingInstruction:
                        node = new XmlProcessingInstruction(_reader.Name, _reader.Value, _doc);
                        break;

                    case XmlNodeType.Comment:
                        node = new XmlComment(_reader.Value, _doc);
                        break;

                    default:
                        throw UnexpectedNodeType(_reader.NodeType);
                }

                Debug.Assert(node != null);
                if (parent != null)
                {
                    parent.AppendChildForLoad(node, _doc);
                }
                else
                {
                    return node;
                }
            }
            while (r.Read());

            return null;
        }
Example #9
0
File: Show.cs Project: rh/mix
 protected override void ExecuteCore(XmlProcessingInstruction instruction)
 {
     Print(instruction);
 }
Example #10
0
File: Task.cs Project: rh/mix
 protected virtual void ExecuteCore(XmlProcessingInstruction instruction)
 {
 }
Example #11
0
File: SetGuid.cs Project: rh/mix
 protected override void ExecuteCore(XmlProcessingInstruction instruction)
 {
     instruction.Value = NewGuid();
 }
Example #12
0
        // Used by the ReadNode method for recursively building a DOM subtree.
        internal XmlNode ReadNodeInternal(XmlReader r)
        {
            switch (r.NodeType)
            {
            case XmlNodeType.Attribute:
            {
                // create the attribute
                XmlAttribute att = CreateAttribute
                                       (r.Prefix, r.LocalName, r.NamespaceURI);

                // read and append the children
                ReadChildren(r, att);

                // return the attribute
                return(att);
            }
            // Not reached.

            case XmlNodeType.CDATA:
            {
                // create the character data section
                XmlCDataSection cdata = CreateCDataSection(r.Value);

                // advance the reader to the next node
                r.Read();

                // return the character data section
                return(cdata);
            }
            // Not reached.

            case XmlNodeType.Comment:
            {
                // create the comment
                XmlComment comment = CreateComment(r.Value);

                // advance the reader to the next node
                r.Read();

                // return the comment
                return(comment);
            }
            // Not reached.

            case XmlNodeType.DocumentType:
            {
                // create the document type
                XmlDocumentType doctype = CreateDocumentType
                                              (r.Name, r["PUBLIC"], r["SYSTEM"], r.Value);

                // advance the reader to the next node
                r.Read();

                // return the document type
                return(doctype);
            }
            // Not reached.

            case XmlNodeType.Element:
            {
                // create the element
                XmlElement elem = CreateElement
                                      (r.Prefix, r.LocalName, r.NamespaceURI);
                bool isEmptyElement = r.IsEmptyElement;

                // read the attributes
                while (r.MoveToNextAttribute())
                {
                    XmlAttribute att = (XmlAttribute)ReadNodeInternal(r);
                    elem.SetAttributeNode(att);
                }
                r.MoveToElement();

                // return now if there are no children
                if (isEmptyElement)
                {
                    // advance the reader to the next node
                    r.Read();

                    // return the empty element
                    return(elem);
                }

                elem.IsEmpty = isEmptyElement;

                // read and append the children
                ReadChildren(r, elem);

                // return the element
                return(elem);
            }
            // Not reached.

            case XmlNodeType.DocumentFragment:
            case XmlNodeType.EndElement:
            case XmlNodeType.EndEntity:
            case XmlNodeType.Entity:
            case XmlNodeType.Notation:
            {
                // TODO

                // advance the reader to the next node
                r.Read();

                // nothing to return
                return(null);
            }
            // Not reached.

            case XmlNodeType.EntityReference:
            {
                // create the entity reference
                XmlEntityReference er = CreateEntityReference(r.Name);

                // advance the reader to the next node
                r.Read();

                // return the entity reference
                return(er);
            }
            // Not reached.

            case XmlNodeType.ProcessingInstruction:
            {
                // create the processing instruction
                XmlProcessingInstruction pi = CreateProcessingInstruction
                                                  (r.Name, r.Value);

                // advance the reader to the next node
                r.Read();

                // return the processing instruction
                return(pi);
            }
            // Not reached.

            case XmlNodeType.SignificantWhitespace:
            {
                // create the significant whitespace
                XmlSignificantWhitespace sws = CreateSignificantWhitespace
                                                   (r.Value);

                // advance the reader to the next node
                r.Read();

                // return the significant whitespace
                return(sws);
            }
            // Not reached.

            case XmlNodeType.Text:
            {
                // create the text
                XmlText text = CreateTextNode(r.Value);

                // advance the reader to the next node
                r.Read();

                // return the text
                return(text);
            }
            // Not reached.

            case XmlNodeType.Whitespace:
            {
                // if whitespace preservation is off, skip whitespace
                if (!preserveWhitespace)
                {
                    while (r.Read())
                    {
                        if (r.NodeType != XmlNodeType.Whitespace)
                        {
                            return(null);
                        }
                    }
                    return(null);
                }

                // create the whitespace
                XmlWhitespace ws = CreateWhitespace(r.Value);

                // advance the reader to the next node
                r.Read();

                // return the whitespace
                return(ws);
            }
            // Not reached.

            case XmlNodeType.XmlDeclaration:
            {
                // set up the defaults
                String e = String.Empty;
                String s = String.Empty;

                // read the version
                r.MoveToNextAttribute();

                // read the optional attributes
                if (r.MoveToNextAttribute())
                {
                    if (r.Name == "encoding")
                    {
                        e = r.Value;
                        if (r.MoveToNextAttribute())
                        {
                            s = r.Value;
                        }
                    }
                    else
                    {
                        s = r.Value;
                    }
                }

                // create the xml declaration
                XmlDeclaration xml = CreateXmlDeclaration("1.0", e, s);

                // advance the reader to the next node
                r.Read();

                // return the xml declaration
                return(xml);
            }
            // Not reached.

            default:
            {
                throw new InvalidOperationException(/* TODO */);
            }
                // Not reached.
            }
        }
Example #13
0
File: Rename.cs Project: rh/mix
 protected override void ExecuteCore(XmlProcessingInstruction instruction)
 {
     var parent = instruction.ParentNode;
     var clone = instruction.OwnerDocument.CreateProcessingInstruction(DoRename(instruction.Name), instruction.Value);
     parent.ReplaceChild(clone, instruction);
 }
Example #14
0
		internal DOMProcessingInstruction(XmlProcessingInstruction/*!*/ xmlProcessingInstruction)
			: base(ScriptContext.CurrentContext, true)
		{
			this.XmlProcessingInstruction = xmlProcessingInstruction;
		}
        private XmlNode LoadNodeDirect()
        {
            XmlNode node2;
            XmlReader reader = this.reader;
            XmlNode parentNode = null;
        Label_0009:
            node2 = null;
            switch (reader.NodeType)
            {
                case XmlNodeType.Element:
                {
                    bool isEmptyElement = this.reader.IsEmptyElement;
                    XmlElement newChild = new XmlElement(this.reader.Prefix, this.reader.LocalName, this.reader.NamespaceURI, this.doc) {
                        IsEmpty = isEmptyElement
                    };
                    if (this.reader.MoveToFirstAttribute())
                    {
                        XmlAttributeCollection attributes = newChild.Attributes;
                        do
                        {
                            XmlAttribute attribute = this.LoadAttributeNodeDirect();
                            attributes.Append(attribute);
                        }
                        while (reader.MoveToNextAttribute());
                    }
                    if (!isEmptyElement)
                    {
                        parentNode.AppendChildForLoad(newChild, this.doc);
                        parentNode = newChild;
                        goto Label_01FC;
                    }
                    node2 = newChild;
                    break;
                }
                case XmlNodeType.Attribute:
                    node2 = this.LoadAttributeNodeDirect();
                    break;

                case XmlNodeType.Text:
                    node2 = new XmlText(this.reader.Value, this.doc);
                    break;

                case XmlNodeType.CDATA:
                    node2 = new XmlCDataSection(this.reader.Value, this.doc);
                    break;

                case XmlNodeType.EntityReference:
                    node2 = this.LoadEntityReferenceNode(true);
                    break;

                case XmlNodeType.ProcessingInstruction:
                    node2 = new XmlProcessingInstruction(this.reader.Name, this.reader.Value, this.doc);
                    break;

                case XmlNodeType.Comment:
                    node2 = new XmlComment(this.reader.Value, this.doc);
                    break;

                case XmlNodeType.Whitespace:
                    if (!this.preserveWhitespace)
                    {
                        goto Label_01FC;
                    }
                    node2 = new XmlWhitespace(this.reader.Value, this.doc);
                    break;

                case XmlNodeType.SignificantWhitespace:
                    node2 = new XmlSignificantWhitespace(this.reader.Value, this.doc);
                    break;

                case XmlNodeType.EndElement:
                    if (parentNode.ParentNode != null)
                    {
                        parentNode = parentNode.ParentNode;
                        goto Label_01FC;
                    }
                    return parentNode;

                case XmlNodeType.EndEntity:
                    goto Label_01FC;

                default:
                    throw UnexpectedNodeType(this.reader.NodeType);
            }
            if (parentNode != null)
            {
                parentNode.AppendChildForLoad(node2, this.doc);
            }
            else
            {
                return node2;
            }
        Label_01FC:
            if (reader.Read())
            {
                goto Label_0009;
            }
            return null;
        }
Example #16
0
        protected override void ExecuteCore(XmlProcessingInstruction instruction)
        {
            var element = instruction.ParentNode as XmlElement;
            var name = instruction.Name;

            if (element != null && element.Attributes[name] == null)
            {
                var attribute = instruction.OwnerDocument.CreateAttribute(name);
                attribute.Value = instruction.Value;
                element.Attributes.Append(attribute);
                element.RemoveChild(instruction);
            }
        }
Example #17
0
File: Replace.cs Project: rh/mix
 protected override void ExecuteCore(XmlProcessingInstruction instruction)
 {
     instruction.Value = DoReplace(instruction.Value);
 }
Example #18
0
		public override XmlNode CloneNode (bool deep)
		{
			XmlNode n = new XmlProcessingInstruction (target, data, OwnerDocument);
			return n;
		}
Example #19
0
        private XmlNode LoadEntityChildren()
        {
            XmlNode node = null;

            // We do not use creator functions on XmlDocument, b/c we do not want to let users extend the nodes that are children of entity nodes (also, if we do
            // this, XmlDataDocument will have a problem, b/c they do not know that those nodes should not be mapped).
            switch (reader.NodeType)
            {
            case XmlNodeType.EndElement:
            case XmlNodeType.EndEntity:
                break;

            case XmlNodeType.Element: {
                bool fEmptyElement = reader.IsEmptyElement;

                XmlElement element = new XmlElement(reader.Prefix, reader.LocalName, reader.NamespaceURI, this.doc);
                element.IsEmpty = fEmptyElement;

                while (reader.MoveToNextAttribute())
                {
                    XmlAttribute attr = (XmlAttribute)LoadEntityChildren();
                    element.Attributes.Append(attr);
                }

                // recursively load all children.
                if (!fEmptyElement)
                {
                    LoadEntityChildren(element);
                }

                node = element;
                break;
            }

            case XmlNodeType.Attribute:
                if (reader.IsDefault)
                {
                    XmlUnspecifiedAttribute attr = new XmlUnspecifiedAttribute(reader.Prefix, reader.LocalName, reader.NamespaceURI, this.doc);
                    LoadEntityAttributeChildren(attr);
                    attr.SetSpecified(false);
                    node = attr;
                }
                else
                {
                    XmlAttribute attr = new XmlAttribute(reader.Prefix, reader.LocalName, reader.NamespaceURI, this.doc);
                    LoadEntityAttributeChildren(attr);
                    node = attr;
                }
                break;

            case XmlNodeType.SignificantWhitespace:
                node = new XmlSignificantWhitespace(reader.Value, this.doc);
                break;

            case XmlNodeType.Whitespace:
                if (preserveWhitespace)
                {
                    node = new XmlWhitespace(reader.Value, this.doc);
                }
                else
                {
                    // if preserveWhitespace is false skip all subsequent WS nodes and position on the first non-WS node
                    do
                    {
                        if (!reader.Read())
                        {
                            return(null);
                        }
                    } while (reader.NodeType == XmlNodeType.Whitespace);
                    node = LoadEntityChildren();       // Skip WS node if preserveWhitespace is false
                }
                break;

            case XmlNodeType.Text:
                node = new XmlText(reader.Value, this.doc);
                break;

            case XmlNodeType.CDATA:
                node = new XmlCDataSection(reader.Value, this.doc);
                break;

            case XmlNodeType.EntityReference: {
                XmlEntityReference eref = new XmlEntityReference(reader.Name, this.doc);
                if (reader.CanResolveEntity)
                {
                    reader.ResolveEntity();
                    LoadEntityChildren(eref);
                    //what if eref doesn't have children at all? should we just put a Empty String text here?
                    if (eref.ChildNodes.Count == 0)
                    {
                        eref.AppendChild(new XmlText(""));
                    }
                }
                node = eref;
                break;
            }

            case XmlNodeType.ProcessingInstruction:
                node = new XmlProcessingInstruction(reader.Name, reader.Value, this.doc);
                break;

            case XmlNodeType.Comment:
                node = new XmlComment(reader.Value, this.doc);
                break;

            default:
                throw new InvalidOperationException(string.Format(Res.GetString(Res.Xdom_Load_NodeType), reader.NodeType.ToString()));
            }

            return(node);
        }
		private void ProcessElseElement(XmlProcessingInstruction pi, IXmlProcessorEngine engine, ref StatementState state)
		{
			AssertData(pi, pi.Name == ElsifPiName);

			if (state == StatementState.Collect)
			{
				state = StatementState.Finished;
			}
			else if (pi.Name == ElsePiName || engine.HasFlag(pi.Data))
			{
				if (state == StatementState.Init)
				{
					state = StatementState.Collect;
				}
			}

			RemoveItSelf(pi);
			return;
		}
		public void InnerAndOuterXml ()
		{
			pi = document.CreateProcessingInstruction ("foo", "bar");
			AssertEquals (String.Empty, pi.InnerXml);
			AssertEquals ("<?foo bar?>", pi.OuterXml);
		}
Example #22
0
        private XmlNode LoadEntityChildren() {
            XmlNode node = null;

            // We do not use creator functions on XmlDocument, b/c we do not want to let users extend the nodes that are children of entity nodes (also, if we do
            // this, XmlDataDocument will have a problem, b/c they do not know that those nodes should not be mapped).
            switch (reader.NodeType) {
                case XmlNodeType.EndElement:
                case XmlNodeType.EndEntity:
                    break;

                case XmlNodeType.Element: {
                    bool fEmptyElement = reader.IsEmptyElement;

                    XmlElement element = new XmlElement( reader.Prefix, reader.LocalName, reader.NamespaceURI, this.doc );
                    element.IsEmpty = fEmptyElement;

                    while(reader.MoveToNextAttribute()) {
                        XmlAttribute attr = (XmlAttribute) LoadEntityChildren();
                        element.Attributes.Append( attr );
                    }

                    // recursively load all children.
                    if (! fEmptyElement)
                        LoadEntityChildren( element );

                    node = element;
                    break;
                }

                case XmlNodeType.Attribute:
                    if (reader.IsDefault) {
                        XmlUnspecifiedAttribute attr = new XmlUnspecifiedAttribute( reader.Prefix, reader.LocalName, reader.NamespaceURI, this.doc );
                        LoadEntityAttributeChildren( attr );
                        attr.SetSpecified( false );
                        node = attr;
                    }
                    else {
                        XmlAttribute attr = new XmlAttribute( reader.Prefix, reader.LocalName, reader.NamespaceURI, this.doc );
                        LoadEntityAttributeChildren( attr );
                        node = attr;
                    }
                    break;

                case XmlNodeType.SignificantWhitespace:
                    node = new XmlSignificantWhitespace( reader.Value, this.doc );
                    break;

                case XmlNodeType.Whitespace:
                    if ( preserveWhitespace )
                        node = new XmlWhitespace( reader.Value, this.doc );
                    else {
                        // if preserveWhitespace is false skip all subsequent WS nodes and position on the first non-WS node
                        do {
                            if (! reader.Read() )
                                return null;
                        } while (reader.NodeType == XmlNodeType.Whitespace);
                        node = LoadEntityChildren();   // Skip WS node if preserveWhitespace is false
                    }
                    break;

                case XmlNodeType.Text:
                    node = new XmlText( reader.Value, this.doc );
                    break;

                case XmlNodeType.CDATA:
                    node = new XmlCDataSection( reader.Value, this.doc );
                    break;

                case XmlNodeType.EntityReference:{
                    XmlEntityReference eref = new XmlEntityReference( reader.Name, this.doc );
                    if ( reader.CanResolveEntity ) {
                        reader.ResolveEntity();
                        LoadEntityChildren( eref );
                        //what if eref doesn't have children at all? should we just put a Empty String text here?
                        if ( eref.ChildNodes.Count == 0 )
                            eref.AppendChild( new XmlText("") );
                    }
                    node = eref;
                    break;
                }

                case XmlNodeType.ProcessingInstruction:
                    node = new XmlProcessingInstruction( reader.Name, reader.Value, this.doc );
                    break;

                case XmlNodeType.Comment:
                    node = new XmlComment( reader.Value, this.doc );
                    break;

                default:
                    throw new InvalidOperationException(string.Format(Res.GetString(Res.Xdom_Load_NodeType),reader.NodeType.ToString()));
            }

            return node;
        }
Example #23
0
 protected override void ExecuteCore(XmlProcessingInstruction instruction)
 {
     instruction.Value = Transform(instruction.Value);
 }
Example #24
0
 /// <summary>
 /// Constructor for CssStyleSheet
 /// </summary>
 /// <param name="pi">The XML processing instruction that references the stylesheet</param>
 /// <param name="origin">The type of stylesheet</param>
 internal CssStyleSheet(XmlProcessingInstruction pi, CssStyleSheetType origin)
     : base(pi)
 {
     Origin = origin;
 }
		private void AssertData(XmlProcessingInstruction pi, bool requireData)
		{
			String data = pi.Data.Trim();

			if (data == "" && requireData)
			{
				throw new XmlProcessorException("Element '{0}' must have a flag attribute", pi.Name);
			}
			else if (data != "")
			{
				if (!requireData)
				{
					throw new XmlProcessorException("Element '{0}' cannot have any attributes", pi.Name);
				}
			}
		}
        /// <summary>
        /// Compares properties of a processing instruction.
        /// </summary>
        private ComparisonResult CompareProcessingInstructions(XmlProcessingInstruction control,
                                          XPathContext controlContext,
                                          XmlProcessingInstruction test,
                                          XPathContext testContext)
        {
            ComparisonResult lastResult =
                Compare(new Comparison(ComparisonType.PROCESSING_INSTRUCTION_TARGET,
                                       control, GetXPath(controlContext),
                                       control.Target,
                                       test, GetXPath(testContext),
                                       test.Target));
            if (lastResult == ComparisonResult.CRITICAL) {
                return lastResult;
            }

            return Compare(new Comparison(ComparisonType.PROCESSING_INSTRUCTION_DATA,
                                          control, GetXPath(controlContext),
                                          control.Data,
                                          test, GetXPath(testContext),
                                          test.Data));
        }
Example #27
0
        private XmlNode LoadNodeDirect()
        {
            XmlNode   node2;
            XmlReader reader     = this.reader;
            XmlNode   parentNode = null;

Label_0009:
            node2 = null;
            switch (reader.NodeType)
            {
            case XmlNodeType.Element:
            {
                bool       isEmptyElement = this.reader.IsEmptyElement;
                XmlElement newChild       = new XmlElement(this.reader.Prefix, this.reader.LocalName, this.reader.NamespaceURI, this.doc)
                {
                    IsEmpty = isEmptyElement
                };
                if (this.reader.MoveToFirstAttribute())
                {
                    XmlAttributeCollection attributes = newChild.Attributes;
                    do
                    {
                        XmlAttribute attribute = this.LoadAttributeNodeDirect();
                        attributes.Append(attribute);
                    }while (reader.MoveToNextAttribute());
                }
                if (!isEmptyElement)
                {
                    parentNode.AppendChildForLoad(newChild, this.doc);
                    parentNode = newChild;
                    goto Label_01FC;
                }
                node2 = newChild;
                break;
            }

            case XmlNodeType.Attribute:
                node2 = this.LoadAttributeNodeDirect();
                break;

            case XmlNodeType.Text:
                node2 = new XmlText(this.reader.Value, this.doc);
                break;

            case XmlNodeType.CDATA:
                node2 = new XmlCDataSection(this.reader.Value, this.doc);
                break;

            case XmlNodeType.EntityReference:
                node2 = this.LoadEntityReferenceNode(true);
                break;

            case XmlNodeType.ProcessingInstruction:
                node2 = new XmlProcessingInstruction(this.reader.Name, this.reader.Value, this.doc);
                break;

            case XmlNodeType.Comment:
                node2 = new XmlComment(this.reader.Value, this.doc);
                break;

            case XmlNodeType.Whitespace:
                if (!this.preserveWhitespace)
                {
                    goto Label_01FC;
                }
                node2 = new XmlWhitespace(this.reader.Value, this.doc);
                break;

            case XmlNodeType.SignificantWhitespace:
                node2 = new XmlSignificantWhitespace(this.reader.Value, this.doc);
                break;

            case XmlNodeType.EndElement:
                if (parentNode.ParentNode != null)
                {
                    parentNode = parentNode.ParentNode;
                    goto Label_01FC;
                }
                return(parentNode);

            case XmlNodeType.EndEntity:
                goto Label_01FC;

            default:
                throw UnexpectedNodeType(this.reader.NodeType);
            }
            if (parentNode != null)
            {
                parentNode.AppendChildForLoad(node2, this.doc);
            }
            else
            {
                return(node2);
            }
Label_01FC:
            if (reader.Read())
            {
                goto Label_0009;
            }
            return(null);
        }
Example #28
0
 protected override void ExecuteCore(XmlProcessingInstruction instruction)
 {
     var section = instruction.OwnerDocument.CreateCDataSection(instruction.Value);
     instruction.ParentNode.ReplaceChild(section, instruction);
 }
Example #29
0
        /// <summary>
        /// 执行sql
        /// </summary>
        /// <param name="strSql"></param>
        /// <param name="strDataSet"></param>
        /// <returns></returns>
        public int ExecQuery(string strSql, ref string strDataSet, string strXSLFileName)
        {
            //[2007/12/01]新增
            CloseRead();
            // end;

            //[2008/03/13]
            //if (reader != null)
            //{
            //    if (!reader.IsClosed)
            //    {
            //        reader.Close();
            //    }
            //}
            // end;


            this.command.Connection  = this.con as IBM.Data.DB2.DB2Connection;
            this.command.CommandType = System.Data.CommandType.Text;
            this.command.Parameters.Clear();
            this.command.CommandText = strSql + "";
            try
            {
                TempReader1 = this.command.ExecuteReader();
                XmlDocument doc = new XmlDocument();
                XmlNode     root;
                XmlElement  node, row;
                doc.AppendChild(doc.CreateXmlDeclaration("1.0", "GB2312", ""));
                if (strXSLFileName != null && strXSLFileName != "")
                {
                    string PI = "type='text/xsl' href='" + strXSLFileName + "'";
                    System.Xml.XmlProcessingInstruction xmlProcessingInstruction = doc.CreateProcessingInstruction("xml-stylesheet", PI);
                    doc.AppendChild(xmlProcessingInstruction);
                }
                root = doc.CreateElement("Table");
                doc.AppendChild(root);
                while (TempReader1.Read())
                {
                    row = doc.CreateElement("Row");
                    for (int i = 0; i < TempReader1.FieldCount; i++)
                    {
                        node = doc.CreateElement("Column");
                        node.SetAttribute("Name", TempReader1.GetName(i).ToString());
                        node.InnerText = TempReader1[i].ToString() + "";
                        row.AppendChild(node);
                    }
                    root.AppendChild(row);
                }
                strDataSet = doc.OuterXml;
                TempReader1.Close();
            }
            catch (IBM.Data.DB2.DB2Exception ex)
            {
                this.Err       = "执行产生错误!" + ex.Message;
                this.ErrCode   = strSql;
                this.DBErrCode = 1;
                this.WriteErr();
                return(-1);
            }
            catch (Exception ex)
            {
                this.Err            = "执行语句产生错误!" + ex.Message;
                this.ErrorException = ex.InnerException + "+ " + ex.Source;
                this.ErrCode        = strSql;
                this.WriteErr();
                return(-1);
            }

            WriteDebug("执行查询sql语句!" + strSql);
            return(0);
        }
Example #30
0
 public EditProcessingInstructionName(XmlProcessingInstruction pi, NodeLabelEditEventArgs e)
 {
     this.pi = pi;
     this.p = this.pi.ParentNode;
     this.node = e.Node as XmlTreeNode;
     Debug.Assert(this.p != null);
     name = e.Label;
     this.newpi = pi.OwnerDocument.CreateProcessingInstruction(name, pi.Data);
 }
        public override XmlNode CloneNode(bool deep)
        {
            XmlNode n = new XmlProcessingInstruction(target, data, OwnerDocument);

            return(n);
        }
Example #32
0
 public EditProcessingInstructionName(XmlTreeNode node, string newName)
 {
     this.pi = (XmlProcessingInstruction)node.Node;
     this.p = this.pi.ParentNode;
     this.node = node;
     Debug.Assert(this.p != null);
     name = newName;
     this.newpi = pi.OwnerDocument.CreateProcessingInstruction(name, pi.Data);
 }
Example #33
0
File: Remove.cs Project: rh/mix
 protected override void ExecuteCore(XmlProcessingInstruction instruction)
 {
     instruction.ParentNode.RemoveChild(instruction);
 }
Example #34
0
 public void Swap(XmlProcessingInstruction op, XmlProcessingInstruction np)
 {
     this.p.InsertBefore(np, op );
     this.p.RemoveChild(op);
     this.node.Node = np;
     this.node.Label = np.Target;
     this.node.TreeView.SelectedNode = this.node;
 }
Example #35
0
        // LoadNodeDirect does not use creator functions on XmlDocument. It is used loading nodes that are children of entity nodes,
        // because we do not want to let users extend these (if we would allow this, XmlDataDocument would have a problem, because
        // they do not know that those nodes should not be mapped). It can be also used for an optimized load path when if the
        // XmlDocument is not extended if XmlDocumentType and XmlDeclaration handling is added.
        private XmlNode LoadNodeDirect()
        {
            XmlReader r      = _reader;
            XmlNode   parent = null;

            do
            {
                XmlNode node = null;
                switch (r.NodeType)
                {
                case XmlNodeType.Element:
                    bool       fEmptyElement = _reader.IsEmptyElement;
                    XmlElement element       = new XmlElement(_reader.Prefix, _reader.LocalName, _reader.NamespaceURI, _doc);
                    element.IsEmpty = fEmptyElement;

                    if (_reader.MoveToFirstAttribute())
                    {
                        XmlAttributeCollection attributes = element.Attributes;
                        do
                        {
                            XmlAttribute attr = LoadAttributeNodeDirect();
                            attributes.Append(attr);     // special case for load
                        } while (r.MoveToNextAttribute());
                    }

                    // recursively load all children.
                    if (!fEmptyElement)
                    {
                        parent.AppendChildForLoad(element, _doc);
                        parent = element;
                        continue;
                    }
                    else
                    {
                        node = element;
                        break;
                    }

                case XmlNodeType.EndElement:
                    Debug.Assert(parent.NodeType == XmlNodeType.Element);
                    if (parent.ParentNode == null)
                    {
                        return(parent);
                    }
                    parent = parent.ParentNode;
                    continue;

                case XmlNodeType.EntityReference:
                    node = LoadEntityReferenceNode(true);
                    break;

                case XmlNodeType.EndEntity:
                    continue;

                case XmlNodeType.Attribute:
                    node = LoadAttributeNodeDirect();
                    break;

                case XmlNodeType.SignificantWhitespace:
                    node = new XmlSignificantWhitespace(_reader.Value, _doc);
                    break;

                case XmlNodeType.Whitespace:
                    if (_preserveWhitespace)
                    {
                        node = new XmlWhitespace(_reader.Value, _doc);
                    }
                    else
                    {
                        continue;
                    }
                    break;

                case XmlNodeType.Text:
                    node = new XmlText(_reader.Value, _doc);
                    break;

                case XmlNodeType.CDATA:
                    node = new XmlCDataSection(_reader.Value, _doc);
                    break;

                case XmlNodeType.ProcessingInstruction:
                    node = new XmlProcessingInstruction(_reader.Name, _reader.Value, _doc);
                    break;

                case XmlNodeType.Comment:
                    node = new XmlComment(_reader.Value, _doc);
                    break;

                default:
                    throw UnexpectedNodeType(_reader.NodeType);
                }

                Debug.Assert(node != null);
                if (parent != null)
                {
                    parent.AppendChildForLoad(node, _doc);
                }
                else
                {
                    return(node);
                }
            }while (r.Read());

            return(null);
        }
 public DocumentInformation(XmlProcessingInstruction instruction)
 {
     Source = instruction;
     CurrentVersion = int.Parse(instruction.Value);
 }