Class XmlParser

java.lang.Object
org.fife.ui.rsyntaxtextarea.parser.AbstractParser
org.fife.rsta.ac.xml.XmlParser
All Implemented Interfaces:
org.fife.ui.rsyntaxtextarea.parser.Parser

public class XmlParser extends org.fife.ui.rsyntaxtextarea.parser.AbstractParser
Parses XML code in an RSyntaxTextArea.

Like all RSTA Parsers, an XmlParser instance is notified when the RSTA's text content changes. After a small delay, it will parse the content as XML, building an AST and looking for any errors. When parsing is complete, a property change event of type PROPERTY_AST is fired. Listeners can check the new value of the property for an XmlTreeNode that represents the root of a tree structure modeling the XML content in the text area. Note that the XmlTreeNode may be incomplete if there were parsing/syntax errors (it will usually be complete "up to" the error in the content).

This parser cannot be shared amongst multiple instances of RSyntaxTextArea.

Version:
1.0
  • Field Details

  • Constructor Details

  • Method Details

    • addPropertyChangeListener

      public void addPropertyChangeListener(String prop, PropertyChangeListener l)
      Adds a listener to this parser. Typically you'd want to register a listener on the PROPERTY_AST property.
      Parameters:
      prop - The property to listen for changes on.
      l - The listener itself.
      See Also:
    • getAst

      public XmlTreeNode getAst()
      Returns the XML model from the last time it was parsed.
      Returns:
      The root node of the XML model, or null if it has not yet been parsed or an error occurred while parsing.
    • getMainAttribute

      private String getMainAttribute(Attributes attributes)
      Returns a string representing the "main" attribute for an element.
      Parameters:
      attributes - The attributes of an element. Calling code should have already verified this has length > 0.
      Returns:
      The "main" attribute.
    • getSaxParserFactory

      public SAXParserFactory getSaxParserFactory()
    • parse

      public org.fife.ui.rsyntaxtextarea.parser.ParseResult parse(org.fife.ui.rsyntaxtextarea.RSyntaxDocument doc, String style)
    • removePropertyChangeListener

      public void removePropertyChangeListener(String prop, PropertyChangeListener l)
      Removes a listener on a specific property.
      Parameters:
      prop - The property being listened to.
      l - The listener to remove.
      See Also:
    • setValidationConfig

      public void setValidationConfig(ValidationConfig config)
      Sets how validation will be done by this parser. This can be used to set up either DTD or Schema validation.
      Parameters:
      config - Configuration information for validation. If this is null, no validation will be done.