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 XslForEach : XslCompiledElement {
20 XPathExpression select;
21 XslOperation children;
23 public XslForEach (Compiler c) : base (c) {}
25 protected override void Compile (Compiler c)
27 c.AssertAttribute ("select");
28 select = c.CompileExpression (c.GetAttribute ("select"));
30 if (c.Input.MoveToFirstChild ()) {
33 if (c.Input.NodeType == XPathNodeType.Text)
34 { alldone = false; break; }
36 if (c.Input.NodeType != XPathNodeType.Element)
38 if (c.Input.NamespaceURI != Compiler.XsltNamespace)
39 { alldone = false; break; }
40 if (c.Input.LocalName != "sort")
41 { alldone = false; break; }
43 c.AddSort (select, new Sort (c));
45 } while (c.Input.MoveToNext ());
47 children = c.CompileTemplateContent ();
48 c.Input.MoveToParent ();
52 public override void Evaluate (XslTransformProcessor p)
54 p.PushNodeset (p.Select (select));
55 p.PushForEachContext ();
57 while (p.NodesetMoveNext ())
58 children.Evaluate (p);
59 p.PopForEachContext();