flagstr = ((StringLiteral)args[flagsArg]).getStringValue();
}
if (args[patternArg] instanceof StringLiteral && flagstr != null) {
try {
Platform platform = Configuration.getPlatform();
String in = ((StringLiteral)args[patternArg]).getStringValue();
final int xmlVersion = env.getConfiguration().getXMLVersion();
int syntax = RegularExpression.XPATH_SYNTAX;
// TODO: Find a better (conformant) way of switching this option on
if (flagstr.length() > 0 && flagstr.charAt(0) == '!') {
flagstr = flagstr.subSequence(1, flagstr.length());
syntax = RegularExpression.NATIVE_SYNTAX;
}
return platform.compileRegularExpression(in, xmlVersion, syntax, flagstr);
} catch (XPathException err) {
if (err.getErrorCodeLocalPart() == null) {
err.setErrorCode("FORX0002");
}
throw err;