public interface XMLEscape
This interface assumes that the values to be escapes do not orignate from XML text, in order words, there should not be already any entity or markup in the document. If it is the case the methods in this class should also escapes them. Thus "&" would be represented as "&".
Also the method will not try to escape characters that cannot be escaped.
This interface is based on the paragraph 2.4 of the XML 1.0 Specifications.
Modifier and Type | Method and Description |
---|---|
String |
getEncoding()
Returns the encoding used by the implementing class.
|
String |
toAttributeValue(char[] ch,
int off,
int len)
Returns a well-formed attribute value.
|
String |
toAttributeValue(String value)
Returns a well-formed attribute value.
|
String |
toElementText(char[] ch,
int off,
int len)
Returns a well-formed text value for the element.
|
String |
toElementText(String value)
Returns a well-formed text value for the element.
|
String toAttributeValue(char[] ch, int off, int len)
This method must replace any character in the specified value by the corresponding numeric character reference or the predefined XML general entities, if the character is not allowed or not in the encoding range.
Attribute values must not contain '&' or '<. Quotes and apostrophes must also be escaped by """ and "'" respectively.
ch
- The value that needs to be attribute-escaped.off
- The start (offset) of the characters.len
- The length of characters to.String toAttributeValue(String value)
Method provided for convenience, using the same specifications as
toAttributeValue(char[], int, int)
.
This method should return null
if the given
value is null
.
value
- The value that needs to be attribute-escaped.String toElementText(char[] ch, int off, int len)
This method must replace any character in the specified value by the corresponding numeric character reference or the predefined XML general entities, if the character is not allowed or not in the encoding range.
The text of an element must not contain '&' or '<.
ch
- The value that needs to be attribute-escaped.off
- The start (offset) of the characters.len
- The length of characters to.String toElementText(String value)
Method provided for convenience, using the same specifications as
toElementText(char[], int, int)
.
This method should return null
if the given
value is null
.
value
- The value that needs to be text-escaped.String getEncoding()
Copyright © 2007-2014. All Rights Reserved.