|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.stanford.nlp.util.XMLUtils
public class XMLUtils
Provides some utilities for dealing with XML files, both by properly parsing them and by using the methods of a desperate Perl hacker.
Nested Class Summary | |
---|---|
static class |
XMLUtils.XMLTag
|
Field Summary | |
---|---|
static Set<String> |
breakingTags
Block-level HTML tags that are rendered with surrounding line breaks. |
Method Summary | |
---|---|
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)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final Set<String> breakingTags
Method Detail |
---|
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 receipt
public 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 unescapeStringForXML(String s)
public static String escapeXML(String in)
in
- The String to escape
public static String escapeElementXML(String in)
in
- The String to escape
public static String escapeAttributeXML(String in)
in
- The String to escape
public static String escapeTextAroundXMLTags(String s)
public 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
public static void main(String[] args) throws Exception
Exception
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |