/** * Compile a regular expression (or, in some configurations, get a compiled * regular expression from a cache * * @param regex the regular expression as a string * @param flags the value of the flags attribute * @param hostLanguage one of "XSD10", "XSD11", XP20" or "XP30". Also allow combinations, e.g. "XP20/XSD11". * @param warnings if non-null, any warnings from the regular expression compiler will be added to this list. * If null, the warnings are ignored. * @return the compiled regular expression * @throws XPathException if the regular expression or the flags are invalid */ public RegularExpression compileRegularExpression(CharSequence regex, String flags, String hostLanguage, List<String> warnings) throws XPathException { return Version.platform.compileRegularExpression(this, regex, flags, hostLanguage, warnings); }
/** * Compile a regular expression (or, in some configurations, get a compiled * regular expression from a cache * * @param regex the regular expression as a string * @param flags the value of the flags attribute * @param hostLanguage one of "XSD10", "XSD11", XP20" or "XP30". Also allow combinations, e.g. "XP20/XSD11". * @param warnings if non-null, any warnings from the regular expression compiler will be added to this list. * If null, the warnings are ignored. * @return the compiled regular expression * @throws XPathException if the regular expression or the flags are invalid */ public RegularExpression compileRegularExpression(CharSequence regex, String flags, String hostLanguage, List<String> warnings) throws XPathException { return Version.platform.compileRegularExpression(this, regex, flags, hostLanguage, warnings); }
compiledRegex = Version.platform.compileRegularExpression(XmlUtils.SAXON_PROCESSOR.getUnderlyingConfiguration(), regex, "", "XP20", null);
syntax = RegularExpression.NATIVE_SYNTAX; return platform.compileRegularExpression(in, xmlVersion, syntax, flagstr); } catch (XPathException err) { if (err.getErrorCodeLocalPart() == null) {
syntax = RegularExpression.NATIVE_SYNTAX; return platform.compileRegularExpression(in, xmlVersion, syntax, flagstr); } catch (XPathException err) { XPathException e2 = new XPathException(err.getMessage());
syntax = RegularExpression.NATIVE_SYNTAX; return platform.compileRegularExpression(in, xmlVersion, syntax, flagstr); } catch (XPathException err) { XPathException e2 = new XPathException(err.getMessage());
/** * Match a string against a regular expression * * @param regex * regular expression * @param arg1 * string value * @return true iff {@code arg1} matches {@code regex} * @throws IllegalArgumentException * {@code regex} is not a valid regular expression */ public static boolean match(final StringValue regex, final SimpleValue<String> arg1) throws IllegalArgumentException { /* * From Saxon xf:matches() implementation: Matches#evaluateItem() / evalMatches() */ final RegularExpression compiledRegex; try { compiledRegex = Version.platform.compileRegularExpression(XmlUtils.SAXON_PROCESSOR.getUnderlyingConfiguration(), regex.getUnderlyingValue(), "", "XP20", null); } catch (final XPathException e) { throw new PatternSyntaxException("Invalid regular expression arg", regex.getUnderlyingValue(), -1); } return compiledRegex.containsMatch(arg1.getUnderlyingValue()); }
/** * Get an iterator over the substrings defined by the regular expression * * @param context the evaluation context * @return an iterator that returns matching and nonmatching substrings * @throws XPathException */ private RegexIterator getRegexIterator(XPathContext context) throws XPathException { CharSequence input = select.evaluateAsString(context); RegularExpression re = pattern; if (re == null) { CharSequence flagstr = flags.evaluateAsString(context); final Platform platform = Configuration.getPlatform(); final int xmlVersion = context.getConfiguration().getXMLVersion(); re = platform.compileRegularExpression( regex.evaluateAsString(context), xmlVersion, RegularExpression.XPATH_SYNTAX, flagstr); if (re.matches("")) { dynamicError("The regular expression must not be one that matches a zero-length string", "XTDE1150", context); } } return re.analyze(input); }
/** * Get an iterator over the substrings defined by the regular expression * * @param context the evaluation context * @return an iterator that returns matching and nonmatching substrings * @throws XPathException */ private RegexIterator getRegexIterator(XPathContext context) throws XPathException { CharSequence input = select.evaluateAsString(context); RegularExpression re = pattern; if (re == null) { CharSequence flagstr = flags.evaluateAsString(context); final Platform platform = Configuration.getPlatform(); final int xmlVersion = context.getConfiguration().getXMLVersion(); re = platform.compileRegularExpression( regex.evaluateAsString(context), xmlVersion, RegularExpression.XPATH_SYNTAX, flagstr); if (re.matches("")) { dynamicError("The regular expression must not be one that matches a zero-length string", "XTDE1150", context); } } return re.analyze(input); }
final CharSequence flagstr = ((StringLiteral)flags).getStringValue(); final int xmlVersion = getConfiguration().getXMLVersion(); pattern = platform.compileRegularExpression( regex, xmlVersion, RegularExpression.XPATH_SYNTAX, flagstr);
final CharSequence flagstr = ((StringLiteral)flags).getStringValue(); final int xmlVersion = getConfiguration().getXMLVersion(); pattern = platform.compileRegularExpression( regex, xmlVersion, RegularExpression.XPATH_SYNTAX, flagstr);
final Platform platform = Configuration.getPlatform(); final int xmlVersion = c.getConfiguration().getXMLVersion(); re = platform.compileRegularExpression( pat.getStringValueCS(), xmlVersion, RegularExpression.XPATH_SYNTAX, flags); } catch (XPathException err) {
final Platform platform = Configuration.getPlatform(); final int xmlVersion = c.getConfiguration().getXMLVersion(); re = platform.compileRegularExpression( pattern, xmlVersion, RegularExpression.XPATH_SYNTAX, flags); } catch (XPathException err) {
final CharSequence flagstr = ((StringLiteral)flags).getStringValue(); final int xmlVersion = visitor.getConfiguration().getXMLVersion(); pattern = platform.compileRegularExpression( regex, xmlVersion, RegularExpression.XPATH_SYNTAX, flagstr);
final Platform platform = Configuration.getPlatform(); final int xmlVersion = c.getConfiguration().getXMLVersion(); re = platform.compileRegularExpression( pattern, xmlVersion, RegularExpression.XPATH_SYNTAX, flags); } catch (XPathException err) {
final Platform platform = Configuration.getPlatform(); final int xmlVersion = c.getConfiguration().getXMLVersion(); re = platform.compileRegularExpression( pat.getStringValueCS(), xmlVersion, RegularExpression.XPATH_SYNTAX, flags); } catch (XPathException err) {
final Platform platform = Configuration.getPlatform(); final int xmlVersion = c.getConfiguration().getXMLVersion(); re = platform.compileRegularExpression( pat.getStringValueCS(), xmlVersion, RegularExpression.XPATH_SYNTAX, flags); } catch (XPathException err) {
final Platform platform = Configuration.getPlatform(); final int xmlVersion = c.getConfiguration().getXMLVersion(); re = platform.compileRegularExpression( pattern, xmlVersion, RegularExpression.XPATH_SYNTAX, flags); } catch (XPathException err) {
final Platform platform = Configuration.getPlatform(); final int xmlVersion = c.getConfiguration().getXMLVersion(); re = platform.compileRegularExpression( arg1.getStringValueCS(), xmlVersion, RegularExpression.XPATH_SYNTAX, flags); } catch (XPathException err) {
final Platform platform = Configuration.getPlatform(); final int xmlVersion = c.getConfiguration().getXMLVersion(); re = platform.compileRegularExpression( arg1.getStringValueCS(), xmlVersion, RegularExpression.XPATH_SYNTAX, flags); } catch (XPathException err) {