public class XMLUtils extends Object
Modifier and Type | Class and Description |
---|---|
static class |
XMLUtils.XMLTag |
Modifier and Type | Field and Description |
---|---|
static Set<String> |
breakingTags
Block-level HTML tags that are rendered with surrounding line breaks.
|
Modifier and Type | Method and Description |
---|---|
static String |
escapeAttributeXML(String in)
Returns a String in which some XML special characters have been
escaped.
|
static String |
escapeElementXML(String in)
Returns a String in which some the XML special characters have been
escaped: just the ones that need escaping in an element content.
|
static String |
escapeTextAroundXMLTags(String s) |
static String |
escapeXML(String in)
Returns a String in which all the XML special characters have been
escaped.
|
static int |
findSpace(String haystack,
int begin)
return either the first space or the first nbsp
|
static DocumentBuilder |
getValidatingXmlParser(File schemaFile)
Returns a validating XML parser given an XSD (not DTD!).
|
static DocumentBuilder |
getXmlParser()
Returns a non-validating XML parser.
|
static boolean |
isBreaking(String tag) |
static boolean |
isBreaking(XMLUtils.XMLTag tag) |
static void |
main(String[] args)
Tests a few methods.
|
static XMLUtils.XMLTag |
parseTag(String tagString) |
static XMLUtils.XMLTag |
readAndParseTag(Reader r) |
static Document |
readDocumentFromFile(String filename) |
static Document |
readDocumentFromString(String s) |
static String |
readTag(Reader r)
Reads all text of the XML tag and returns it as a String.
|
static String |
readUntilTag(Reader r)
Reads all text up to next XML tag and returns it as a String.
|
static String |
stripTags(Reader r,
List<Integer> mapBack,
boolean markLineBreaks) |
static String |
unescapeStringForXML(String s) |
public static DocumentBuilder getXmlParser()
public static DocumentBuilder getValidatingXmlParser(File schemaFile)
schemaFile
- public static String stripTags(Reader r, List<Integer> mapBack, boolean markLineBreaks)
r
- the reader to read the XML/HTML frommapBack
- a List of Integers mapping the positions in the result buffer
to positions in the original Reader, will be cleared on receiptpublic static boolean isBreaking(String tag)
public static boolean isBreaking(XMLUtils.XMLTag tag)
public static String readUntilTag(Reader r) throws IOException
IOException
public static XMLUtils.XMLTag readAndParseTag(Reader r) throws IOException
IOException
public static String escapeXML(String in)
in
- The String to escapepublic static String escapeElementXML(String in)
in
- The String to escapepublic static String escapeAttributeXML(String in)
in
- The String to escapepublic static int findSpace(String haystack, int begin)
public static String readTag(Reader r) throws IOException
r
- The reader to read from<TXT>
IOException
public static XMLUtils.XMLTag parseTag(String tagString)
public static Document readDocumentFromFile(String filename) throws Exception
Exception
public static Document readDocumentFromString(String s) throws Exception
Exception