private void tryToBindRegularExpression(Expression[] arguments) { // For all these functions, the regular expression is the second argument, and the flags // argument is the last argument. if (arguments[1] instanceof Literal && arguments[arguments.length - 1] instanceof Literal) { try { Configuration config = getRetainedStaticContext().getConfiguration(); String re = ((Literal) arguments[1]).getValue().getStringValue(); String flags = ((Literal) arguments[arguments.length - 1]).getValue().getStringValue(); String hostLang = "XP30"; if (config.getXsdVersion() == Configuration.XSD11) { hostLang += "/XSD11"; } List<String> warnings = new ArrayList<>(1); staticRegex = config.compileRegularExpression(re, flags, hostLang, warnings); if (!allowRegexMatchingEmptyString() && staticRegex.matches("")) { staticRegex = null; // will cause a dynamic error } } catch (XPathException err) { // If the regex is invalid, we leave it to be evaluated again at execution time } } }
@Override public Expression makeOptimizedFunctionCall(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo, Expression... arguments) throws XPathException { boolean opt = true; if (!(arguments[1] instanceof Literal)) { opt = false; } if (arguments.length == 3 && !(arguments[2] instanceof Literal)) { opt = false; } if (!opt) { return super.makeOptimizedFunctionCall(visitor, contextInfo, arguments); } Configuration config = visitor.getConfiguration(); String language = arguments.length == 3 ? ((Literal)arguments[2]).getValue().getStringValue() : config.getDefaultLanguage(); Numberer numb = config.makeNumberer(language, null); formatter = makeFormatter(numb, ((Literal)arguments[1]).getValue().getStringValue()); return super.makeOptimizedFunctionCall(visitor, contextInfo, arguments); }
Expression c = arguments[arguments.length - 1]; if (c instanceof Literal) { String coll = ((Literal) c).getValue().getStringValue(); try { URI collUri = new URI(coll);
private void tryToBindRegularExpression(Expression[] arguments) { // For all these functions, the regular expression is the second argument, and the flags // argument is the last argument. if (arguments[1] instanceof Literal && arguments[arguments.length - 1] instanceof Literal) { try { Configuration config = getRetainedStaticContext().getConfiguration(); String re = ((Literal) arguments[1]).getValue().getStringValue(); String flags = ((Literal) arguments[arguments.length - 1]).getValue().getStringValue(); String hostLang = "XP30"; if (config.getXsdVersion() == Configuration.XSD11) { hostLang += "/XSD11"; } List<String> warnings = new ArrayList<>(1); staticRegex = config.compileRegularExpression(re, flags, hostLang, warnings); if (!allowRegexMatchingEmptyString() && staticRegex.matches("")) { staticRegex = null; // will cause a dynamic error } } catch (XPathException err) { // If the regex is invalid, we leave it to be evaluated again at execution time } } }
Expression c = arguments[arguments.length - 1]; if (c instanceof Literal) { String coll = ((Literal) c).getValue().getStringValue(); try { URI collUri = new URI(coll);
public void localTypeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) throws XPathException { // Do early checking of content if known statically if (getSelect() instanceof Literal) { String s = ((Literal) getSelect()).getValue().getStringValue(); String s2 = checkContent(s, visitor.getStaticContext().makeEarlyEvaluationContext()); if (!s2.equals(s)) { setSelect(new StringLiteral(s2)); } } }
@Override public Expression bind(StructuredQName functionName, int arity, Expression[] staticArgs, StaticContext env, Container container) throws XPathException { IntegratedFunctionCall ifc = (IntegratedFunctionCall) super.bind(functionName, arity, staticArgs, env, container); if (ifc == null) { return null; } ExtensionFunctionCall f = ifc.getFunction(); // Is the search sorting results in document order: ie do we have a single sort criterion "lux:docid"? if (f instanceof SearchCall && staticArgs.length > 1 && staticArgs[1] instanceof Literal && ((Literal)staticArgs[1]).getValue().getStringValue().equals(FieldRole.LUX_DOCID)) { LuxFunctionCall fc = new LuxFunctionCall(f); fc.setFunctionName(functionName); fc.setArguments(staticArgs); return fc; } return ifc; }
public void localTypeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) throws XPathException { // Do early checking of content if known statically if (getSelect() instanceof Literal) { String s = ((Literal) getSelect()).getValue().getStringValue(); String s2 = checkContent(s, visitor.getStaticContext().makeEarlyEvaluationContext()); if (!s2.equals(s)) { setSelect(new StringLiteral(s2)); } } }
if (arg instanceof Literal) { try { String argValue = ((Literal) arg).getValue().getStringValue(); if (baseUri == null) { if (new URI(argValue).isAbsolute()) {
/** * Make an expression that either calls this function, or that is equivalent to a call * on this function * * @param arguments the supplied arguments to the function call * @return either a function call on this function, or an expression that delivers * the same result */ @Override public Expression makeFunctionCall(Expression[] arguments) { try { if (arguments[0] instanceof Literal) { boolean b = typeAvailable( ((Literal)arguments[0]).getValue().getStringValue(), getRetainedStaticContext().getConfiguration()); return Literal.makeLiteral(BooleanValue.get(b)); } } catch (XPathException e) { // fall through } return super.makeFunctionCall(arguments); } }
/** * Make an expression that either calls this function, or that is equivalent to a call * on this function * * @param arguments the supplied arguments to the function call * @return either a function call on this function, or an expression that delivers * the same result */ @Override public Expression makeFunctionCall(Expression[] arguments) { try { if (arguments[0] instanceof Literal) { boolean b = typeAvailable( ((Literal)arguments[0]).getValue().getStringValue(), getRetainedStaticContext().getConfiguration()); return Literal.makeLiteral(BooleanValue.get(b)); } } catch (XPathException e) { // fall through } return super.makeFunctionCall(arguments); } }
DecimalFormatManager dfm = getRetainedStaticContext().getDecimalFormatManager(); assert dfm != null; picture = ((Literal) arguments[1]).getValue().getStringValue(); if (arguments.length == 3 && !Literal.isEmptySequence(arguments[2])) { try { String lexicalName = ((Literal) arguments[2]).getValue().getStringValue(); decimalFormatName = StructuredQName.fromLexicalQName(lexicalName, false, true, getRetainedStaticContext());
GroundedValue dupes = options.get(new StringValue("duplicates")); try { if (!"combine".equals(dupes.getStringValue())) { maybeCombined = false;
selectValue.getStringValue(), null, getConfiguration().getConversionRules()); if (err != null) { err.setLocator(getLocation()); !((ComplexType) parentType).isSimpleContent() && !((ComplexType) parentType).isMixedContent() && !Whitespace.isWhite(selectValue.getStringValue())) { XPathException err = new XPathException("The containing element must be of type " + parentType.getDescription() + ", which does not allow text content " + Err.wrap(selectValue.getStringValue())); err.setLocation(getLocation()); err.setIsTypeError(true);
GroundedValue dupes = options.get(new StringValue("duplicates")); try { if (!"combine".equals(dupes.getStringValue())) { maybeCombined = false;
/** * Method called during static type checking. This method may be implemented in subclasses so that functions * can take advantage of knowledge of the types of the arguments that will be supplied. * * @param visitor an expression visitor, providing access to the static context and configuration * @param contextItemType information about whether the context item is set, and what its type is * @param arguments the expressions appearing as arguments in the function call */ @Override public void supplyTypeInformation(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType, Expression[] arguments) throws XPathException { ItemType it = arguments[0].getItemType(); if (it instanceof TupleType) { if (arguments[1] instanceof Literal) { String key = ((Literal)arguments[1]).getValue().getStringValue(); if (((TupleType)it).getFieldType(key) == null) { XPathException xe = new XPathException("Field " + key + " is not defined for tuple type " + it, "SXTT0001"); xe.setIsTypeError(true); throw xe; } } TypeHierarchy th = visitor.getConfiguration().getTypeHierarchy(); int relation = th.relationship(arguments[1].getItemType(), BuiltInAtomicType.STRING); if (relation == TypeHierarchy.DISJOINT) { XPathException xe = new XPathException("Key for tuple type must be a string (actual type is " + arguments[1].getItemType(), "XPTY0004"); xe.setIsTypeError(true); throw xe; } } }
/** * Method called during static type checking. This method may be implemented in subclasses so that functions * can take advantage of knowledge of the types of the arguments that will be supplied. * * @param visitor an expression visitor, providing access to the static context and configuration * @param contextItemType information about whether the context item is set, and what its type is * @param arguments the expressions appearing as arguments in the function call */ @Override public void supplyTypeInformation(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType, Expression[] arguments) throws XPathException { ItemType it = arguments[0].getItemType(); if (it instanceof TupleType) { if (arguments[1] instanceof Literal) { String key = ((Literal)arguments[1]).getValue().getStringValue(); if (((TupleType)it).getFieldType(key) == null) { XPathException xe = new XPathException("Field " + key + " is not defined for tuple type " + it, "SXTT0001"); xe.setIsTypeError(true); throw xe; } } TypeHierarchy th = visitor.getConfiguration().getTypeHierarchy(); int relation = th.relationship(arguments[1].getItemType(), BuiltInAtomicType.STRING); if (relation == TypeHierarchy.DISJOINT) { XPathException xe = new XPathException("Key for tuple type must be a string (actual type is " + arguments[1].getItemType(), "XPTY0004"); xe.setIsTypeError(true); throw xe; } } }
public void localTypeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) throws XPathException { StaticContext env = visitor.getStaticContext(); nameOp.typeCheck(visitor, contextItemType); RoleDiagnostic role = new RoleDiagnostic(RoleDiagnostic.INSTRUCTION, "processing-instruction/name", 0); // See bug 2110. XQuery does not use the function conversion rules here, and disallows xs:anyURI. // In XSLT the name is an AVT so we automatically get a string; in XQuery we'll use the standard // mechanism to get an atomic value, and then check the type "by hand" at run time. setNameExp(visitor.getConfiguration().getTypeChecker(false).staticTypeCheck( getNameExp(), SequenceType.SINGLE_ATOMIC, role, visitor)); Expression nameExp = getNameExp(); adoptChildExpression(nameExp); // Do early checking of name if known statically if (nameExp instanceof Literal && ((Literal)nameExp).getValue() instanceof AtomicValue) { AtomicValue val = (AtomicValue) ((Literal) nameExp).getValue(); checkName(val, env.makeEarlyEvaluationContext()); } // Do early checking of content if known statically if (getSelect() instanceof Literal) { String s = ((Literal) getSelect()).getValue().getStringValue(); String s2 = checkContent(s, env.makeEarlyEvaluationContext()); if (!s2.equals(s)) { setSelect(new StringLiteral(s2)); } } }
public void localTypeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) throws XPathException { StaticContext env = visitor.getStaticContext(); nameOp.typeCheck(visitor, contextItemType); RoleDiagnostic role = new RoleDiagnostic(RoleDiagnostic.INSTRUCTION, "processing-instruction/name", 0); // See bug 2110. XQuery does not use the function conversion rules here, and disallows xs:anyURI. // In XSLT the name is an AVT so we automatically get a string; in XQuery we'll use the standard // mechanism to get an atomic value, and then check the type "by hand" at run time. setNameExp(visitor.getConfiguration().getTypeChecker(false).staticTypeCheck( getNameExp(), SequenceType.SINGLE_ATOMIC, role, visitor)); Expression nameExp = getNameExp(); adoptChildExpression(nameExp); // Do early checking of name if known statically if (nameExp instanceof Literal && ((Literal)nameExp).getValue() instanceof AtomicValue) { AtomicValue val = (AtomicValue) ((Literal) nameExp).getValue(); checkName(val, env.makeEarlyEvaluationContext()); } // Do early checking of content if known statically if (getSelect() instanceof Literal) { String s = ((Literal) getSelect()).getValue().getStringValue(); String s2 = checkContent(s, env.makeEarlyEvaluationContext()); if (!s2.equals(s)) { setSelect(new StringLiteral(s2)); } } }
String lexicalQName = ((Literal) arguments[0]).getValue().getStringValue(); StaticContext env = visitor.getStaticContext(); boolean b = false;