protected void ParseParameter() { XPathNavigator nav = this.Navigator; string nameValue = nav.GetAttribute("name", ""); if (this.Parameters.Contains(nameValue)) { return; } PageParameterInfo paramInfo = null; if (nav.MoveToAttribute("bind", WebModule.Namespace)) { var exprBuilderContext = new BindingExpressionContext(this, nav.Clone()); BindingExpressionInfo exprInfo = null; try { exprInfo = BindingExpressionBuilder.ParseExpr(nav.Value, exprBuilderContext); } catch (Exception ex) { throw CreateParseException(ex.Message); } if (exprInfo != null) { exprInfo.LineNumber = ((IXmlLineInfo)nav).LineNumber; } nav.MoveToParent(); IDictionary<string, string> namespacesInScope = nav.GetNamespacesInScope(XmlNamespaceScope.All); bool hasDefaultValue = !String.IsNullOrEmpty(nav.GetAttribute("select", "")); string asValue = nav.GetAttribute("as", ""); bool required = nav.GetAttribute("required", "") == "yes"; paramInfo = PageParameterInfo.FromSequenceType(nameValue, asValue, namespacesInScope); if (hasDefaultValue) { if (paramInfo.MinLength > 0) { paramInfo.MinLength = 0; } } else if (required) { if (paramInfo.MinLength == 0) { paramInfo.MinLength = 1; } } paramInfo.Binding = exprInfo; } if (paramInfo != null) { this.Parameters.Add(paramInfo); } }
protected void ParsePagePI() { XPathNavigator nav = this.Navigator; IDictionary<string, string> attribs = GetAttributes(nav.Value); // language string language = GetNonEmptyNoWhitespaceAttribute(attribs, page.language); if (language != null) { this.Language = language; } // class-name string className = GetFullClassNameAttribute(attribs, page.class_name); if (!String.IsNullOrEmpty(className)) { this.GeneratedTypeFullName = className; } // content-type string contentType = GetNonEmptyAttribute(attribs, page.content_type); if (contentType != null) { this.ContentType = contentType; } // enable-session-state object enableSs = GetEnumAttribute(attribs, page.enable_session_state, typeof(PagesEnableSessionState)); if (enableSs != null) { this.EnableSessionState = (PagesEnableSessionState)enableSs; } // validate-request bool valReq = default(bool); if (GetBooleanAttribute(attribs, page.validate_request, ref valReq)) { this.ValidateRequest = valReq; } // accept-verbs string acceptVerbs = GetNonEmptyAttribute(attribs, page.accept_verbs); if (acceptVerbs != null) { string[] verbs = acceptVerbs.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < verbs.Length; i++) { this.AcceptVerbs.Add(verbs[i].Trim()); } } // XSLT related attributes XPathNavigator nav2 = nav.CreateNavigator(); nav2.MoveToRoot(); nav2.MoveToChild(XPathNodeType.Element); IDictionary<string, string> namespacesInScope = nav2.GetNamespacesInScope(XmlNamespaceScope.All); // initial-template string initialTempl = GetNonEmptyAttribute(attribs, page.initial_template); if (initialTempl != null) { if (this.PageType != XsltPageType.StandardStylesheet) { throw CreateParseException("The '{0}' attribute can only be used on standard XSLT pages.", page.initial_template); } string itLocal = initialTempl; string itNamespace = ""; if (initialTempl.Contains(":")) { string[] itParts = initialTempl.Split(':'); itLocal = itParts[1]; string itPrefix = itParts[0]; if (namespacesInScope.ContainsKey(itPrefix)) { itNamespace = namespacesInScope[itPrefix]; } } this.InitialTemplate = new XmlQualifiedName(itLocal, itNamespace); } // initial-template-binding string initialTemplBind = GetNonEmptyAttribute(attribs, page.bind_initial_template); if (initialTemplBind != null) { if (this.PageType != XsltPageType.StandardStylesheet) { throw CreateParseException("The '{0}' attribute can only be used on standard XSLT pages.", page.bind_initial_template); } var exprBuilderContext = new BindingExpressionContext(this, nav.Clone(), namespacesInScope) { NodeName = page.bind_initial_template, AffectsXsltInitiation = true }; try { this.InitialTemplateBinding = BindingExpressionBuilder.ParseExpr(initialTemplBind, exprBuilderContext); } catch (Exception ex) { throw CreateParseException(ex.Message); } if (this.InitialTemplateBinding != null) { this.InitialTemplateBinding.LineNumber = ((IXmlLineInfo)nav).LineNumber; } } // processor string processor = GetNonEmptyAttribute(attribs, page.processor); if (processor != null) { if (!Processors.Xslt.Exists(processor)) { throw CreateParseException("The processor '{0}' is not registered.", processor); } this.ProcessorName = processor; } }