Esempio n. 1
0
        private void CompileContent(Compiler compiler) {
            NavigatorInput input = compiler.Input;
            
            if (compiler.Recurse()) {
                do {
                    Debug.Trace(input);
                    switch(input.NodeType) {
                    case XPathNodeType.Element:
                        compiler.PushNamespaceScope();
                        string nspace = input.NamespaceURI;
                        string name   = input.LocalName;

                        if (Keywords.Equals(nspace, input.Atoms.XsltNamespace) && Keywords.Equals(name, input.Atoms.WithParam)) {
                                WithParamAction par = compiler.CreateWithParamAction();
                                CheckDuplicateParams(par.Name);
                                AddAction(par);
                        }
                        else {
                            throw XsltException.UnexpectedKeyword(compiler);
                        }
                        compiler.PopScope();
                        break;
                    case XPathNodeType.Comment:
                    case XPathNodeType.ProcessingInstruction:
                    case XPathNodeType.Whitespace:
                    case XPathNodeType.SignificantWhitespace:
                        break;
                    default:
                        throw new XsltException(Res.Xslt_InvalidContents, Keywords.s_CallTemplate);
                    }
                } while(compiler.Advance());

                compiler.ToParent();
            }
        }
Esempio n. 2
0
        public void CompileAttributes(Compiler compiler) {
            NavigatorInput input   = compiler.Input;
            string         element = input.LocalName;

            if (input.MoveToFirstAttribute()) {
                do {
                    Debug.TraceAttribute(input);

                    if (! Keywords.Equals(input.NamespaceURI, input.Atoms.Empty)) continue;

                    try {
                        if (CompileAttribute(compiler) == false) {
                            throw XsltException.InvalidAttribute(element, input.LocalName);
                        }
                    }catch(Exception) {
                        if (! compiler.ForwardCompatibility) {
                            throw;
                        }
                        else {
                            // In ForwardCompatibility mode we ignoreing all unknown or incorrect attributes
                            // If it's mandatory attribute we'l notice it absents later.
                        }
                    }
                }
                while (input.MoveToNextAttribute());
                input.ToParent();
            }
        }
Esempio n. 3
0
        internal virtual void CompileSingle(Compiler compiler) {
            this.match      = Compiler.RootQuery;
            this.matchKey   = Compiler.RootQueryKey;
            this.priority   = Compiler.RootPriority;

            CompileOnceTemplate(compiler);
        }
		protected override void Compile (Compiler c)
		{
			if (c.Debugger != null)
				c.Debugger.DebugCompile (this.DebugInput);

			c.CheckExtraAttributes ("value-of", "select", "disable-output-escaping");

			c.AssertAttribute ("select");
			select = c.CompileExpression (c.GetAttribute ("select"));
			disableOutputEscaping = c.ParseYesNoAttribute ("disable-output-escaping", false);
			if (c.Input.MoveToFirstChild ()) {
				do {
					switch (c.Input.NodeType) {
					case XPathNodeType.Element:
						if (c.Input.NamespaceURI == XsltNamespace)
							goto case XPathNodeType.SignificantWhitespace;
						// otherwise element in external namespace -> ignore
						break;
					case XPathNodeType.Text:
					case XPathNodeType.SignificantWhitespace:
						throw new XsltCompileException ("XSLT value-of element cannot contain any child.", null, c.Input);
					}
				} while (c.Input.MoveToNext ());
			}
		}
Esempio n. 5
0
		protected override void Compile (Compiler c)
		{
			if (c.Debugger != null)
				c.Debugger.DebugCompile (this.DebugInput);

			c.CheckExtraAttributes ("number", "level", "count", "from", "value", "format", "lang", "letter-value", "grouping-separator", "grouping-size");

			switch (c.GetAttribute ("level"))
			{
			case "single":
				level = XslNumberingLevel.Single;
				break;
			case "multiple":
				level = XslNumberingLevel.Multiple;
				break;
			case "any":
				level = XslNumberingLevel.Any;
				break;
			case null:
			case "":
			default:
				level = XslNumberingLevel.Single; // single == default
				break;
			}
			
			count = c.CompilePattern (c.GetAttribute ("count"), c.Input);
			from = c.CompilePattern (c.GetAttribute ("from"), c.Input);
			value = c.CompileExpression (c.GetAttribute ("value"));
			
			format = c.ParseAvtAttribute ("format");
			lang = c.ParseAvtAttribute ("lang");
			letterValue = c.ParseAvtAttribute ("letter-value");
			groupingSeparator = c.ParseAvtAttribute ("grouping-separator");
			groupingSize = c.ParseAvtAttribute ("grouping-size");
		}
