Esempio n. 1
0
        public override void Evaluate(XslTransformProcessor p)
        {
            if (p.Debugger != null)
            {
                p.Debugger.DebugExecute(p, base.DebugInput);
            }
            string           text             = (this.calcName == null) ? this.name.Evaluate(p) : this.calcName;
            string           text2            = (this.calcNs == null) ? ((this.ns == null) ? null : this.ns.Evaluate(p)) : this.calcNs;
            XmlQualifiedName xmlQualifiedName = XslNameUtil.FromString(text, this.nsDecls);
            string           text3            = xmlQualifiedName.Name;

            if (text2 == null)
            {
                text2 = xmlQualifiedName.Namespace;
            }
            int num = text.IndexOf(':');

            if (num > 0)
            {
                this.calcPrefix = text.Substring(0, num);
            }
            else if (num == 0)
            {
                XmlConvert.VerifyNCName(string.Empty);
            }
            string text4 = (this.calcPrefix == null) ? string.Empty : this.calcPrefix;

            if (text4 != string.Empty)
            {
                XmlConvert.VerifyNCName(text4);
            }
            XmlConvert.VerifyNCName(text3);
            bool insideCDataElement = p.InsideCDataElement;

            p.PushElementState(text4, text3, text2, false);
            p.Out.WriteStartElement(text4, text3, text2);
            if (this.useAttributeSets != null)
            {
                foreach (XmlQualifiedName xmlQualifiedName2 in this.useAttributeSets)
                {
                    p.ResolveAttributeSet(xmlQualifiedName2).Evaluate(p);
                }
            }
            if (this.value != null)
            {
                this.value.Evaluate(p);
            }
            if (this.isEmptyElement && this.useAttributeSets == null)
            {
                p.Out.WriteEndElement();
            }
            else
            {
                p.Out.WriteFullEndElement();
            }
            p.PopCDataState(insideCDataElement);
        }
Esempio n. 2
0
        public override void Evaluate(XslTransformProcessor p)
        {
            if (p.Debugger != null)
            {
                p.Debugger.DebugExecute(p, this.DebugInput);
            }

            // Since namespace-alias might be determined after compilation
            // of import-ing stylesheets, this must be determined later.
            bool isCData = p.InsideCDataElement;

            p.PushElementState(prefix, localname, nsUri, true);
            p.Out.WriteStartElement(prefix, localname, nsUri);

            if (useAttributeSets != null)
            {
                foreach (XmlQualifiedName s in useAttributeSets)
                {
                    p.ResolveAttributeSet(s).Evaluate(p);
                }
            }

            if (attrs != null)
            {
                int len = attrs.Count;
                for (int i = 0; i < len; i++)
                {
                    ((XslLiteralAttribute)attrs [i]).Evaluate(p);
                }
            }

            p.OutputLiteralNamespaceUriNodes(nsDecls, null, null);

            if (children != null)
            {
                children.Evaluate(p);
            }

            var templateContent = children as XslTemplateContent;

            if (isEmptyElement || (templateContent != null && templateContent.IsEmptyElement))
            {
                p.Out.WriteEndElement();
            }
            else
            {
                p.Out.WriteFullEndElement();
            }

            p.PopCDataState(isCData);
        }
        public override void Evaluate(XslTransformProcessor p)
        {
            if (p.Debugger != null)
            {
                p.Debugger.DebugExecute(p, base.DebugInput);
            }
            bool insideCDataElement = p.InsideCDataElement;

            p.PushElementState(this.prefix, this.localname, this.nsUri, true);
            p.Out.WriteStartElement(this.prefix, this.localname, this.nsUri);
            if (this.useAttributeSets != null)
            {
                foreach (XmlQualifiedName name in this.useAttributeSets)
                {
                    p.ResolveAttributeSet(name).Evaluate(p);
                }
            }
            if (this.attrs != null)
            {
                int count = this.attrs.Count;
                for (int j = 0; j < count; j++)
                {
                    ((XslLiteralElement.XslLiteralAttribute) this.attrs[j]).Evaluate(p);
                }
            }
            p.OutputLiteralNamespaceUriNodes(this.nsDecls, null, null);
            if (this.children != null)
            {
                this.children.Evaluate(p);
            }
            if (this.isEmptyElement)
            {
                p.Out.WriteEndElement();
            }
            else
            {
                p.Out.WriteFullEndElement();
            }
            p.PopCDataState(insideCDataElement);
        }
