public class XmlParser extends AbstractParser
This class isn't actually used by RSyntaxTextArea anywhere, but you can install and use it yourself. Doing so is as simple as:
XmlParser xmlParser = new XmlParser(); textArea.addParser(xmlParser);To support DTD validation, specify an entity resolver when creating the parser, and enable validation like so:
XmlParser xmlParser = new XmlParser(new MyEntityResolver()); xmlParser.setValidating(true); textArea.addParser(xmlParser);Also note that a single instance of this class can be installed on multiple instances of
RSyntaxTextArea
.
For a more complete XML parsing/validation solution, see the
RSTALanguageSupport
project's XmlLanguageSupport
class.
构造器和说明 |
---|
XmlParser() |
XmlParser(org.xml.sax.EntityResolver resolver)
Constructor allowing DTD validation of documents.
|
限定符和类型 | 方法和说明 |
---|---|
boolean |
isValidating()
Returns whether this parser does DTD validation.
|
ParseResult |
parse(RSyntaxDocument doc,
java.lang.String style)
Parses input from the specified document.
|
void |
setValidating(boolean validating)
Sets whether this parser will use DTD validation if required.
|
getHyperlinkListener, getImageBase, isEnabled, setEnabled, setHyperlinkListener
public XmlParser()
public XmlParser(org.xml.sax.EntityResolver resolver)
resolver
- An entity resolver to use if validation is enabled.setValidating(boolean)
public boolean isValidating()
setValidating(boolean)
public ParseResult parse(RSyntaxDocument doc, java.lang.String style)
doc
- The document to parse. This document is in a read lock,
so it cannot be modified while parsing is occurring.style
- The language being rendered, such as
SyntaxConstants.SYNTAX_STYLE_JAVA
.null
.public void setValidating(boolean validating)
validating
- Whether DTD validation should be enabled. If this is
true
, documents must specify a DOCTYPE, and you
should have used the constructor specifying an entity resolver.isValidating()