Esempio n. 6
0
		protected override void Compile (Compiler c)
		{
			if (c.Debugger != null)
				c.Debugger.DebugCompile (this.DebugInput);

			prefix = c.Input.Prefix;
			string alias = c.CurrentStylesheet.GetActualPrefix (prefix);
			if (alias != prefix) {
				prefix = alias;
				nsUri = c.Input.GetNamespace (alias);
			}
			else
				nsUri = c.Input.NamespaceURI;

			this.localname = c.Input.LocalName;
			this.useAttributeSets = c.ParseQNameListAttribute ("use-attribute-sets", XsltNamespace);
			this.nsDecls = c.GetNamespacesToCopy ();
			if (nsDecls.Count == 0) nsDecls = null;
			this.isEmptyElement = c.Input.IsEmptyElement;

			if (c.Input.MoveToFirstAttribute ())
			{
				attrs = new ArrayList ();
				do {
					if (c.Input.NamespaceURI == XsltNamespace)
						continue; //already handled
					attrs.Add (new XslLiteralAttribute (c));
				} while (c.Input.MoveToNextAttribute());
				c.Input.MoveToParent ();
			}
			
			if (!c.Input.MoveToFirstChild ()) return;
			children = c.CompileTemplateContent ();
			c.Input.MoveToParent ();
		}
Esempio n. 7
0
        internal override void Compile(Compiler compiler) {
            CompileAttributes(compiler);

            if (compiler.Recurse()) {
                CompileTemplate(compiler);
                compiler.ToParent();
            }
        }
Esempio n. 8
0
        internal override void Compile(Compiler compiler) {
            CompileAttributes(compiler);

            if (compiler.Recurse()) {
                CompileConditions(compiler);
                compiler.ToParent();
            }
        }
		public XslTemplateContent (Compiler c,
			XPathNodeType parentType, bool xslForEach)
			: base (c) 
		{
			this.parentType = parentType;
			this.xslForEach = xslForEach;
			Compile (c);
		}
Esempio n. 10
0
 internal override void Compile(Compiler compiler) {
     CheckEmpty(compiler);
     if (! compiler.CanHaveApplyImports) {
         throw new XsltException(Res.Xslt_ApplyImports);                
     }
     this.mode = compiler.CurrentMode;
     this.stylesheet = compiler.CompiledStylesheet;
 }
Esempio n. 11
0
        internal static Avt CompileAvt(Compiler compiler, string avtText) {
            Debug.Assert(compiler != null);
            Debug.Assert(avtText != null);
            new ArrayList();

            bool constant;
            ArrayList list = compiler.CompileAvt(avtText, out constant);
            return constant ? new Avt(avtText) : new Avt(list);
        }
Esempio n. 12
0
 internal override void Compile(Compiler compiler) {
     XPathNavigator nav = compiler.Input.Navigator.Clone();
     string name = nav.Name;
     nav.MoveToParent();
     string parent = nav.Name;
     if (compiler.Recurse()) {
         CompileSelectiveTemplate(compiler);
         compiler.ToParent();
     }
 }
Esempio n. 13
0
        internal override void Compile(Compiler compiler) {
            Debug.Assert(!IsBuiltInAction);

            CompileAttributes(compiler);
            CompileContent(compiler);
            if (this.sort && this.selectKey == Compiler.InvalidQueryKey){
                this.select    = "child::node()";
                this.selectKey = compiler.AddQuery(this.select);
            }
        }
Esempio n. 14
0
		protected override void Compile (Compiler c)
		{
			if (c.Debugger != null)
				c.Debugger.DebugCompile (c.Input);

			c.CheckExtraAttributes ("copy-of", "select");

			c.AssertAttribute ("select");
			select = c.CompileExpression (c.GetAttribute ("select"));
		}
Esempio n. 15
0
        internal void CompileStylesheetAttributes(Compiler compiler) {
            NavigatorInput input        = compiler.Input;
            string         element      = input.LocalName;
            string         badAttribute = null;
            string         version      = null;
            
            if (input.MoveToFirstAttribute()) {
                do {
                    Debug.TraceAttribute(input);

                    string nspace = input.NamespaceURI;
                    string name   = input.LocalName;

                    if (! Keywords.Equals(nspace, input.Atoms.Empty)) continue;

                    Debug.WriteLine("Attribute name: \"" + name + "\"");
                    if (Keywords.Equals(name, input.Atoms.Version)) {
                        version = input.Value;
                        if (1 <= XmlConvert.ToXPathDouble(version)) {
                            compiler.ForwardCompatibility = (version != Keywords.s_Version10);
                        }
                        else {
                            // XmlConvert.ToXPathDouble(version) an be NaN!
                            if (! compiler.ForwardCompatibility) {
                                throw XsltException.InvalidAttrValue(Keywords.s_Version, version);
                            }
                        }
                        Debug.WriteLine("Version found: \"" + version + "\"");
                    }
                    else if (Keywords.Equals(name, input.Atoms.ExtensionElementPrefixes)) {
                        compiler.InsertExtensionNamespace(input.Value);
                    }
                    else if (Keywords.Equals(name, input.Atoms.ExcludeResultPrefixes)) {
                        compiler.InsertExcludedNamespace(input.Value);
                    }
                    else if (Keywords.Equals(name, input.Atoms.Id)) {
                        // Do nothing here.
                    }
                    else {
                        // We can have version atribute later. For now remember this attribute and continue
                        badAttribute = name;
                    }
                }
                while( input.MoveToNextAttribute());
                input.ToParent();
            }

            if (version == null) {
                throw new XsltException(Res.Xslt_MissingAttribute, Keywords.s_Version);
            }

            if (badAttribute != null && ! compiler.ForwardCompatibility) {
                throw XsltException.InvalidAttribute(element, badAttribute);
            }
        }