Esempio n. 4
0
		public override void Evaluate (XslTransformProcessor p)
		{
			if (p.Debugger != null)
				p.Debugger.DebugExecute (p, this.DebugInput);

			XPathNavigator nav = p.CurrentNode;
			switch (nav.NodeType)
			{
			case XPathNodeType.Root:
				if (p.Out.CanProcessAttributes && useAttributeSets != null)
					foreach (XmlQualifiedName s in useAttributeSets) {
						XslAttributeSet attset = p.ResolveAttributeSet (s);
						if (attset == null)
							throw new XsltException ("Attribute set was not found", null, nav);
						attset.Evaluate (p);
					}

				if (children != null) children.Evaluate (p);
				break;
			case XPathNodeType.Element:
				bool isCData = p.InsideCDataElement;
				string prefix = nav.Prefix;
				p.PushElementState (prefix, nav.LocalName, nav.NamespaceURI, true);
				p.Out.WriteStartElement (prefix, nav.LocalName, nav.NamespaceURI);
				
				if (useAttributeSets != null)
					foreach (XmlQualifiedName s in useAttributeSets)
						p.ResolveAttributeSet (s).Evaluate (p);

				if (nav.MoveToFirstNamespace (XPathNamespaceScope.ExcludeXml)) {
					do {
						if (nav.LocalName == prefix)
							continue;
						p.Out.WriteNamespaceDecl (nav.LocalName, nav.Value);
					} while (nav.MoveToNextNamespace (XPathNamespaceScope.ExcludeXml));
					nav.MoveToParent ();
				}

				if (children != null) children.Evaluate (p);

				p.Out.WriteFullEndElement ();
				p.PopCDataState (isCData);
				break;
			case XPathNodeType.Attribute:
				p.Out.WriteAttributeString (nav.Prefix, nav.LocalName, nav.NamespaceURI, nav.Value);
				break;
			
			case XPathNodeType.SignificantWhitespace:
			case XPathNodeType.Whitespace:
				bool cdata = p.Out.InsideCDataSection;
				p.Out.InsideCDataSection = false;
				p.Out.WriteString (nav.Value);
				p.Out.InsideCDataSection = cdata;
				break;
			case XPathNodeType.Text:
				p.Out.WriteString (nav.Value);
				break;
			
			case XPathNodeType.Comment:
				p.Out.WriteComment (nav.Value);
				break;
			
			case XPathNodeType.ProcessingInstruction:
				p.Out.WriteProcessingInstruction (nav.Name, nav.Value);
				break;

			case XPathNodeType.Namespace:
				if (p.XPathContext.ElementPrefix != nav.Name)
					p.Out.WriteNamespaceDecl (nav.Name, nav.Value);
				break;

			default:
//				Console.WriteLine ("unhandled node type {0}", nav.NodeType);
				break;
			}
		}
Esempio n. 5
0
        public override void Evaluate(XslTransformProcessor p)
        {
            if (p.Debugger != null)
            {
                p.Debugger.DebugExecute(p, this.DebugInput);
            }

            XPathNavigator nav = p.CurrentNode;

            switch (nav.NodeType)
            {
            case XPathNodeType.Root:
                if (p.Out.CanProcessAttributes && useAttributeSets != null)
                {
                    foreach (XmlQualifiedName s in useAttributeSets)
                    {
                        XslAttributeSet attset = p.ResolveAttributeSet(s);
                        if (attset == null)
                        {
                            throw new XsltException("Attribute set was not found", null, nav);
                        }
                        attset.Evaluate(p);
                    }
                }

                if (children != null)
                {
                    children.Evaluate(p);
                }
                break;

            case XPathNodeType.Element:
                bool   isCData = p.InsideCDataElement;
                string prefix  = nav.Prefix;
                p.PushElementState(prefix, nav.LocalName, nav.NamespaceURI, true);
                p.Out.WriteStartElement(prefix, nav.LocalName, nav.NamespaceURI);

                if (useAttributeSets != null)
                {
                    foreach (XmlQualifiedName s in useAttributeSets)
                    {
                        p.ResolveAttributeSet(s).Evaluate(p);
                    }
                }

                if (nav.MoveToFirstNamespace(XPathNamespaceScope.ExcludeXml))
                {
                    do
                    {
                        if (nav.LocalName == prefix)
                        {
                            continue;
                        }
                        p.Out.WriteNamespaceDecl(nav.LocalName, nav.Value);
                    } while (nav.MoveToNextNamespace(XPathNamespaceScope.ExcludeXml));
                    nav.MoveToParent();
                }

                if (children != null)
                {
                    children.Evaluate(p);
                }

                p.Out.WriteFullEndElement();
                p.PopCDataState(isCData);
                break;

            case XPathNodeType.Attribute:
                p.Out.WriteAttributeString(nav.Prefix, nav.LocalName, nav.NamespaceURI, nav.Value);
                break;

            case XPathNodeType.SignificantWhitespace:
            case XPathNodeType.Whitespace:
                bool cdata = p.Out.InsideCDataSection;
                p.Out.InsideCDataSection = false;
                p.Out.WriteString(nav.Value);
                p.Out.InsideCDataSection = cdata;
                break;

            case XPathNodeType.Text:
                p.Out.WriteString(nav.Value);
                break;

            case XPathNodeType.Comment:
                p.Out.WriteComment(nav.Value);
                break;

            case XPathNodeType.ProcessingInstruction:
                p.Out.WriteProcessingInstruction(nav.Name, nav.Value);
                break;

            case XPathNodeType.Namespace:
                if (p.XPathContext.ElementPrefix != nav.Name)
                {
                    p.Out.WriteNamespaceDecl(nav.Name, nav.Value);
                }
                break;

            default:
//				Console.WriteLine ("unhandled node type {0}", nav.NodeType);
                break;
            }
        }
