Package net.sf.saxon.om
Class NameChecker
- java.lang.Object
-
- net.sf.saxon.om.NameChecker
-
public abstract class NameChecker extends java.lang.Object
The NameChecker performs validation and analysis of XML names.In releases prior to 9.6, there were two name checkers, one for XML 1.0 and one for XML 1.1. However, XML 1.0 fifth edition uses the same rules for XML names as XML 1.1, so they were actually checking the same rules for names (although they were different when checking for valid characters). From 9.6, the name checker no longer performs checks for valid XML characters, so only one name checker is needed, and the methods have become static.
-
-
Constructor Summary
Constructors Constructor Description NameChecker()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String[]
checkQNameParts(java.lang.String qname)
Validate a QName, and return the prefix and local name.static java.lang.String
getPrefix(java.lang.String qname)
Extract the prefix from a QName.static java.lang.String[]
getQNameParts(java.lang.String qname)
static boolean
isNCNameChar(int ch)
Test whether a character can appear in an NCNamestatic boolean
isNCNameStartChar(int ch)
Test whether a character can appear at the start of an NCNamestatic boolean
isQName(IntIterator codePoints)
Validate whether a given string constitutes a valid QName, as defined in XML Namespaces.static boolean
isValidNCName(java.lang.String str)
static boolean
isValidNCName(IntIterator codePoints)
Validate whether a given string constitutes a valid NCName, as defined in XML Namespaces.static boolean
isValidNmtoken(UnicodeString in)
Check to see if a string is a valid Nmtoken according to [7] in the XML 1.0 Recommendation
-
-
-
Method Detail
-
isQName
public static boolean isQName(IntIterator codePoints)
Validate whether a given string constitutes a valid QName, as defined in XML Namespaces. Note that this does not test whether the prefix is actually declared.- Parameters:
codePoints
- the name to be tested, supplied as a codepoint iterator- Returns:
- true if the name is a lexically-valid QName
-
getPrefix
public static java.lang.String getPrefix(java.lang.String qname)
Extract the prefix from a QName. Note, the QName is assumed to be valid.- Parameters:
qname
- The lexical QName whose prefix is required- Returns:
- the prefix, that is the part before the colon. Returns an empty string if there is no prefix
-
getQNameParts
public static java.lang.String[] getQNameParts(java.lang.String qname) throws QNameException
- Throws:
QNameException
-
checkQNameParts
public static java.lang.String[] checkQNameParts(java.lang.String qname) throws XPathException
Validate a QName, and return the prefix and local name. Both parts are checked to ensure they are valid NCNames.Used from compiled code
- Parameters:
qname
- the lexical QName whose parts are required. Note that leading and trailing whitespace is not permitted- Returns:
- an array of two strings, the prefix and the local name. The first item is a zero-length string if there is no prefix.
- Throws:
XPathException
- if not a valid QName.
-
isValidNCName
public static boolean isValidNCName(IntIterator codePoints)
Validate whether a given string constitutes a valid NCName, as defined in XML Namespaces.- Parameters:
codePoints
- the name to be tested, as a codepoint iterator. Any whitespace trimming must have already been applied.- Returns:
- true if the name is a lexically-valid QName
-
isValidNCName
public static boolean isValidNCName(java.lang.String str)
-
isValidNmtoken
public static boolean isValidNmtoken(UnicodeString in)
Check to see if a string is a valid Nmtoken according to [7] in the XML 1.0 Recommendation- Parameters:
in
- the string to be tested. Any whitespace trimming must have already been applied.- Returns:
- true if nmtoken is a valid Nmtoken
-
isNCNameChar
public static boolean isNCNameChar(int ch)
Test whether a character can appear in an NCName- Parameters:
ch
- the character to be tested- Returns:
- true if this is a valid character in an NCName. The rules for XML 1.0 fifth edition are the same as the XML 1.1 rules, and these are the rules that we use.
-
isNCNameStartChar
public static boolean isNCNameStartChar(int ch)
Test whether a character can appear at the start of an NCName- Parameters:
ch
- the character to be tested- Returns:
- true if this is a valid character at the start of an NCName. The rules for XML 1.0 fifth edition are the same as the XML 1.1 rules, and these are the rules that we use.
-
-