Esempio n. 16
0
 public override void ReplaceNamespaceAlias(Compiler compiler){
     if (this.namespaceUri != String.Empty) { // Do we need to check this for namespace?
         NamespaceInfo ResultURIInfo = compiler.FindNamespaceAlias(this.namespaceUri);
         if (ResultURIInfo != null) {
             this.namespaceUri = ResultURIInfo.nameSpace;
             if (ResultURIInfo.prefix != null) {
                 this.name = ResultURIInfo.prefix;
             }
         }
     }
 }
Esempio n. 17
0
        internal override void Compile(Compiler compiler) {
            CompileAttributes(compiler);

            if (compiler.Recurse()) {
                CompileTemplate(compiler);
                compiler.ToParent();
            }
            if (this.containedActions == null)
                this.empty = true;
                
        }
Esempio n. 18
0
		protected override void Compile (Compiler c)
		{
			if (c.Debugger != null)
				c.Debugger.DebugCompile (c.Input);

			c.CheckExtraAttributes ("fallback");

			if (!c.Input.MoveToFirstChild ()) return;
			children = c.CompileTemplateContent ();
			c.Input.MoveToParent ();
		}
Esempio n. 19
0
        internal override void Compile(Compiler compiler) {
            CompileAttributes(compiler);
            CheckRequiredAttribute(compiler, this.select, Keywords.s_Select);

            compiler.CanHaveApplyImports = false;
            if (compiler.Recurse()) {
                CompileSortElements(compiler);
                CompileTemplate(compiler);
                compiler.ToParent();
            }
        }
Esempio n. 20
0
		// It does not automatically invoke Compile() in .ctor()
		public XslCompiledElementBase (Compiler c)
		{
			IXmlLineInfo li = c.Input as IXmlLineInfo;
			if (li != null) {
				lineNumber = li.LineNumber;
				linePosition = li.LinePosition;
			}
			// store input only when the debugger is enabled
			if (c.Debugger != null)
				debugInput = c.Input.Clone ();
		}
Esempio n. 21
0
        internal override void Compile(Compiler compiler) {
            CompileAttributes(compiler);
            if (this.type != ConditionType.ConditionOtherwise) {
                CheckRequiredAttribute(compiler, this.testKey != Compiler.InvalidQueryKey, Keywords.s_Test);
            }

            if (compiler.Recurse()) {
                CompileTemplate(compiler);
                compiler.ToParent();
            }
        }
Esempio n. 22
0
        internal override void Compile(Compiler compiler) {
            CompileAttributes(compiler);
            CheckRequiredAttribute(compiler, this.name, Keywords.s_Name);
            if (compiler.Recurse()) {
                CompileTemplate(compiler);
                compiler.ToParent();

                if (this.select != null && this.containedActions != null) {
                    throw new XsltException(Res.Xslt_VariableCntSel, this.nameStr, this.select);
                }
            }
        }
Esempio n. 23
0
		protected override void Compile (Compiler c)
		{
			if (c.Debugger != null)
				c.Debugger.DebugCompile (this.DebugInput);

			c.CheckExtraAttributes ("text", "disable-output-escaping");

			this.text = c.Input.Value;
			
			if (c.Input.NodeType == XPathNodeType.Element)
				this.disableOutputEscaping = c.ParseYesNoAttribute ("disable-output-escaping", false);
		}
Esempio n. 24
0
		protected override void Compile (Compiler c)
		{
			if (c.Debugger != null)
				c.Debugger.DebugCompile (c.Input);

			c.CheckExtraAttributes ("comment");

			if (c.Input.MoveToFirstChild ()) {
				value = c.CompileTemplateContent (XPathNodeType.Comment);
				c.Input.MoveToParent ();
			}
		}
