The java.swing.tree option enables an interpreter facility for Relaxer objects.
The java.swing.tree option takes one of the following values as a parameter:
The default configuration is false
.
No parameter implies that the parameter is 'true
'.
The java.swing.tree option generates
no additional classes, but RelaxerOrg.jar
is needed
for the class library.
The java.swing.tree option adds the following methods to Relaxer objects.
rGetParentRNode()
rSetParentRNode(IRNode)
rGetRNodes()
Object eval()
Object eval(IREvaluationContext)
Object eval(Object[], IREvaluationContext)
The rGetParentRNode
mehtod,
the rSetParentRNode
method, and
the rGetRNodes
methods are derived
from the java.pattern.composite option.
Three eval
methods are methods for interpreter.(?)
List 4.19.3.1[javaSwingTree.rng] is a sample schema for the java.swing.tree option.
<grammar xmlns="http://relaxng.org/ns/structure/1.0" xmlns:java="http://www.relaxer.org/xmlns/relaxer/java" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"> <start> <ref name="account"/> </start> <define name="account"> <element name="account"> <attribute name="accountNo"> <data type="token"/> </attribute> <element name="balance"> <data type="int"/> </element> <element name="owner"> <data type="token"/> </element> <optional> <ref name="address"/> </optional> <zeroOrMore> <ref name="phone"/> </zeroOrMore> </element> </define> <define name="address"> <element name="address"> <attribute name="zip"> <data type="token"/> </attribute> <text/> </element> </define> <define name="phone"> <element name="phone"> <attribute name="area"> <data type="token"/> </attribute> <data type="token"/> </element> </define> </grammar>
Execution of Relaxer with the java.swing.tree option is as follows:
$ relaxer -java -java.swing.tree javaSwingTree.rng
Because the Java generator is a default generator, execution of Relaxer as shown below has the same effect:
$ relaxer -java.swing.tree javaSwingTree.rng
As a result, Relaxer generates six files:
List 4.19.3.1.1[JavaSwingTree.java] is a sample program for the java.swing.tree option.
import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import javax.swing.*; import javax.swing.tree.*; public class JavaSwingTree { public static void main(String[] args) throws Exception { String fileName = args[0]; Account account = new Account(fileName); JTree jtree = new JTree(account); JFrame jframe = new JFrame("java.swing.tree"); jframe.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent evt) { System.exit(0); } } ); jframe.getContentPane().add(new JScrollPane(jtree)); jframe.pack(); jframe.setVisible(true); } }
Compilation of JavaSwingTree
class is shown here:
$ javac JavaSwingTree.java
List 4.19.3.2.1[javaSwingTree.xml] is an XML document for testing.
<account accountNo="12345"> <balance>102030</balance> <owner>XML Taro</owner> <address zip="213">Yokohama</address> <phone area="123">456-7890</phone> <phone area="090">123-4567</phone> </account>
Execution of the JavaSwingTree
class is shown here:
$ java JavaSwingTree javaSwingTree.xml
(??)