2 // XslProcessingInstruction.cs
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;
19 namespace Mono.Xml.Xsl.Operations {
20 public class XslProcessingInstruction : XslCompiledElement {
24 public XslProcessingInstruction (Compiler c) : base (c) {}
26 protected override void Compile (Compiler c)
28 name = c.ParseAvtAttribute ("name");
30 if (c.Input.MoveToFirstAttribute ()) {
32 if (c.Input.NamespaceURI == String.Empty && c.Input.LocalName != "name")
33 throw new XsltCompileException ("Invalid attribute \"" + c.Input.Name + "\"", null, c.Input);
34 } while (c.Input.MoveToNextAttribute ());
35 c.Input.MoveToParent ();
38 if (!c.Input.MoveToFirstChild ()) return;
40 value = c.CompileTemplateContent (XPathNodeType.ProcessingInstruction);
41 c.Input.MoveToParent ();
44 public override void Evaluate (XslTransformProcessor p)
46 StringWriter s = new StringWriter ();
47 Outputter outputter = new TextOutputter(s, true);
48 p.PushOutput (outputter);
52 string actualName = name.Evaluate (p);
53 if (actualName.ToLower () == "xml")
54 throw new XsltException ("Processing instruction name was evaluated to \"xml\"", null, p.CurrentNode);
55 p.Out.WriteProcessingInstruction (actualName, s.ToString ());