Esempio n. 25
0
		protected override void Compile (Compiler c)
		{
			if (c.Debugger != null)
				c.Debugger.DebugCompile (c.Input);

			c.CheckExtraAttributes ("apply-templates", "select", "mode");

			select = c.CompileExpression (c.GetAttribute ("select"));
			mode = c.ParseQNameAttribute ("mode");
			ArrayList sorterList = null;
			if (c.Input.MoveToFirstChild ()) {
				do {
					switch (c.Input.NodeType) {
					case XPathNodeType.Comment:
					case XPathNodeType.ProcessingInstruction:
					case XPathNodeType.Whitespace:
					case XPathNodeType.SignificantWhitespace:
						continue;
					case XPathNodeType.Element:
						if (c.Input.NamespaceURI != XsltNamespace)
							throw new XsltCompileException ("Unexpected element", null, c.Input); // TODO: fwd compat
						
						switch (c.Input.LocalName)
						{
							case "with-param":
								if (withParams == null)
									withParams = new ArrayList ();
								withParams.Add (new XslVariableInformation (c));
								break;
								
							case "sort":
								if (sorterList == null)
									sorterList = new ArrayList ();
								if (select == null)
									select = c.CompileExpression ("*");
								sorterList.Add (new Sort (c));
								//c.AddSort (select, new Sort (c));
								break;
							default:
								throw new XsltCompileException ("Unexpected element", null, c.Input); // todo forwards compat
						}
						break;
					default:
						throw new XsltCompileException ("Unexpected node type " + c.Input.NodeType, null, c.Input);	// todo forwards compat
					}
				} while (c.Input.MoveToNext ());
				c.Input.MoveToParent ();
			}
			if (sorterList != null)
				sortEvaluator = new XslSortEvaluator (select,
					(Sort []) sorterList.ToArray (typeof (Sort)));
		}
Esempio n. 26
0
        internal override bool CompileAttribute(Compiler compiler) {
            string name   = compiler.Input.LocalName;
            string value  = compiler.Input.Value;
            if (Keywords.Equals(name, compiler.Atoms.Terminate)) {
                _Terminate = compiler.GetYesNo(value);
                Debug.WriteLine("Message terminate == \"" + _Terminate + "\"");
            }
            else {
                return false;
            }

            return true;
        }
        internal override bool CompileAttribute(Compiler compiler) {
            string name   = compiler.Input.LocalName;
            string value  = compiler.Input.Value;
            if (Keywords.Equals(name, compiler.Atoms.Name)) {
                this.nameAvt = Avt.CompileAvt(compiler, value);
                Debug.WriteLine("name = \"" + value + "\"");
            }
            else {
                return false;
            }

            return true;
        }
Esempio n. 28
0
 internal override bool CompileAttribute(Compiler compiler) {
     string name   = compiler.Input.LocalName;
     string value  = compiler.Input.Value;
     if (Keywords.Equals(name, compiler.Atoms.UseAttributeSets)) {
         this.useAttributeSets = value;
         AddAction(compiler.CreateUseAttributeSetsAction());
         Debug.WriteLine("UseAttributeSets = \"" + this.useAttributeSets + "\"");
     }
     else {
         return false;
     }
     return true;
 }
Esempio n. 29
0
		protected override void Compile (Compiler c)
		{
			if (c.Debugger != null)
				c.Debugger.DebugCompile (this.DebugInput);

			c.CheckExtraAttributes ("message", "terminate");

			terminate = c.ParseYesNoAttribute ("terminate", false);
			
			if (!c.Input.MoveToFirstChild ()) return;
			children = c.CompileTemplateContent ();
			c.Input.MoveToParent ();
		}
Esempio n. 30
0
        internal override bool CompileAttribute(Compiler compiler) {
            string name   = compiler.Input.LocalName;
            string value  = compiler.Input.Value;

            if (Keywords.Equals(name, compiler.Atoms.DisableOutputEscaping)) {
                this.disableOutputEscaping = compiler.GetYesNo(value);
            }
            else {
                return false;
            }

            return true;
        }
Esempio n. 31
0
        public void Load(string url)
        {
            XmlTextReaderImpl tr = new XmlTextReaderImpl(url);

            Compile(Compiler.LoadDocument(tr).CreateNavigator(), XmlNullResolver.Singleton);
        }
Esempio n. 32
0
        public void Load(string url)
        {
            XmlTextReaderImpl tr = new XmlTextReaderImpl(url);

            Compile(Compiler.LoadDocument(tr).CreateNavigator(), CreateDefaultResolver());
        }
Esempio n. 33
0
        public void Load([StringSyntax(StringSyntaxAttribute.Uri)] string url)
        {
            XmlTextReaderImpl tr = new XmlTextReaderImpl(url);

            Compile(Compiler.LoadDocument(tr).CreateNavigator(), CreateDefaultResolver());
        }