5 // Ben Maurer (bmaurer@users.sourceforge.net)
6 // Atsushi Enomoto (ginga@kit.hi-ho.ne.jp)
9 // (C) 2003 Atsushi Enomoto
14 using System.Collections;
15 using System.Collections.Specialized;
17 using System.Xml.Schema;
18 using System.Xml.XPath;
20 using Mono.Xml.Xsl.Operations;
22 using QName = System.Xml.XmlQualifiedName;
24 namespace Mono.Xml.Xsl {
25 public class XslAttributeSet : XslCompiledElement {
27 // [QName]=>XslAttributeSet
28 ArrayList usedAttributeSets = new ArrayList ();
30 // [QName]=>XslAttribute
31 ArrayList attributes = new ArrayList ();
33 public XslAttributeSet (Compiler c) : base (c) {}
39 protected override void Compile (Compiler c)
41 this.name = c.ParseQNameAttribute ("name");
43 QName [] attrSets = c.ParseQNameListAttribute ("use-attribute-sets");
45 foreach (QName q in c.ParseQNameListAttribute ("use-attribute-sets"))
46 usedAttributeSets.Add (q);
49 if (!c.Input.MoveToFirstChild ()) return;
52 if (c.Input.NodeType != XPathNodeType.Element) continue;
54 if (c.Input.NamespaceURI != XsltNamespace || c.Input.LocalName != "attribute")
55 throw new Exception ("Invalid attr set content");
56 attributes.Add (new XslAttribute (c));
57 } while (c.Input.MoveToNext ());
59 c.Input.MoveToParent ();
63 public void Merge (XslAttributeSet s)
65 attributes.AddRange (s.attributes);
67 foreach (QName q in s.usedAttributeSets)
68 if (!usedAttributeSets.Contains (q))
69 usedAttributeSets.Add (q);
72 public override void Evaluate (XslTransformProcessor p) {
75 if (usedAttributeSets != null) {
76 foreach (QName set in usedAttributeSets)
78 XslAttributeSet s = p.ResolveAttributeSet (set);
80 throw new Exception ("Could not resolve attribute set");
83 throw new Exception ("circular dependency");
89 foreach (Operations.XslAttribute a in attributes)