Esempio n. 1
0
			public TemplateWithPriority (XslTemplate t, Pattern p)
			{
				Template = t;
				Pattern = p;
				Priority = p.DefaultPriority;
				TemplateID = t.Id;
			}
Esempio n. 2
0
 public TemplateWithPriority(XslTemplate t, double p)
 {
     this.Template   = t;
     this.Pattern    = t.Match;
     this.Priority   = p;
     this.TemplateID = t.Id;
 }
 public TemplateWithPriority(XslTemplate t, Pattern p)
 {
     Template   = t;
     Pattern    = p;
     Priority   = p.DefaultPriority;
     TemplateID = t.Id;
 }
        public void Add(XslTemplate template)
        {
            if (template.Name != XmlQualifiedName.Empty)
            {
                if (namedTemplates [template.Name] != null)
                {
                    throw new InvalidOperationException("Named template " + template.Name + " is already registered.");
                }

                namedTemplates [template.Name] = template;
            }

            if (template.Match == null)
            {
                return;
            }

            XslModedTemplateTable tbl = this [template.Mode];

            if (tbl == null)
            {
                tbl = new XslModedTemplateTable(template.Mode);
                Add(tbl);
            }

            tbl.Add(template);
        }
Esempio n. 5
0
			public TemplateWithPriority (XslTemplate t, double p)
			{
				Template = t;
				Pattern = t.Match;
				Priority = p;
				TemplateID = t.Id;
			}
 public TemplateWithPriority(XslTemplate t, double p)
 {
     Template   = t;
     Pattern    = t.Match;
     Priority   = p;
     TemplateID = t.Id;
 }
Esempio n. 7
0
 public TemplateWithPriority(XslTemplate t, Pattern p)
 {
     this.Template   = t;
     this.Pattern    = p;
     this.Priority   = p.DefaultPriority;
     this.TemplateID = t.Id;
 }
		private XslTemplate FindTemplate(XPathNavigator node, XmlQualifiedName mode)
		{
			XslTemplate xslTemplate = this.style.Templates.FindMatch(this.CurrentNode, mode, this);
			if (xslTemplate != null)
			{
				return xslTemplate;
			}
			switch (node.NodeType)
			{
			case XPathNodeType.Root:
			case XPathNodeType.Element:
				if (mode == XmlQualifiedName.Empty)
				{
					return XslDefaultNodeTemplate.Instance;
				}
				return new XslDefaultNodeTemplate(mode);
			case XPathNodeType.Attribute:
			case XPathNodeType.Text:
			case XPathNodeType.SignificantWhitespace:
			case XPathNodeType.Whitespace:
				return XslDefaultTextTemplate.Instance;
			case XPathNodeType.ProcessingInstruction:
			case XPathNodeType.Comment:
				return XslEmptyTemplate.Instance;
			}
			return XslEmptyTemplate.Instance;
		}
Esempio n. 9
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();
        }
		private XslTemplate FindTemplate(XmlQualifiedName name)
		{
			XslTemplate xslTemplate = this.style.Templates.FindTemplate(name);
			if (xslTemplate != null)
			{
				return xslTemplate;
			}
			throw new XsltException("Could not resolve named template " + name, null, this.CurrentNode);
		}
Esempio n. 11
0
 public void Add(XslTemplate t, Pattern p)
 {
     if (p is UnionPattern)
     {
         this.Add(t, ((UnionPattern)p).p0);
         this.Add(t, ((UnionPattern)p).p1);
         return;
     }
     this.unnamedTemplates.Add(new XslModedTemplateTable.TemplateWithPriority(t, p));
 }
Esempio n. 12
0
        XslTemplate FindTemplate(QName name)
        {
            XslTemplate ret = style.Templates.FindTemplate(name);

            if (ret != null)
            {
                return(ret);
            }

            throw new XsltException("Could not resolve named template " + name, null, CurrentNode);
        }
        public void Add(XslTemplate t, Pattern p)
        {
            if (p is UnionPattern)
            {
                Add(t, ((UnionPattern)p).p0);
                Add(t, ((UnionPattern)p).p1);
                return;
            }

            unnamedTemplates.Add(new TemplateWithPriority(t, p));
        }
 public void Add(XslTemplate t)
 {
     if (!double.IsNaN(t.Priority))
     {
         unnamedTemplates.Add(new TemplateWithPriority(t, t.Priority));
     }
     else
     {
         Add(t, t.Match);
     }
 }
Esempio n. 15
0
 public void Add(XslTemplate t)
 {
     if (!double.IsNaN(t.Priority))
     {
         this.unnamedTemplates.Add(new XslModedTemplateTable.TemplateWithPriority(t, t.Priority));
     }
     else
     {
         this.Add(t, t.Match);
     }
 }
		public void CallTemplate(XmlQualifiedName name, ArrayList withParams)
		{
			Hashtable @params = this.GetParams(withParams);
			XslTemplate xslTemplate = this.FindTemplate(name);
			this.currentTemplateStack.Push(null);
			xslTemplate.Evaluate(this, @params);
			this.currentTemplateStack.Pop();
			if (@params != null)
			{
				this.paramPassingCache.Push(@params);
			}
		}
		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();
		}
Esempio n. 18
0
        public void CallTemplate(QName name, ArrayList withParams)
        {
            Hashtable passedParams = GetParams(withParams);

            XslTemplate t = FindTemplate(name);

            currentTemplateStack.Push(null);
            t.Evaluate(this, passedParams);
            currentTemplateStack.Pop();

            if (passedParams != null)
            {
                paramPassingCache.Push(passedParams);
            }
        }
		public void ApplyTemplates(XPathNodeIterator nodes, XmlQualifiedName mode, ArrayList withParams)
		{
			Hashtable @params = this.GetParams(withParams);
			while (this.NodesetMoveNext(nodes))
			{
				this.PushNodeset(nodes);
				XslTemplate xslTemplate = this.FindTemplate(this.CurrentNode, mode);
				this.currentTemplateStack.Push(xslTemplate);
				xslTemplate.Evaluate(this, @params);
				this.currentTemplateStack.Pop();
				this.PopNodeset();
			}
			if (@params != null)
			{
				this.paramPassingCache.Push(@params);
			}
		}
Esempio n. 20
0
        public XslTemplate FindTemplate(XmlQualifiedName name)
        {
            XslTemplate xslTemplate = (XslTemplate)this.namedTemplates[name];

            if (xslTemplate != null)
            {
                return(xslTemplate);
            }
            for (int i = this.parent.Imports.Count - 1; i >= 0; i--)
            {
                XslStylesheet xslStylesheet = (XslStylesheet)this.parent.Imports[i];
                xslTemplate = xslStylesheet.Templates.FindTemplate(name);
                if (xslTemplate != null)
                {
                    return(xslTemplate);
                }
            }
            return(null);
        }
Esempio n. 21
0
        public void ApplyTemplates(XPathNodeIterator nodes, QName mode, ArrayList withParams)
        {
            Hashtable passedParams = GetParams(withParams);

            while (NodesetMoveNext(nodes))
            {
                PushNodeset(nodes);
                XslTemplate t = FindTemplate(CurrentNode, mode);
                currentTemplateStack.Push(t);
                t.Evaluate(this, passedParams);
                currentTemplateStack.Pop();
                PopNodeset();
            }

            if (passedParams != null)
            {
                paramPassingCache.Push(passedParams);
            }
        }
Esempio n. 22
0
 public XslTemplate FindMatch(XPathNavigator node, XmlQualifiedName mode, XslTransformProcessor p)
 {
     if (this[mode] != null)
     {
         XslTemplate xslTemplate = this[mode].FindMatch(node, p);
         if (xslTemplate != null)
         {
             return(xslTemplate);
         }
     }
     for (int i = this.parent.Imports.Count - 1; i >= 0; i--)
     {
         XslStylesheet xslStylesheet = (XslStylesheet)this.parent.Imports[i];
         XslTemplate   xslTemplate   = xslStylesheet.Templates.FindMatch(node, mode, p);
         if (xslTemplate != null)
         {
             return(xslTemplate);
         }
     }
     return(null);
 }
        public XslTemplate FindTemplate(XmlQualifiedName name)
        {
            XslTemplate ret = (XslTemplate)namedTemplates [name];

            if (ret != null)
            {
                return(ret);
            }

            for (int i = parent.Imports.Count - 1; i >= 0; i--)
            {
                XslStylesheet s = (XslStylesheet)parent.Imports [i];
                ret = s.Templates.FindTemplate(name);
                if (ret != null)
                {
                    return(ret);
                }
            }

            return(null);
        }
Esempio n. 24
0
        XslTemplate FindTemplate(XPathNavigator node, QName mode)
        {
            XslTemplate ret = style.Templates.FindMatch(CurrentNode, mode, this);

            if (ret != null)
            {
                return(ret);
            }

            switch (node.NodeType)
            {
            case XPathNodeType.Root:
            case XPathNodeType.Element:
                if (mode == QName.Empty)
                {
                    return(XslDefaultNodeTemplate.Instance);
                }
                else
                {
                    return(new XslDefaultNodeTemplate(mode));
                }

            case XPathNodeType.Attribute:
            case XPathNodeType.SignificantWhitespace:
            case XPathNodeType.Text:
            case XPathNodeType.Whitespace:
                return(XslDefaultTextTemplate.Instance);

            case XPathNodeType.Comment:
            case XPathNodeType.ProcessingInstruction:
                return(XslEmptyTemplate.Instance);

            default:
                return(XslEmptyTemplate.Instance);
            }
        }
Esempio n. 25
0
		public void Add (XslTemplate t)
		{
			if (!double.IsNaN (t.Priority))
				unnamedTemplates.Add (new TemplateWithPriority (t, t.Priority));
			else
				Add (t, t.Match);
		}
Esempio n. 26
0
		public void Add (XslTemplate t, Pattern p)
		{
			if (p is UnionPattern) {
				Add (t, ((UnionPattern)p).p0);
				Add (t, ((UnionPattern)p).p1);
				return;
			}
			
			unnamedTemplates.Add (new TemplateWithPriority (t, p));
		}
Esempio n. 27
0
		public void Add (XslTemplate template)
		{
			if (template.Name != XmlQualifiedName.Empty) {
				if (namedTemplates [template.Name] != null)
					throw new InvalidOperationException ("Named template " + template.Name + " is already registered.");
				
				namedTemplates [template.Name] = template;
			}
			
			if (template.Match == null) return;
			
			XslModedTemplateTable tbl = this [template.Mode];
			if (tbl == null) {
				tbl = new XslModedTemplateTable (template.Mode);
				Add (tbl);
			}

			tbl.Add (template);
		}