net.sf.saxon.regex

Class JDK15RegexTranslator

public class JDK15RegexTranslator extends Object

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
static classJDK15RegexTranslator.BackReference
abstract static classJDK15RegexTranslator.CharClass
static classJDK15RegexTranslator.CharRange
static classJDK15RegexTranslator.Complement
static classJDK15RegexTranslator.Empty
static classJDK15RegexTranslator.Property
static classJDK15RegexTranslator.Range
abstract static classJDK15RegexTranslator.SimpleCharClass
static classJDK15RegexTranslator.SingleChar
static classJDK15RegexTranslator.Subtraction
static classJDK15RegexTranslator.Union
Field Summary
static intALL
static StringCATEGORY_NAMES
static int[][]CATEGORY_RANGES
static StringNMCHAR_CATEGORIES
static StringNMCHAR_EXCLUDE_RANGES
static StringNMCHAR_INCLUDES
static StringNMSTRT_CATEGORIES
static StringNMSTRT_EXCLUDE_RANGES
static StringNMSTRT_INCLUDES
static intNONE
static StringNOT_ALLOWED_CLASS
static intSOME
static StringSURROGATES1_CLASS
static StringSURROGATES2_CLASS
Method Summary
static voidmain(String[] args)
static Stringtranslate(CharSequence regexp, boolean xpath)
Translates a regular expression in the syntax of XML Schemas Part 2 into a regular expression in the syntax of java.util.regex.Pattern.

Field Detail

ALL

static final int ALL

CATEGORY_NAMES

static final String CATEGORY_NAMES

CATEGORY_RANGES

static final int[][] CATEGORY_RANGES

NMCHAR_CATEGORIES

static final String NMCHAR_CATEGORIES

NMCHAR_EXCLUDE_RANGES

static final String NMCHAR_EXCLUDE_RANGES

NMCHAR_INCLUDES

static final String NMCHAR_INCLUDES

NMSTRT_CATEGORIES

static final String NMSTRT_CATEGORIES

NMSTRT_EXCLUDE_RANGES

static final String NMSTRT_EXCLUDE_RANGES

NMSTRT_INCLUDES

static final String NMSTRT_INCLUDES

NONE

static final int NONE

NOT_ALLOWED_CLASS

static final String NOT_ALLOWED_CLASS

SOME

static final int SOME

SURROGATES1_CLASS

static final String SURROGATES1_CLASS

SURROGATES2_CLASS

static final String SURROGATES2_CLASS

Method Detail

main

public static void main(String[] args)

translate

public static String translate(CharSequence regexp, boolean xpath)
Translates a regular expression in the syntax of XML Schemas Part 2 into a regular expression in the syntax of java.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 2 xpath a boolean indicating whether the XPath 2.0 F+O extensions to the schema regex syntax are permitted

Throws: RegexSyntaxException if regexp is not a regular expression in the syntax of XML Schemas Part 2, or XPath 2.0, as appropriate

See Also: java.util.regex.Pattern XML Schema Part 2