Esempio n. 6
0
        public override void Evaluate(XslTransformProcessor p)
        {
            if (p.Debugger != null)
            {
                p.Debugger.DebugExecute(p, this.DebugInput);
            }

            string nm, nmsp, localName, prefix;

            localName = nm = calcName != null ? calcName : name.Evaluate(p);
            nmsp      = calcNs != null ? calcNs : ns != null?ns.Evaluate(p) : null;

            QName q = XslNameUtil.FromString(nm, nsDecls);

            localName = q.Name;
            if (nmsp == null)
            {
                nmsp = q.Namespace;
            }
            int colonAt = nm.IndexOf(':');

            if (colonAt > 0)
            {
                calcPrefix = nm.Substring(0, colonAt);
            }
            else if (colonAt == 0)
            {
                // raises an error
                XmlConvert.VerifyNCName(String.Empty);
            }

            prefix = calcPrefix != null ? calcPrefix : String.Empty;

            if (prefix != String.Empty)
            {
                XmlConvert.VerifyNCName(prefix);
            }
            XmlConvert.VerifyNCName(localName);

            bool isCData = p.InsideCDataElement;

            p.PushElementState(prefix, localName, nmsp, false);
            p.Out.WriteStartElement(prefix, localName, nmsp);

            if (useAttributeSets != null)
            {
                foreach (XmlQualifiedName s in useAttributeSets)
                {
                    p.ResolveAttributeSet(s).Evaluate(p);
                }
            }

            if (value != null)
            {
                value.Evaluate(p);
            }

            if (isEmptyElement && useAttributeSets == null)
            {
                p.Out.WriteEndElement();
            }
            else
            {
                p.Out.WriteFullEndElement();
            }
            p.PopCDataState(isCData);
        }
Esempio n. 7
0
		public override void Evaluate (XslTransformProcessor p)
		{
			if (p.Debugger != null)
				p.Debugger.DebugExecute (p, this.DebugInput);

			// Since namespace-alias might be determined after compilation
			// of import-ing stylesheets, this must be determined later.
			bool isCData = p.InsideCDataElement;
			p.PushElementState (prefix, localname, nsUri, true);
			p.Out.WriteStartElement (prefix, localname, nsUri);

			if (useAttributeSets != null)
				foreach (XmlQualifiedName s in useAttributeSets)
					p.ResolveAttributeSet (s).Evaluate (p);
						
			if (attrs != null) {
				int len = attrs.Count;
				for (int i = 0; i < len; i++)
					((XslLiteralAttribute)attrs [i]).Evaluate (p);
			}

			p.OutputLiteralNamespaceUriNodes (nsDecls, null, null);

			if (children != null) children.Evaluate (p);

			var templateContent = children as XslTemplateContent;
			if (isEmptyElement || (templateContent != null && templateContent.IsEmptyElement))
				p.Out.WriteEndElement ();
			else
				p.Out.WriteFullEndElement ();

			p.PopCDataState (isCData);
		}
