Package net.sf.saxon.regex
Class JDK15RegexTranslator
java.lang.Object
net.sf.saxon.regex.JDK15RegexTranslator
This class translates XML Schema regex syntax into JDK 1.5 regex syntax. This differs from the JDK 1.4
translator because JDK 1.5 handles non-BMP characters (wide characters) in places where JDK 1.4 does not,
for example in a range such as [X-Y]. This enables much of the code from the 1.4 translator to be
removed.
Author: James Clark
Modified by Michael Kay (a) to integrate the code into Saxon, and (b) to support XPath additions
to the XML Schema regex syntax. This version also removes most of the complexities of handling non-BMP
characters, since JDK 1.5 handles these natively.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class
(package private) static class
(package private) static class
(package private) static class
(package private) static class
(package private) static class
(package private) static final class
(package private) static class
(package private) static class
(package private) static class
(package private) static class
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final int
(package private) static final String
(package private) static final int[][]
(package private) static final String
(package private) static final String
(package private) static final String
(package private) static final String
(package private) static final String
(package private) static final String
(package private) static final int
(package private) static final String
(package private) static final int
(package private) static final String
(package private) static final String
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
static String
translate
(CharSequence regexp, boolean xpath, boolean ignoreWhitespace, boolean caseBlind) Translates a regular expression in the syntax of XML Schemas Part 2 into a regular expression in the syntax ofjava.util.regex.Pattern
.
-
Field Details
-
CATEGORY_NAMES
- See Also:
-
CATEGORY_RANGES
static final int[][] CATEGORY_RANGES -
NMSTRT_INCLUDES
- See Also:
-
NMSTRT_EXCLUDE_RANGES
- See Also:
-
NMSTRT_CATEGORIES
- See Also:
-
NMCHAR_INCLUDES
- See Also:
-
NMCHAR_EXCLUDE_RANGES
- See Also:
-
NMCHAR_CATEGORIES
- See Also:
-
NONE
static final int NONE- See Also:
-
SOME
static final int SOME- See Also:
-
ALL
static final int ALL- See Also:
-
SURROGATES1_CLASS
- See Also:
-
SURROGATES2_CLASS
- See Also:
-
NOT_ALLOWED_CLASS
- See Also:
-
-
Method Details
-
translate
public static String translate(CharSequence regexp, boolean xpath, boolean ignoreWhitespace, boolean caseBlind) throws RegexSyntaxException Translates a regular expression in the syntax of XML Schemas Part 2 into a regular expression in the syntax ofjava.util.regex.Pattern
. The translation assumes that the string to be matched against the regex uses surrogate pairs correctly. If the string comes from XML content, a conforming XML parser will automatically check this; if the string comes from elsewhere, it may be necessary to check surrogate usage before matching.- Parameters:
regexp
- a String containing a regular expression in the syntax of XML Schemas Part 2xpath
- a boolean indicating whether the XPath 2.0 F+O extensions to the schema regex syntax are permitted- Throws:
RegexSyntaxException
- ifregexp
is not a regular expression in the syntax of XML Schemas Part 2, or XPath 2.0, as appropriate- See Also:
-
main
- Throws:
RegexSyntaxException
-