/** * If tracing, add a clause to a FLWOR expression that can be used to monitor requests for * tuples to be processed * * @param target the clause whose evaluation is to be traced (or otherwise monitored) * @param env the static context of the containing FLWOR expression * @return the new clause to do the tracing; or null if no tracing is required at this point */ public Clause injectClause(Clause target, StaticContext env) { return new TraceClause(target, env.getNamespaceResolver()); } }
/** * If tracing, add a clause to a FLWOR expression that can be used to monitor requests for * tuples to be processed * * @param target the clause whose evaluation is to be traced (or otherwise monitored) * @param env the static context of the containing FLWOR expression * @return the new clause to do the tracing; or null if no tracing is required at this point */ public Clause injectClause(Clause target, StaticContext env) { return new TraceClause(target, env.getNamespaceResolver()); } }
@Override public void supplyStaticContext (StaticContext context, int locationId, Expression[] arguments) { namespaceResolver = context.getNamespaceResolver(); if (!(namespaceResolver instanceof SavedNamespaceContext)) { namespaceResolver = new SavedNamespaceContext(namespaceResolver); } }
/** * Simplify the function call. This implementation saves the static namespace context, in case it is * needed by the TraceListener. * @param visitor an expression visitor */ public Expression simplify(ExpressionVisitor visitor) throws XPathException { resolver = visitor.getStaticContext().getNamespaceResolver(); return super.simplify(visitor); }
/** * Simplify the function call. This implementation saves the static namespace context, in case it is * needed by the TraceListener. * @param visitor an expression visitor */ public Expression simplify(ExpressionVisitor visitor) throws XPathException { resolver = visitor.getStaticContext().getNamespaceResolver(); return super.simplify(visitor); }
/** * Simplify the function call. This implementation saves the static namespace context, in case it is * needed by the TraceListener. * @param visitor an expression visitor */ public Expression simplify(ExpressionVisitor visitor) throws XPathException { resolver = visitor.getStaticContext().getNamespaceResolver(); return super.simplify(visitor); }
private static String getDiagnosticName(StructuredQName name, StaticContext env) { String uri = name.getURI(); if (uri.equals("")) { return name.getLocalPart(); } else { NamespaceResolver resolver = env.getNamespaceResolver(); for (Iterator<String> it = resolver.iteratePrefixes(); it.hasNext(); ) { String prefix = it.next(); if (uri.equals(resolver.getURIForPrefix(prefix, true))) { if (prefix.isEmpty()) { return "Q{" + uri + "}" + name.getLocalPart(); } else { return prefix + ":" + name.getLocalPart(); } } } } return "Q{" + uri + "}" + name.getLocalPart(); }
private static String getDiagnosticName(StructuredQName name, StaticContext env) { String uri = name.getURI(); if (uri.equals("")) { return name.getLocalPart(); } else { NamespaceResolver resolver = env.getNamespaceResolver(); for (Iterator<String> it = resolver.iteratePrefixes(); it.hasNext(); ) { String prefix = it.next(); if (uri.equals(resolver.getURIForPrefix(prefix, true))) { if (prefix.isEmpty()) { return "Q{" + uri + "}" + name.getLocalPart(); } else { return prefix + ":" + name.getLocalPart(); } } } } return "Q{" + uri + "}" + name.getLocalPart(); }
public void checkArguments(ExpressionVisitor visitor) throws XPathException { if (checked) return; checked = true; super.checkArguments(visitor); if (argument[0] instanceof StringLiteral) { propertyName = StructuredQName.fromLexicalQName( ((StringLiteral)argument[0]).getStringValue(), false, visitor.getConfiguration().getNameChecker(), visitor.getStaticContext().getNamespaceResolver()); // Don't actually read the system property yet, it might be different at run-time } else { // we need to save the namespace context nsContext = visitor.getStaticContext().getNamespaceResolver(); } }
public void checkArguments(ExpressionVisitor visitor) throws XPathException { if (checked) return; checked = true; super.checkArguments(visitor); if (argument[0] instanceof StringLiteral) { propertyName = StructuredQName.fromLexicalQName( ((StringLiteral)argument[0]).getStringValue(), false, visitor.getConfiguration().getNameChecker(), visitor.getStaticContext().getNamespaceResolver()); // Don't actually read the system property yet, it might be different at run-time } else { // we need to save the namespace context nsContext = visitor.getStaticContext().getNamespaceResolver(); } }
public void checkArguments(ExpressionVisitor visitor) throws XPathException { // the second time checkArguments is called, it's a global check so the static context is inaccurate if (checked) { return; } checked = true; super.checkArguments(visitor); if (!(argument[0] instanceof Literal && (argument.length==1 || argument[1] instanceof Literal))) { // we need to save the namespace context nsContext = visitor.getStaticContext().getNamespaceResolver(); // for type-available, we need to save the set of imported namespaces if (operation == TYPE_AVAILABLE) { importedSchemaNamespaces = visitor.getStaticContext().getImportedSchemaNamespaces(); } } }
public void checkArguments(ExpressionVisitor visitor) throws XPathException { // the second time checkArguments is called, it's a global check so the static context is inaccurate if (checked) { return; } checked = true; super.checkArguments(visitor); if (!(argument[0] instanceof Literal && (argument.length==1 || argument[1] instanceof Literal))) { // we need to save the namespace context nsContext = visitor.getStaticContext().getNamespaceResolver(); // for type-available, we need to save the set of imported namespaces if (operation == TYPE_AVAILABLE) { importedSchemaNamespaces = visitor.getStaticContext().getImportedSchemaNamespaces(); } } }
public void checkArguments(ExpressionVisitor visitor) throws XPathException { // the second time checkArguments is called, it's a global check so the static context is inaccurate if (checked) { return; } checked = true; super.checkArguments(visitor); if (!(argument[0] instanceof Literal && (argument.length==1 || argument[1] instanceof Literal))) { // we need to save the namespace context nsContext = visitor.getStaticContext().getNamespaceResolver(); // for type-available, we need to save the set of imported namespaces if (operation == TYPE_AVAILABLE) { importedSchemaNamespaces = visitor.getStaticContext().getImportedSchemaNamespaces(); } } }
/** * If tracing, wrap an expression in a trace instruction * * @param exp the expression to be wrapped * @param env the static context * @param construct integer constant identifying the kind of construct * @param qName the name of the construct (if applicable) * @return the expression that does the tracing */ public Expression inject(Expression exp, /*@NotNull*/ StaticContext env, int construct, StructuredQName qName) { if (exp instanceof Literal && !(construct == StandardNames.XSL_TEMPLATE || construct == StandardNames.XSL_FUNCTION)) { return exp; } TraceExpression trace = new TraceExpression(exp); //ExpressionTool.copyLocationInfo(exp, trace); trace.setNamespaceResolver(env.getNamespaceResolver()); trace.setConstructType(construct); trace.setObjectName(qName); //trace.setObjectNameCode(objectNameCode); return trace; }
/** * If tracing, wrap an expression in a trace instruction * * @param exp the expression to be wrapped * @param env the static context * @param construct integer constant identifying the kind of construct * @param qName the name of the construct (if applicable) * @return the expression that does the tracing */ public Expression inject(Expression exp, /*@NotNull*/ StaticContext env, int construct, StructuredQName qName) { if (exp instanceof Literal && !(construct == StandardNames.XSL_TEMPLATE || construct == StandardNames.XSL_FUNCTION)) { return exp; } TraceExpression trace = new TraceExpression(exp); //ExpressionTool.copyLocationInfo(exp, trace); trace.setNamespaceResolver(env.getNamespaceResolver()); trace.setConstructType(construct); trace.setObjectName(qName); //trace.setObjectNameCode(objectNameCode); return trace; }
public void checkArguments(ExpressionVisitor visitor) throws XPathException { if (checked) return; checked = true; super.checkArguments(visitor); if (argument[0] instanceof StringLiteral) { try { propertyName = StructuredQName.fromLexicalQName( ((StringLiteral)argument[0]).getStringValue(), false, visitor.getConfiguration().getNameChecker(), visitor.getStaticContext().getNamespaceResolver()); } catch (XPathException e) { if (e.getErrorCodeLocalPart()==null || e.getErrorCodeLocalPart().equals("FOCA0002") || e.getErrorCodeLocalPart().equals("FONS0004")) { e.setErrorCode("XTDE1390"); throw e; } } // Don't actually read the system property yet, it might be different at run-time } else { // we need to save the namespace context nsContext = visitor.getStaticContext().getNamespaceResolver(); } }
public RetainedStaticContext(StaticContext sc) { this.config = sc.getConfiguration(); this.packageData = sc.getPackageData(); if (sc.getStaticBaseURI() != null) { staticBaseUriString = sc.getStaticBaseURI(); try { this.staticBaseUri = ExpressionTool.getBaseURI(sc, null, true); } catch (XPathException e) { staticBaseUri = null; } } this.defaultCollationName = sc.getDefaultCollationName(); this.decimalFormatManager = sc.getDecimalFormatManager(); this.defaultElementNamespace = sc.getDefaultElementNamespace(); defaultFunctionNamespace = sc.getDefaultFunctionNamespace(); backwardsCompatibility = sc.isInBackwardsCompatibleMode(); if (Version.platform.JAXPStaticContextCheck(this, sc)) { //updated in method } else { this.namespaces = new HashMap<>(4); NamespaceResolver resolver = sc.getNamespaceResolver(); for (Iterator<String> it = resolver.iteratePrefixes(); it.hasNext(); ) { String prefix = it.next(); if (!prefix.equals("xml")) { namespaces.put(prefix, resolver.getURIForPrefix(prefix, true)); } } } }
/** * If tracing, wrap an expression in a trace instruction * @param startOffset the position of the expression in the soruce * @param exp the expression to be wrapped * @param construct integer constant identifying the kind of construct * @param qName the name of the construct (if applicable) * @return the expression that does the tracing */ protected Expression makeTracer(int startOffset, Expression exp, int construct, StructuredQName qName) { if (isCompileWithTracing()) { TraceExpression trace = new TraceExpression(exp); long lc = t.getLineAndColumn(startOffset); trace.setLineNumber((int)(lc>>32)); trace.setColumnNumber((int)(lc&0x7fffffff)); trace.setSystemId(env.getSystemId()); trace.setNamespaceResolver(env.getNamespaceResolver()); trace.setConstructType(construct); trace.setObjectName(qName); //trace.setObjectNameCode(objectNameCode); return trace; } else { return exp; } }
/** * If tracing, wrap an expression in a trace instruction * @param startOffset the position of the expression in the soruce * @param exp the expression to be wrapped * @param construct integer constant identifying the kind of construct * @param qName the name of the construct (if applicable) * @return the expression that does the tracing */ protected Expression makeTracer(int startOffset, Expression exp, int construct, StructuredQName qName) { if (isCompileWithTracing()) { TraceExpression trace = new TraceExpression(exp); long lc = t.getLineAndColumn(startOffset); trace.setLineNumber((int)(lc>>32)); trace.setColumnNumber((int)(lc&0x7fffffff)); trace.setSystemId(env.getSystemId()); trace.setNamespaceResolver(env.getNamespaceResolver()); trace.setConstructType(construct); trace.setObjectName(qName); //trace.setObjectNameCode(objectNameCode); return trace; } else { return exp; } }
/** * Parse the expression (inside a string literal) used to define default values * for external variables. This requires instantiating a nested XPath parser. * @param exp holds the expression used to define a default value * @return the compiled expression that computes the default value */ public Expression setDefaultValue(String exp) { try { IndependentContext ic = new IndependentContext(env.getConfiguration()); ic.setNamespaceResolver(env.getNamespaceResolver()); Expression expr = ExpressionTool.make(exp, ic, 0, Token.EOF, 1, false); ItemType contextItemType = Type.ITEM_TYPE; ExpressionVisitor visitor = ExpressionVisitor.make(ic); expr = visitor.typeCheck(expr, contextItemType); expr = visitor.optimize(expr, contextItemType); SlotManager stackFrameMap = ic.getStackFrameMap(); ExpressionTool.allocateSlots(expr, stackFrameMap.getNumberOfVariables(), stackFrameMap); return expr; } catch (XPathException e) { try { warning("Invalid expression for default value: " + e.getMessage() + " (ignored)"); } catch (XPathException staticError) { // } return null; } }