RelaxNGCC ( RELAX NG Compiler Compiler)
RelaxNGCC is a tool for generating Java source code from a given RELAX NG grammar. By embedding code fragments in the grammar like yacc or JavaCC, you can take appropriate actions while parsing valid XML documents against the grammar.
JRE 1.2 or later is required to run the compiler.
Generated code will only need a SAX parser to run.
Feature Highlights
Relaxer is another famous tool for generating Java source code from a given grammar, but RelaxNGCC is different from Relaxer at following points.
- The code generated by RelaxNGCC can ignore unnecessary parts of the input XML document while Relaxer retrieves all information in the document. It is powerful especially when you want to extract necessary data from XML instances.
- RelaxNGCC focuses on reading XML instances. Generation of XML documents from Java objects is outside the scope of RelaxNGCC.
- RelaxNGCC makes programming easy for reading XML in comparison with writing raw DOM or SAX code.
Your Comment
If you hava any comments, questions, or requests, please post them to reldeve mailing list, where all the developers are monitoring. We always welcome your comments, as those are the ultimate motivation that drives us to further development.
License
RelaxNGCC is licensed under Apache Software License-like license. For the code generated by RelaxNGCC, we waive our copyrights, so they are all yours.
Note about AttributesImpl.java
The generated AttributesImpl.java is used as an implementation of org.xml.sax.Attributes
. It is based on the source code of org.xml.sax.helpers.AttributesImpl
distributed with some products such as Xerces, but the original org.xml.sax.helpers.AttributesImpl
has a bug in removeAttribute method. To avoid the bug, I modified the original and located at relaxngcc.runtime package. relaxngcc.runtime.AttributesImpl.java
is in the public domain like the original for this reason. The bug has not been fixed in JRE1.4.
Release Notes
- May 3, 2002 Version 0.7 is released.
- Added
inline
attribute for expanding a scope into other scopes.
- Revised manuals.
- Jun, 2002 Version 1.0 is released
- Kohsuke Kawaguchi joined the development and the project is now hosted at SourceForge.
- RelaxNGCC became self-sufficient; now it uses itself to parse RELAX NG grammars.
- Replaced the compiler algorithm so that it generates code that works correctly
- Implemented an experimental text-based shorthand syntax.
- Added new features represented by c:with-params, c:params, c:return-type, and c:return-value attributes.
- Runtime code is refactored. The compiler now generates NGCCRuntime class, which coordinates the entire processing.
- The RELAX NG compact syntax support was pulled out.
- The compiler is now smart enough to handle multiple aliases with the same name, and aliases colliding with fields defined in c:java-body elements.
-
Oct, 2002 Version 1.1 is released.
- Implemented an Ant task for RelaxNGCC.
- Introduced CodeDOM for more stable code generation.
cc:class
attribute can be now specified for any pattern, and it will become its own class, as if it were <define>d as a separate block.
- Organized the structure of the generated code especially the treatment of attributes.
Earlier release notes are available here.
Wish list for future versions
- Token looking ahead support to handle ambiguous schemas
- Supporting code generation in other languages, such as C#
- Enhancing documents, especially internal algorithm
To file a feature request, please visit the project website at SourceForge.
Related resources