Package net.sf.saxon.value
Class Whitespace
java.lang.Object
net.sf.saxon.value.Whitespace
This class provides helper methods and constants for handling whitespace
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
static final int
static final int
The values NONE, IGNORABLE, and ALL identify which kinds of whitespace text node should be stripped when building a source treestatic final int
The values PRESERVE, REPLACE, and COLLAPSE represent the three options for whitespace normalization.static final int
static final int
-
Method Summary
Modifier and TypeMethodDescriptionstatic CharSequence
applyWhitespaceNormalization
(int action, CharSequence value) Apply schema-defined whitespace normalization to a stringstatic CharSequence
Collapse whitespace as defined in XML Schemastatic boolean
containsWhitespace
(CharSequence value) Determine if a string contains any whitespacestatic final boolean
isWhite
(CharSequence content) Determine if a string is all-whitespacestatic boolean
isWhitespace
(int ch) Test whether a character is whitespacestatic CharSequence
Normalize whitespace as defined in XML Schemastatic CharSequence
removeAllWhitespace
(CharSequence value) Remove all whitespace characters from a stringstatic CharSequence
Remove leading whitespace characters from a stringstatic CharSequence
Remove leading and trailing whitespace.
-
Field Details
-
PRESERVE
public static final int PRESERVEThe values PRESERVE, REPLACE, and COLLAPSE represent the three options for whitespace normalization. They are deliberately chosen in ascending strength order; given a number of whitespace facets, only the strongest needs to be carried out.- See Also:
-
REPLACE
public static final int REPLACE- See Also:
-
COLLAPSE
public static final int COLLAPSE- See Also:
-
NONE
public static final int NONEThe values NONE, IGNORABLE, and ALL identify which kinds of whitespace text node should be stripped when building a source tree- See Also:
-
IGNORABLE
public static final int IGNORABLE- See Also:
-
ALL
public static final int ALL- See Also:
-
UNSPECIFIED
public static final int UNSPECIFIED- See Also:
-
-
Method Details
-
isWhitespace
public static boolean isWhitespace(int ch) Test whether a character is whitespace -
applyWhitespaceNormalization
Apply schema-defined whitespace normalization to a string- Parameters:
action
- the action to be applied: one of PRESERVE, REPLACE, or COLLAPSEvalue
- the value to be normalized- Returns:
- the value after normalization
-
removeAllWhitespace
Remove all whitespace characters from a string -
removeLeadingWhitespace
Remove leading whitespace characters from a string -
containsWhitespace
Determine if a string contains any whitespace -
isWhite
Determine if a string is all-whitespace- Parameters:
content
- the string to be tested- Returns:
- true if the supplied string contains no non-whitespace characters
-
normalizeWhitespace
Normalize whitespace as defined in XML Schema -
collapseWhitespace
Collapse whitespace as defined in XML Schema -
trimWhitespace
Remove leading and trailing whitespace. This has the same effect as collapseWhitespace, but is cheaper, for use by data types that do not allow internal whitespace.- Parameters:
in
- the input string whose whitespace is to be removed- Returns:
- the result of removing excess whitespace
-