Skip to content
/ java-xml Public

A tool that makes your life easier when you need to read XML into a language inspired by coffee

License

Notifications You must be signed in to change notification settings

10usb/java-xml

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Java Xml

This is a utility to process Xml files. The aim is to automate the usual state pattern build around reading the content into a structure data set of own design.

It works by setting an initial state that gets called when an element is found, and it has to return a new state (could be the same, not recommended)

Events

  • OnOpen Called by the parser when this state it set as current state
  • OnClose Called by the parser when the closing tag of this state if found
  • OnElement Called when an element is found, this method should return a new state. Best is not to return it self
  • OnText Called by the parser when a text node is found
  • OnComment Called by the parser when a comment element is found

Example

Parser parser = new Parser(stream, new MyInitialState());
parser.Parse();
  class MyInitialState extends DefaultState {
    /* Some initialisation code... */
    @override
    public State onElement(QualifiedName qualifiedName, AttributeCollection attributes) {
      if (qualifiedName.equals("nameOfMyRootElement", "http://my.namespace.uri")) {
        return new /* Some state to handle the root element */;
      }
      return null;
    }
    /* The other events that can be triggerd */
  }

About

A tool that makes your life easier when you need to read XML into a language inspired by coffee

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages