1 //------------------------------------------------------------------------------
2 // <copyright file="AttributeSetAction.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
5 // <owner current="true" primary="true">[....]</owner>
6 //------------------------------------------------------------------------------
8 namespace System.Xml.Xsl.XsltOld {
9 using Res = System.Xml.Utils.Res;
11 using System.Diagnostics;
13 using System.Xml.XPath;
14 using System.Collections;
16 internal class AttributeSetAction : ContainerAction {
17 internal XmlQualifiedName name;
19 internal XmlQualifiedName Name {
20 get { return this.name; }
23 internal override void Compile(Compiler compiler) {
24 CompileAttributes(compiler);
25 CheckRequiredAttribute(compiler, this.name, "name");
26 CompileContent(compiler);
29 internal override bool CompileAttribute(Compiler compiler) {
30 string name = compiler.Input.LocalName;
31 string value = compiler.Input.Value;
32 if (Ref.Equal(name, compiler.Atoms.Name)) {
33 Debug.Assert(this.name == null);
34 this.name = compiler.CreateXPathQName(value);
36 else if (Ref.Equal(name, compiler.Atoms.UseAttributeSets)) {
37 // create a UseAttributeSetsAction
38 // sets come before xsl:attributes
39 AddAction(compiler.CreateUseAttributeSetsAction());
48 private void CompileContent(Compiler compiler) {
49 NavigatorInput input = compiler.Input;
51 if (compiler.Recurse()) {
53 switch(input.NodeType) {
54 case XPathNodeType.Element:
55 compiler.PushNamespaceScope();
57 string nspace = input.NamespaceURI;
58 string name = input.LocalName;
60 if (Ref.Equal(nspace, input.Atoms.UriXsl) && Ref.Equal(name, input.Atoms.Attribute)) {
61 // found attribute so add it
62 AddAction(compiler.CreateAttributeAction());
65 throw compiler.UnexpectedKeyword();
70 case XPathNodeType.Comment:
71 case XPathNodeType.ProcessingInstruction:
72 case XPathNodeType.Whitespace:
73 case XPathNodeType.SignificantWhitespace:
77 throw XsltException.Create(Res.Xslt_InvalidContents, "attribute-set");
80 while(compiler.Advance());
86 internal void Merge(AttributeSetAction attributeAction) {
87 // add the contents of "attributeAction" to this action
88 // place them at the end
92 while((action = attributeAction.GetAction(i)) != null) {