Esempio n. 8
0
		public override void Evaluate (XslTransformProcessor p)
		{
			if (p.Debugger != null)
				p.Debugger.DebugExecute (p, this.DebugInput);

			string nm, nmsp, localName, prefix;
			
			localName = nm = calcName != null ? calcName : name.Evaluate (p);
			nmsp = calcNs != null ? calcNs : ns != null ? ns.Evaluate (p) : null;

			QName q = XslNameUtil.FromString (nm, nsDecls);
			localName = q.Name;
			if (nmsp == null)
				nmsp = q.Namespace;
			int colonAt = nm.IndexOf (':');
			if (colonAt > 0)
				calcPrefix = nm.Substring (0, colonAt);
			else if (colonAt == 0)
				// raises an error
				XmlConvert.VerifyNCName (String.Empty);

			prefix = calcPrefix != null ? calcPrefix : String.Empty;

			if (prefix != String.Empty)
				XmlConvert.VerifyNCName (prefix);
			XmlConvert.VerifyNCName (localName);

			bool isCData = p.InsideCDataElement;
			p.PushElementState (prefix, localName, nmsp, false);
			p.Out.WriteStartElement (prefix, localName, nmsp);

			if (useAttributeSets != null)
				foreach (XmlQualifiedName s in useAttributeSets)
					p.ResolveAttributeSet (s).Evaluate (p);

			if (value != null) value.Evaluate (p);

			if (isEmptyElement && useAttributeSets == null)
				p.Out.WriteEndElement ();
			else
				p.Out.WriteFullEndElement ();
			p.PopCDataState (isCData);
		}
Esempio n. 9
0
        public override void Evaluate(XslTransformProcessor p)
        {
            if (p.Debugger != null)
            {
                p.Debugger.DebugExecute(p, base.DebugInput);
            }
            XPathNavigator currentNode = p.CurrentNode;

            switch (currentNode.NodeType)
            {
            case XPathNodeType.Root:
                if (p.Out.CanProcessAttributes && this.useAttributeSets != null)
                {
                    foreach (XmlQualifiedName name in this.useAttributeSets)
                    {
                        XslAttributeSet xslAttributeSet = p.ResolveAttributeSet(name);
                        if (xslAttributeSet == null)
                        {
                            throw new XsltException("Attribute set was not found", null, currentNode);
                        }
                        xslAttributeSet.Evaluate(p);
                    }
                }
                if (this.children != null)
                {
                    this.children.Evaluate(p);
                }
                break;

            case XPathNodeType.Element:
            {
                bool   insideCDataElement = p.InsideCDataElement;
                string prefix             = currentNode.Prefix;
                p.PushElementState(prefix, currentNode.LocalName, currentNode.NamespaceURI, true);
                p.Out.WriteStartElement(prefix, currentNode.LocalName, currentNode.NamespaceURI);
                if (this.useAttributeSets != null)
                {
                    foreach (XmlQualifiedName name2 in this.useAttributeSets)
                    {
                        p.ResolveAttributeSet(name2).Evaluate(p);
                    }
                }
                if (currentNode.MoveToFirstNamespace(XPathNamespaceScope.ExcludeXml))
                {
                    do
                    {
                        if (!(currentNode.LocalName == prefix))
                        {
                            p.Out.WriteNamespaceDecl(currentNode.LocalName, currentNode.Value);
                        }
                    }while (currentNode.MoveToNextNamespace(XPathNamespaceScope.ExcludeXml));
                    currentNode.MoveToParent();
                }
                if (this.children != null)
                {
                    this.children.Evaluate(p);
                }
                p.Out.WriteFullEndElement();
                p.PopCDataState(insideCDataElement);
                break;
            }

            case XPathNodeType.Attribute:
                p.Out.WriteAttributeString(currentNode.Prefix, currentNode.LocalName, currentNode.NamespaceURI, currentNode.Value);
                break;

            case XPathNodeType.Namespace:
                if (p.XPathContext.ElementPrefix != currentNode.Name)
                {
                    p.Out.WriteNamespaceDecl(currentNode.Name, currentNode.Value);
                }
                break;

            case XPathNodeType.Text:
                p.Out.WriteString(currentNode.Value);
                break;

            case XPathNodeType.SignificantWhitespace:
            case XPathNodeType.Whitespace:
            {
                bool insideCDataSection = p.Out.InsideCDataSection;
                p.Out.InsideCDataSection = false;
                p.Out.WriteString(currentNode.Value);
                p.Out.InsideCDataSection = insideCDataSection;
                break;
            }

            case XPathNodeType.ProcessingInstruction:
                p.Out.WriteProcessingInstruction(currentNode.Name, currentNode.Value);
                break;

            case XPathNodeType.Comment:
                p.Out.WriteComment(currentNode.Value);
                break;
            }
        }