コード例 #1
0
        public void ApplyImports()
        {
            XslTemplate currentTemplate = (XslTemplate)currentTemplateStack.Peek();

            if (currentTemplate == null)
            {
                throw new XsltException("Invalid context for apply-imports", null, CurrentNode);
            }
            XslTemplate t;

            for (int i = currentTemplate.Parent.Imports.Count - 1; i >= 0; i--)
            {
                XslStylesheet s = (XslStylesheet)currentTemplate.Parent.Imports [i];
                t = s.Templates.FindMatch(CurrentNode, currentTemplate.Mode, this);
                if (t != null)
                {
                    currentTemplateStack.Push(t);
                    t.Evaluate(this);
                    currentTemplateStack.Pop();
                    return;
                }
            }

            switch (CurrentNode.NodeType)
            {
            case XPathNodeType.Root:
            case XPathNodeType.Element:
                if (currentTemplate.Mode == QName.Empty)
                {
                    t = XslDefaultNodeTemplate.Instance;
                }
                else
                {
                    t = new XslDefaultNodeTemplate(currentTemplate.Mode);
                }

                break;

            case XPathNodeType.Attribute:
            case XPathNodeType.SignificantWhitespace:
            case XPathNodeType.Text:
            case XPathNodeType.Whitespace:
                t = XslDefaultTextTemplate.Instance;
                break;

            case XPathNodeType.Comment:
            case XPathNodeType.ProcessingInstruction:
                t = XslEmptyTemplate.Instance;
                break;

            default:
                t = XslEmptyTemplate.Instance;
                break;
            }
            currentTemplateStack.Push(t);
            t.Evaluate(this);
            currentTemplateStack.Pop();
        }
コード例 #2
0
		public void ApplyImports()
		{
			XslTemplate xslTemplate = (XslTemplate)this.currentTemplateStack.Peek();
			if (xslTemplate == null)
			{
				throw new XsltException("Invalid context for apply-imports", null, this.CurrentNode);
			}
			XslTemplate xslTemplate2;
			for (int i = xslTemplate.Parent.Imports.Count - 1; i >= 0; i--)
			{
				XslStylesheet xslStylesheet = (XslStylesheet)xslTemplate.Parent.Imports[i];
				xslTemplate2 = xslStylesheet.Templates.FindMatch(this.CurrentNode, xslTemplate.Mode, this);
				if (xslTemplate2 != null)
				{
					this.currentTemplateStack.Push(xslTemplate2);
					xslTemplate2.Evaluate(this);
					this.currentTemplateStack.Pop();
					return;
				}
			}
			switch (this.CurrentNode.NodeType)
			{
			case XPathNodeType.Root:
			case XPathNodeType.Element:
				if (xslTemplate.Mode == XmlQualifiedName.Empty)
				{
					xslTemplate2 = XslDefaultNodeTemplate.Instance;
				}
				else
				{
					xslTemplate2 = new XslDefaultNodeTemplate(xslTemplate.Mode);
				}
				goto IL_131;
			case XPathNodeType.Attribute:
			case XPathNodeType.Text:
			case XPathNodeType.SignificantWhitespace:
			case XPathNodeType.Whitespace:
				xslTemplate2 = XslDefaultTextTemplate.Instance;
				goto IL_131;
			case XPathNodeType.ProcessingInstruction:
			case XPathNodeType.Comment:
				xslTemplate2 = XslEmptyTemplate.Instance;
				goto IL_131;
			}
			xslTemplate2 = XslEmptyTemplate.Instance;
			IL_131:
			this.currentTemplateStack.Push(xslTemplate2);
			xslTemplate2.Evaluate(this);
			this.currentTemplateStack.Pop();
		}
コード例 #3
0
ファイル: XslTransformProcessor.cs プロジェクト: nobled/mono
		public void ApplyImports ()
		{	

			XslTemplate currentTemplate = (XslTemplate)currentTemplateStack.Peek();
			if (currentTemplate == null)
				throw new XsltException ("Invalid context for apply-imports", null, CurrentNode);
			XslTemplate t;
			
			for (int i = currentTemplate.Parent.Imports.Count - 1; i >= 0; i--) {
				XslStylesheet s = (XslStylesheet)currentTemplate.Parent.Imports [i];
				t = s.Templates.FindMatch (CurrentNode, currentTemplate.Mode, this);
				if (t != null) {					
					currentTemplateStack.Push (t);
					t.Evaluate (this);
					currentTemplateStack.Pop ();
					return;
				}
			}
			
			switch (CurrentNode.NodeType) {
			case XPathNodeType.Root:
			case XPathNodeType.Element:
				if (currentTemplate.Mode == QName.Empty)
					t = XslDefaultNodeTemplate.Instance;
				else
					t = new XslDefaultNodeTemplate(currentTemplate.Mode);
			
				break;
			case XPathNodeType.Attribute:
			case XPathNodeType.SignificantWhitespace:
			case XPathNodeType.Text:
			case XPathNodeType.Whitespace:
				t = XslDefaultTextTemplate.Instance;
				break;
			
			case XPathNodeType.Comment:
			case XPathNodeType.ProcessingInstruction:
				t = XslEmptyTemplate.Instance;
				break;
			
			default:
				t = XslEmptyTemplate.Instance;
				break;
			}
			currentTemplateStack.Push (t);
			t.Evaluate (this);
			currentTemplateStack.Pop ();
		}