internal void LoadCompiledStylesheet(out Stylesheet compiledStylesheet, out XPathExpression[] querylist, out ArrayList queryStore, out RootAction rootAction, XPathNavigator input) { // // Extract the state atomically // if (_CompiledStylesheet == null || _QueryStore == null || _RootAction == null) { throw new XsltException(Res.Xslt_NoStylesheetLoaded); } compiledStylesheet = _CompiledStylesheet; queryStore = _QueryStore; rootAction = _RootAction; int queryCount = _QueryStore.Count; querylist = new XPathExpression[queryCount]; { bool canClone = input is DocumentXPathNavigator || input is XPathDocumentNavigator; for (int i = 0; i < queryCount; i++) { XPathExpression query = ((TheQuery)_QueryStore[i]).CompiledQuery; if (canClone) { querylist[i] = query.Clone(); } else { bool hasPrefix; IQuery ast = new QueryBuilder().Build(query.Expression, out hasPrefix); querylist[i] = new CompiledXpathExpr(ast, query.Expression, hasPrefix); } } } }
internal int AddQuery(string xpathQuery, bool allowVar, bool allowKey, bool isPattern) { Debug.Assert(_queryStore != null); CompiledXpathExpr expr; try { expr = new CompiledXpathExpr( (isPattern ? _queryBuilder.BuildPatternQuery(xpathQuery, allowVar, allowKey) : _queryBuilder.Build(xpathQuery, allowVar, allowKey) ), xpathQuery, false ); } catch (XPathException e) { if (!ForwardCompatibility) { throw XsltException.Create(SR.Xslt_InvalidXPath, new string[] { xpathQuery }, e); } expr = new ErrorXPathExpression(xpathQuery, this.Input.BaseURI, this.Input.LineNumber, this.Input.LinePosition); } _queryStore.Add(new TheQuery(expr, _scopeManager)); return(_queryStore.Count - 1); }
public static XPathExpression Compile(string xpath, IXmlNamespaceResolver nsResolver) { bool hasPrefix; Query query = new QueryBuilder().Build(xpath, out hasPrefix); CompiledXpathExpr expr = new CompiledXpathExpr(query, xpath, hasPrefix); if (null != nsResolver) { expr.SetContext(nsResolver); } return expr; }
public static XPathExpression Compile(string xpath, IXmlNamespaceResolver nsResolver) { bool flag; CompiledXpathExpr expr = new CompiledXpathExpr(new QueryBuilder().Build(xpath, out flag), xpath, flag); if (nsResolver != null) { expr.SetContext(nsResolver); } return expr; }
public static XPathExpression Compile(string xpath, IXmlNamespaceResolver nsResolver) { bool hasPrefix; Query query = new QueryBuilder().Build(xpath, out hasPrefix); CompiledXpathExpr expr = new CompiledXpathExpr(query, xpath, hasPrefix); if (null != nsResolver) { expr.SetContext(nsResolver); } return(expr); }
private void AnalyzePriority(Compiler compiler) { NavigatorInput input = compiler.Input; if (!Double.IsNaN(this.priority) || this.matchKey == Compiler.InvalidQueryKey) { return; } // Split Unions: TheQuery theQuery = (TheQuery)compiler.QueryStore[this.MatchKey]; CompiledXpathExpr expr = (CompiledXpathExpr)theQuery.CompiledQuery; Query query = expr.QueryTree; UnionExpr union; while ((union = query as UnionExpr) != null) { Debug.Assert(!(union.qy2 is UnionExpr), "only qy1 can be union"); TemplateAction copy = this.CloneWithoutName(); compiler.QueryStore.Add(new TheQuery( new CompiledXpathExpr(union.qy2, expr.Expression, false), theQuery._ScopeManager )); copy.matchKey = compiler.QueryStore.Count - 1; copy.priority = union.qy2.XsltDefaultPriority; compiler.AddTemplate(copy); query = union.qy1; } if (expr.QueryTree != query) { // query was splitted and we need create new TheQuery for this template compiler.QueryStore[this.MatchKey] = new TheQuery( new CompiledXpathExpr(query, expr.Expression, false), theQuery._ScopeManager ); } this.priority = query.XsltDefaultPriority; }
internal int AddQuery(string xpathQuery, bool allowVar, bool allowKey, bool isPattern) { Debug.Assert(_queryStore != null); CompiledXpathExpr expr; try { expr = new CompiledXpathExpr( (isPattern ? _queryBuilder.BuildPatternQuery(xpathQuery, allowVar, allowKey) : _queryBuilder.Build(xpathQuery, allowVar, allowKey) ), xpathQuery, false ); } catch (XPathException e) { if (!ForwardCompatibility) { throw XsltException.Create(SR.Xslt_InvalidXPath, new string[] { xpathQuery }, e); } expr = new ErrorXPathExpression(xpathQuery, this.Input.BaseURI, this.Input.LineNumber, this.Input.LinePosition); } _queryStore.Add(new TheQuery(expr, _scopeManager)); return _queryStore.Count - 1; }
internal TheQuery(CompiledXpathExpr compiledQuery, InputScopeManager manager) { _CompiledQuery = compiledQuery; _ScopeManager = manager.Clone(); }
internal TheQuery(CompiledXpathExpr compiledQuery, InputScopeManager manager) { _CompiledQuery = compiledQuery; _ScopeManager = manager.Clone(); }