|
|||||||||
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 java.util.Set<java.lang.String> |
breakingTags
Block-level HTML tags that are rendered with surrounding line breaks. |
Method Summary | |
---|---|
static java.lang.String |
escapeAttributeXML(java.lang.String in)
Returns a String in which some XML special characters have been escaped. |
static java.lang.String |
escapeElementXML(java.lang.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 java.lang.String |
escapeTextAroundXMLTags(java.lang.String s)
|
static java.lang.String |
escapeXML(java.lang.String in)
Returns a String in which all the XML special characters have been escaped. |
static int |
findSpace(java.lang.String haystack,
int begin)
return either the first space or the first nbsp |
static javax.xml.parsers.DocumentBuilder |
getValidatingXmlParser(java.io.File schemaFile)
Returns a validating XML parser given an XSD (not DTD!). |
static javax.xml.parsers.DocumentBuilder |
getXmlParser()
Returns a non-validating XML parser. |
static boolean |
isBreaking(java.lang.String tag)
|
static boolean |
isBreaking(XMLUtils.XMLTag tag)
|
static void |
main(java.lang.String[] args)
Tests a few methods. |
static XMLUtils.XMLTag |
parseTag(java.lang.String tagString)
|
static XMLUtils.XMLTag |
readAndParseTag(java.io.Reader r)
|
static org.w3c.dom.Document |
readDocumentFromFile(java.lang.String filename)
|
static org.w3c.dom.Document |
readDocumentFromString(java.lang.String s)
|
static java.lang.String |
readTag(java.io.Reader r)
Reads all text of the XML tag and returns it as a String. |
static java.lang.String |
readUntilTag(java.io.Reader r)
Reads all text up to next XML tag and returns it as a String. |
static java.lang.String |
stripTags(java.io.Reader r,
java.util.List<java.lang.Integer> mapBack,
boolean markLineBreaks)
|
static java.lang.String |
unescapeStringForXML(java.lang.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 java.util.Set<java.lang.String> breakingTags
Method Detail |
---|
public static javax.xml.parsers.DocumentBuilder getXmlParser()
public static javax.xml.parsers.DocumentBuilder getValidatingXmlParser(java.io.File schemaFile)
schemaFile
-
public static java.lang.String stripTags(java.io.Reader r, java.util.List<java.lang.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(java.lang.String tag)
public static boolean isBreaking(XMLUtils.XMLTag tag)
public static java.lang.String readUntilTag(java.io.Reader r) throws java.io.IOException
java.io.IOException
public static XMLUtils.XMLTag readAndParseTag(java.io.Reader r) throws java.io.IOException
java.io.IOException
public static java.lang.String unescapeStringForXML(java.lang.String s)
public static java.lang.String escapeXML(java.lang.String in)
in
- The String to escape
public static java.lang.String escapeElementXML(java.lang.String in)
in
- The String to escape
public static java.lang.String escapeAttributeXML(java.lang.String in)
in
- The String to escape
public static java.lang.String escapeTextAroundXMLTags(java.lang.String s)
public static int findSpace(java.lang.String haystack, int begin)
public static java.lang.String readTag(java.io.Reader r) throws java.io.IOException
r
- The reader to read from
<TXT>
java.io.IOException
public static XMLUtils.XMLTag parseTag(java.lang.String tagString)
public static org.w3c.dom.Document readDocumentFromFile(java.lang.String filename) throws java.lang.Exception
java.lang.Exception
public static org.w3c.dom.Document readDocumentFromString(java.lang.String s) throws java.lang.Exception
java.lang.Exception
public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |