##### Commons SCXML Resources

- Overview
- User Guide
  - SCXML documents
  - Using Commons SCXML
  - Standalone Testing
  - SCXML Parser
  - SCXML datamodel
  - Contexts and Evaluators
  - SCXML Engine
  - Triggering Events
  - Custom Actions
  - Custom Semantics
  - Side Effect - EL
- Javadoc
- FAQ
- Usecases
- Building
- Dependencies
- Mailing lists
- Team
- SVN repository
- Nightly snapshots

##### Releases

- Version 0.7
- Version 0.6
- Version 0.5

##### Project Documentation

- About
- Project Info
- Project Reports
- Development Process

##### Commons

- Home
- Components
- Sandbox
- Dormant
- Volunteering
- Contributing Patches
- Building Components
- Releasing Components
- Wiki

##### Legend

- External Link
- Opens in a new window

## Commons SCXML - Parsing SCXML documents for Commons SCXML

Commons SCXML provides its own implementation of the Java object model for SCXML and a configured Digester that can parse SCXML documents into that object model.

### Usage

The primary convenience method exposed by the `SCXMLParser` is:

            //import java.io.IOException;
            //import java.net.URL;
            //import org.apache.commons.scxml.io.SCXMLParser;
            //import org.apache.commons.scxml.model.ModelException;
            //import org.apache.commons.scxml.model.SCXML;
            //import org.xml.sax.ErrorHandler;
            //import org.xml.sax.SAXException;

            SCXML scxml = null;

            try {
              scxml = SCXMLParser.parse(<URL>, <ErrorHandler>);
            } catch (IOException ioe) {
              // IOException while parsing
            } catch (SAXException se) {
              // SAXException while parsing
            } catch (ModelException me) {
              // ModelException while parsing
            }

            if (scxml == null) {
              // Parsing failed
            }

It returns an `SCXML` object, which is the state machine / chart represented in the Commons SCXML Java object model. This method uses the `URL` of the initial SCXML document to resolve any relative URLs referenced by the document, such as `src` attributes of `State` SCXML elements.

Commons SCXML provides convenience implementations of most of the interfaces such as `ErrorHandler`.

The SCXMLParser exposes other convenience methods which can handle a SCXML document specified using its "real path" on the local system, in which case an additional `org.apache.commons.SCXML.PathResolver`parameter needs to be supplied for resolving relative document references or as an `InputSource`, in which case there is no path resolution, so the document must be a standalone document.

The `SCXMLParser` Javadoc is available here.

### API notes set

The next note in this set describes the SCXML engine.