5 // Ben Maurer (bmaurer@users.sourceforge.net)
6 // Atsushi Enomoto (ginga@kit.hi-ho.ne.jp)
9 // (C) 2003 Atsushi Enomoto
13 using System.Collections;
15 using System.Xml.XPath;
18 namespace Mono.Xml.Xsl.Operations {
19 public class XslCallTemplate : XslCompiledElement {
20 XmlQualifiedName name;
21 ArrayList withParams = new ArrayList ();
22 public XslCallTemplate (Compiler c) : base (c) {}
24 protected override void Compile (Compiler c)
26 c.AssertAttribute ("name");
27 name = c.ParseQNameAttribute ("name");
29 if (c.Input.MoveToFirstChild ()) {
31 switch (c.Input.NodeType) {
32 case XPathNodeType.Comment:
33 case XPathNodeType.ProcessingInstruction:
34 case XPathNodeType.Whitespace:
36 case XPathNodeType.Element:
37 if (c.Input.NamespaceURI != XsltNamespace)
38 throw new Exception ("unexptected element"); // TODO: fwd compat
40 switch (c.Input.LocalName)
43 withParams.Add (new XslVariableInformation (c));
46 throw new Exception ("unexptected element"); // todo forwards compat
50 throw new Exception ("unexptected node type " + c.Input.NodeType); // TODO: fwd compat
52 } while (c.Input.MoveToNext ());
53 c.Input.MoveToParent ();
57 public override void Evaluate (XslTransformProcessor p)
59 Hashtable passedParams = null;
61 if (withParams.Count > 0) {
62 passedParams = new Hashtable ();
63 foreach (XslVariableInformation param in withParams)
64 passedParams [param.Name] = param.Evaluate (p);
67 p.CallTemplate (name, passedParams);