Author: awiner
Date: Mon May  8 17:25:44 2006
New Revision: 405242

URL: http://svn.apache.org/viewcvs?rev=405242&view=rev
Log:
Remove dependencies on oracle.bali.rts and Oracle XML parser

Added:
    
incubator/adffaces/trunk/plugins/maven-xrts-plugin/src/main/java/org/apache/myfaces/adfbuild/plugin/xrts/ListRTSWriter.java
    
incubator/adffaces/trunk/plugins/maven-xrts-plugin/src/main/java/org/apache/myfaces/adfbuild/plugin/xrts/OrderedDictionary.java
    
incubator/adffaces/trunk/plugins/maven-xrts-plugin/src/main/java/org/apache/myfaces/adfbuild/plugin/xrts/RTSWriter.java
    
incubator/adffaces/trunk/plugins/maven-xrts-plugin/src/main/java/org/apache/myfaces/adfbuild/plugin/xrts/UnicodeEscapes.java
    
incubator/adffaces/trunk/plugins/maven-xrts-plugin/src/main/java/org/apache/myfaces/adfbuild/plugin/xrts/XRTSGenerator.java
    
incubator/adffaces/trunk/plugins/maven-xrts-plugin/src/main/java/org/apache/myfaces/adfbuild/plugin/xrts/XRTSParser.java
Modified:
    incubator/adffaces/trunk/plugins/maven-xrts-plugin/pom.xml
    
incubator/adffaces/trunk/plugins/maven-xrts-plugin/src/main/java/org/apache/myfaces/adfbuild/plugin/xrts/AbstractGenerateSourcesMojo.java

Modified: incubator/adffaces/trunk/plugins/maven-xrts-plugin/pom.xml
URL: 
http://svn.apache.org/viewcvs/incubator/adffaces/trunk/plugins/maven-xrts-plugin/pom.xml?rev=405242&r1=405241&r2=405242&view=diff
==============================================================================
--- incubator/adffaces/trunk/plugins/maven-xrts-plugin/pom.xml (original)
+++ incubator/adffaces/trunk/plugins/maven-xrts-plugin/pom.xml Mon May  8 
17:25:44 2006
@@ -15,16 +15,6 @@
 
   <dependencies>
     <dependency>
-      <groupId>oracle.bali.rts</groupId>
-      <artifactId>rts</artifactId>
-      <version>2.0.6</version>
-    </dependency>
-    <dependency>
-      <groupId>oracle.xml</groupId>
-      <artifactId>xmlparserv2</artifactId>
-      <version>9.2.0.3.0</version>
-    </dependency>
-    <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-plugin-api</artifactId>
       <version>2.0</version>

Modified: 
incubator/adffaces/trunk/plugins/maven-xrts-plugin/src/main/java/org/apache/myfaces/adfbuild/plugin/xrts/AbstractGenerateSourcesMojo.java
URL: 
http://svn.apache.org/viewcvs/incubator/adffaces/trunk/plugins/maven-xrts-plugin/src/main/java/org/apache/myfaces/adfbuild/plugin/xrts/AbstractGenerateSourcesMojo.java?rev=405242&r1=405241&r2=405242&view=diff
==============================================================================
--- 
incubator/adffaces/trunk/plugins/maven-xrts-plugin/src/main/java/org/apache/myfaces/adfbuild/plugin/xrts/AbstractGenerateSourcesMojo.java
 (original)
+++ 
incubator/adffaces/trunk/plugins/maven-xrts-plugin/src/main/java/org/apache/myfaces/adfbuild/plugin/xrts/AbstractGenerateSourcesMojo.java
 Mon May  8 17:25:44 2006
@@ -26,13 +26,9 @@
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
-import java.util.Properties;
 
-
-import oracle.bali.rts.tools.RTSWriter;
-import oracle.bali.rts.tools.XRTSGenerator;
-
-import oracle.xml.parser.v2.SAXParser;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
 
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
@@ -97,6 +93,9 @@
         Dictionary params = new Hashtable();
 
         List dirtyXRTS = new LinkedList(Arrays.asList(xrtsFiles));
+        SAXParserFactory factory = SAXParserFactory.newInstance();
+        factory.setValidating(false);
+
         for (Iterator i=dirtyXRTS.iterator(); i.hasNext();)
         {
           String xrtsFile = (String)i.next();
@@ -129,10 +128,8 @@
             params.put("outFile", targetFile);
             params.put("outName", baseName);
             params.put("srcName", baseName);
-            params.put("validate", Boolean.FALSE);
             params.put("quietMode", Boolean.TRUE);
 
-            SAXParser parser = new SAXParser();
             InputSource source = new InputSource(new 
FileInputStream(sourceFile));
             // setup relative systemId resolution for local rts.dtd files.
             source.setSystemId(sourceFile.getParentFile().toURL().toString());
@@ -142,6 +139,7 @@
               if (targetFile.exists())
                 targetFile.delete();
 
+              SAXParser parser = factory.newSAXParser();
               targetFile.getParentFile().mkdirs();
               XRTSGenerator.generate(parser, source, writer, params);
               targetFile.setReadOnly();
@@ -158,10 +156,6 @@
 
   private RTSWriter getRTSWriter() throws IOException, MojoExecutionException
   {
-    InputStream config = XRTSGenerator.class.getResourceAsStream("Config.txt");
-    if (config == null)
-      throw new IllegalStateException("Missing Config.text");
-
     String implClassName;
 
     String targetType = getTargetType();
@@ -171,14 +165,9 @@
     }
     else
     {
-      Properties props = new Properties();
-      props.load(config);
-      config.close();
-
-      implClassName = (String)props.get(targetType);
-
-      if (implClassName == null)
-        throw new IllegalArgumentException("Unrecognized targetType: " + 
targetType);
+      if ("list".equals(targetType))
+        return new ListRTSWriter();
+      throw new MojoExecutionException("Unknown bundle type: " + targetType);
     }
 
     try

Added: 
incubator/adffaces/trunk/plugins/maven-xrts-plugin/src/main/java/org/apache/myfaces/adfbuild/plugin/xrts/ListRTSWriter.java
URL: 
http://svn.apache.org/viewcvs/incubator/adffaces/trunk/plugins/maven-xrts-plugin/src/main/java/org/apache/myfaces/adfbuild/plugin/xrts/ListRTSWriter.java?rev=405242&view=auto
==============================================================================
--- 
incubator/adffaces/trunk/plugins/maven-xrts-plugin/src/main/java/org/apache/myfaces/adfbuild/plugin/xrts/ListRTSWriter.java
 (added)
+++ 
incubator/adffaces/trunk/plugins/maven-xrts-plugin/src/main/java/org/apache/myfaces/adfbuild/plugin/xrts/ListRTSWriter.java
 Mon May  8 17:25:44 2006
@@ -0,0 +1,178 @@
+/*
+* Copyright 2006 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.myfaces.adfbuild.plugin.xrts;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.PrintWriter;
+import java.util.Dictionary;
+//import java.util.StringTokenizer;
+
+
+/**
+ * The <code>ListRTSWriter</code> class is an implementation of the
+ * <code>RTSWriter</code> interface used to create a Sun
+ * <code>ListResourceBundle</code> file.
+ *
+ * @version $Name:  $ ($Revision: 1.11 $) $Date: 2002/02/27 17:18:47 $
+ * @author Craig R. Cummings
+ * @since RTS 2.0
+ */
+public class ListRTSWriter implements RTSWriter
+{
+
+  /**
+   * Empty constructor for the <code>ListResourceBundle</code> implementation
+   *
+   */
+  public ListRTSWriter()
+  {
+  }
+
+  /**
+   * <code>RTSWriter</code> method implementation to write the header of the
+   * <code>ListResourceBundle</code> file.
+   *
+   * @param parms a <code>Dictionary</code> of command line parameters.
+   * @param meta a <code>Dictionary</code> of parsed non-resource data
+   * (e.g., authors).
+   */
+  public void startBundle(Dictionary parms, Dictionary meta)
+    throws Throwable
+  {
+    File outFile = (File)parms.get("outFile");
+    String outName = (String)parms.get("outName");
+    String srcName = (String)parms.get("srcName");
+
+    Boolean b = (Boolean)parms.get("quietMode");
+    boolean quietMode = b.booleanValue();
+    if (!quietMode)
+    {
+      System.out.println("  " + outFile);
+    }
+
+    _pw = new PrintWriter(new BufferedWriter(new FileWriter(outFile)));
+
+    _pw.println("// Do not edit this file!");
+    _pw.println("// This file has been automatically generated.");
+
+    String rtsFileType = "xrts";
+    if (meta != null)
+      rtsFileType = (String)meta.get("fileType");
+    _pw.println("// Edit " + srcName + "." + rtsFileType + " and run the " +
+      rtsFileType.toUpperCase() + "MakeBundle tool instead.");
+    _pw.println("// ");
+
+    String packageName = (String)parms.get("pkgName");
+    if (packageName == null)
+      if (meta != null)
+        if (meta.get("package") != null)
+          packageName = (String)meta.get("package");
+
+    if (packageName != null &&
+      (!packageName.equals("") || !packageName.trim().equals("")))
+    {
+      _pw.println("package " + packageName + ";");
+      _pw.println("");
+    }
+
+    _pw.println("import java.util.ListResourceBundle;");
+
+    writeImports(parms, meta);
+
+    _pw.println("");
+    _pw.println("public class " + outName + " extends ListResourceBundle {");
+    _pw.println("  public Object[][] getContents() {");
+    _pw.println("    return contents;");
+    _pw.println("  }");
+    _pw.println("");
+    _pw.println("  static final Object[][] contents = {");
+  }
+
+  protected void writeImports(Dictionary parms, Dictionary meta)
+     throws Throwable
+  {
+  }
+
+  public void writeString(Dictionary parms, Dictionary meta, String key,
+    String value, Dictionary attr) throws Throwable
+  {
+    _pw.println("    {\"" + UnicodeEscapes.convert(key) + "\", \"" +
+                UnicodeEscapes.convert(value) + "\"},");
+
+// Comments can be preserved with RTS.  The commented out code below
+// was for demonstrating that this worked properly.  As comments are
+// not required in the ListResourceBundle, this code is here only to guide
+// developers in their RTSWriter interface implementation.
+//      String comments = rts.getComment(key);
+//      if (comments.length() > 0 )
+//      {
+//        StringTokenizer st = new StringTokenizer(comments, "\n");
+//        while (st.hasMoreTokens())
+//          _pw.println("// " + st.nextToken());
+//      }
+
+  }
+
+
+  public void writeStringArray(Dictionary parms, Dictionary meta, String key,
+   String[] strArr, Dictionary[] attrs) throws Throwable
+  {
+    _pw.println("    {\"" + key + "\",");
+    _pw.println("       new String[] {");
+
+    for (int i = 0; i < (strArr.length - 1); i++)
+      _pw.println("           \"" + UnicodeEscapes.convert(strArr[i]) + "\",");
+    // the last line of the string array shouldn't have a comma
+
+    _pw.println("           \"" +
+                UnicodeEscapes.convert(strArr[strArr.length-1]) + "\"");
+    _pw.println("       }");
+    _pw.println("    },");
+  }
+
+  public void writeDictionary(Dictionary parms, Dictionary meta, String key,
+    Dictionary kvps, Dictionary attrs) throws Throwable
+  {
+    System.err.println("Dictionary \'" + key + "\' was found in XML-based " +
+      "RTS, but is not supported by ListResourceBundle.  Use XRTSMakeBundle " +
+      "subkey instead.");
+  }
+
+  /**
+   * <code>RTSWriter</code> method implementation to close the file stream
+   * required for the <code>ListResourceBundle</code>.  Before closing, this
+   * method also writes the footer portions of the file.  The footer portions
+   * consist of little more than closing braces.
+   *
+   * @param meta a <code>Dictionary</code> of parsed non-resource data
+   * (e.g., authors).
+   */
+  public void endBundle(Dictionary parms, Dictionary meta) throws Throwable
+  {
+    _pw.println("  };");
+    _pw.println("}");
+    _pw.close();
+  }
+
+  protected PrintWriter getOut()
+  {
+    return _pw;
+  }
+
+  private PrintWriter _pw;
+}

Added: 
incubator/adffaces/trunk/plugins/maven-xrts-plugin/src/main/java/org/apache/myfaces/adfbuild/plugin/xrts/OrderedDictionary.java
URL: 
http://svn.apache.org/viewcvs/incubator/adffaces/trunk/plugins/maven-xrts-plugin/src/main/java/org/apache/myfaces/adfbuild/plugin/xrts/OrderedDictionary.java?rev=405242&view=auto
==============================================================================
--- 
incubator/adffaces/trunk/plugins/maven-xrts-plugin/src/main/java/org/apache/myfaces/adfbuild/plugin/xrts/OrderedDictionary.java
 (added)
+++ 
incubator/adffaces/trunk/plugins/maven-xrts-plugin/src/main/java/org/apache/myfaces/adfbuild/plugin/xrts/OrderedDictionary.java
 Mon May  8 17:25:44 2006
@@ -0,0 +1,51 @@
+/*
+* Copyright 2006 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.myfaces.adfbuild.plugin.xrts;
+
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Vector;
+
+/**
+ * The <code>OrderedDictionary</code> class is an implementation of the
+ * Sun's <code>Hashtable</code> that guarantees order of keys.
+ *
+ * @version $Name:  $ ($Revision: 1.2 $) $Date: 2001/04/09 23:20:09 $
+ * @author Craig R. Cummings
+ */
+final class OrderedDictionary extends Hashtable
+{
+  OrderedDictionary()
+  {
+    super();
+    _keys = new Vector();
+  }
+
+  public synchronized Enumeration keys()
+  {
+    return _keys.elements();
+  }
+
+  public synchronized Object put(Object key, Object value)
+  {
+    Object oldValue = super.put(key, value);
+    _keys.addElement(key);
+
+    return oldValue;
+  }
+
+  private Vector _keys;
+}

Added: 
incubator/adffaces/trunk/plugins/maven-xrts-plugin/src/main/java/org/apache/myfaces/adfbuild/plugin/xrts/RTSWriter.java
URL: 
http://svn.apache.org/viewcvs/incubator/adffaces/trunk/plugins/maven-xrts-plugin/src/main/java/org/apache/myfaces/adfbuild/plugin/xrts/RTSWriter.java?rev=405242&view=auto
==============================================================================
--- 
incubator/adffaces/trunk/plugins/maven-xrts-plugin/src/main/java/org/apache/myfaces/adfbuild/plugin/xrts/RTSWriter.java
 (added)
+++ 
incubator/adffaces/trunk/plugins/maven-xrts-plugin/src/main/java/org/apache/myfaces/adfbuild/plugin/xrts/RTSWriter.java
 Mon May  8 17:25:44 2006
@@ -0,0 +1,207 @@
+/*
+* Copyright 2006 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.myfaces.adfbuild.plugin.xrts;
+
+import java.util.Dictionary;
+import java.util.Enumeration;
+
+/**
+ * The <code>RTSWriter</code> interface defines methods for writing the
+ * header, body, and footer of various output implementations. <p>
+ *
+ * The methods <code>startBundle</code> and <code>endBundle</code> write the
+ * header and footer portions to the output.  The methods for writing the
+ * body are <code>writeString</code>, <code>writeStringArray</code>, and
+ * <code>writeDictionary</code>. These methods are supplied with data parsed
+ * by the XML-based RTS file <code>XRTSParser</code> or the
+ * <code>RTSProperties</code> parser.<p>
+ *
+ * RTS provides two basic implementations of RTSWriter --
+ * <code>ListRTSWriter</code> and <code>DefaultSubkeyRTSWriter</code>. <p>
+ *
+ * <code>ListRTSWriter</code> writes parsed data into a Sun
+ * <code>ListResourceBundle</code> file.  It utilizes the 
<code>writeString</code>
+ * and <code>writeStringArray</code> methods.  Data stored in Dictionary format
+ * cannot be processed by <code>ListResourceBundle</code>s and
+ * <code>ListRTSWriter</code> will throw an exception. <p>
+ *
+ * Those consumers with a requirement to store and process
+ * <code>Dictionary</code> format information should use
+ * <code>DefaultSubkeyResourceBundle</code>. 
<code>DefaultSubkeyRTSWriter</code>
+ * writes parsed data to an Oracle RTS <code>DefaultSubkeyResourceBundle</code>
+ * file. <code>DefaultSubkeyResourceBundle</code> is capable of storing not 
only
+ * <code>String</code> and <code>String</code> array data as
+ * <code>ListResourceBundle</code>, but also <code>Dictionary</code> data that
+ * is stored as subkey/value pairs as well. <p>
+ *
+ * These two implementations of <code>RTSWriter</code> provided by RTS only
+ * write Java output files.  However, <code>RTSWriter</code> is an extremely
+ * powerful interface and is designed to support the output of any file type.
+ * That is, RTS consumers can write their own implementations of
+ * <code>RTSWriter</code> to output files type such as HTML, XSL, CSS, XML, 
etc.
+ * Moreover, the output of <code>RTSWriter</code> is not limited to just
+ * files.  For example, <code>RTSWriter</code> could be used to implement
+ * writing parsed data to the database using SQLJ, JDBC, or even a SQL loader.
+ * <p>
+ *
+ * Consumers developing their own implementations of <code>RTSWriter</code> 
will
+ * need to make sure that the implementation is registered in the Config.txt
+ * file.  By default, Config.txt contains registrations for the list and subkey
+ * implementations.  The format of Config.txt matches that of a text-based RTS
+ * file.  That is, a key, followed by an equal sign '=', followed by the value.
+ * The key is the command line parameter that XXXMakeBundle calls.  The value 
is
+ * the fully qualified class name of the <code>RTSWriter</code> implementation.
+ *  The following is the text contained in the default Config.txt:
+ * <blockquote>
+ * <pre>
+ * subkey = oracle.bali.rts.tools.DefaultSubkeyRTSWriter
+ * list = oracle.bali.rts.tools.ListRTSWriter
+ * </pre>
+ * </blockquote>
+ *
+ * Each method in this interface includes a <code>parms</code> and
+ * <code>meta Dictionary</code>.  The <code>parms dictionary</code> contains
+ * <code>String</code> keys and values representing the command line parameters
+ * for the make tool. <p>
+ *
+ * In this release, the <code>meta Dictionary</code> is not fully utilized.  It
+ * is intended to contain information that contained in the XML-based RTS 
source
+ * file, but external to the resource element information.  The final release 
of
+ * RTS 2.0 will better define this structure's contents.
+ *
+ * @see ListRTSWriter
+ * @see DefaultSubkeyRTSWriter
+ * @see RTSMakeBundle
+ * @see XRTSMakeBundle
+ *
+ * @version $Name:  $ ($Revision: 1.7 $) $Date: 2001/04/09 23:22:22 $
+ * @author Craig R. Cummings ([EMAIL PROTECTED])
+ * @since RTS 1.5
+ */
+public interface RTSWriter
+{
+
+  /**
+   * Writes the <file or other output header(s).
+   *
+   * @param parms a <code>Dictionary</code> of command line parameters.
+   * @param meta a <code>Dictionary</code> of parsed non-resource data
+   * (e.g., package).
+   */
+  public void startBundle(Dictionary parms, Dictionary meta)
+    throws Throwable;
+
+  /**
+   * Writes a <code>String</code> to the implementation output. <p>
+   *
+   * This is the typical case use.  A single <code>String</code> key associated
+   * with a single <code>String</code> value forming a key/value pair (kvp).
+   * Note that the other two body methods, <code>writeStringArray</code> and
+   * <code>writeDictionary</code> both support a single <code>String</code>
+   * key associated with multiple values. <p>
+   *
+   * A key/value pair may have associated attributes in the RTS file.
+   * In this method, these are received from the XML parser as a
+   * <code>Dictionary</code>. <p>
+   *
+   * @param parms a <code>Dictionary</code> of command line parameters
+   * @param meta a <code>Dictionary</code> of parsed non-resource data
+   * (e.g., package).
+   * @param key a <code>String</code> key.
+   * @param value a <code>String</code> value.
+   * @param attr a <code>Dictionary</code> containing any XML attributes
+   * assciated with the resource element.
+   *
+   * The <code>attr Dictionary</code> contains a <code>String</code> key which
+   * is the attribute name and a <code>String</code> value for the given
+   * attribute name (typically the text in the source RTS file that
+   * appears to the right of the equals '=' sign of an attribute key).
+   */
+  public void writeString(Dictionary parms, Dictionary meta, String key,
+    String value, Dictionary attr) throws Throwable;
+
+  /**
+   * Writes an array of <code>String</code> to the implementation body output.
+   * <p>
+   *
+   * If the <code>String</code> array <code>kvpArr</code> has n values then the
+   * array of <code>Dictionary attrs</code> will have n+1 values.  Each
+   * <code>Dictionary</code> in the array with an index from 0-n will be
+   * the attributes for the <code>String</code> in the <code>String</code> 
array
+   * of the same index.  The <code>Dictionary</code> of attributes at index n+1
+   * will be that of the 'values' element from the RTS file. <p>
+   *
+   * @param parms a <code>Dictionary</code> of command line parameters
+   * @param meta a <code>Dictionary</code> of parsed non-resource data
+   * (e.g., package).
+   * @param key a <code>String</code> key.
+   * @param kvpArr an array of <code>String</code> values
+   * pairs.
+   * @param attrs an array of <code>Dictionary</code> where each
+   * <code>Dictionary</code> contains any XML attributes assciated with a
+   * given <code>String</code> in the kvpArr array.
+   *
+   * The contents of each attribute <code>Dictionary</code> in the array is
+   * a <code>String</code> key which is the attribute name and a value which is
+   * the <code>String</code> value for the given attribute name (typically the
+   * text that appears to the right of the equals '=' sign of an attribute key.
+   */
+  public void writeStringArray(Dictionary parms, Dictionary meta, String key,
+    String[] kvpArr, Dictionary[] attrs) throws Throwable;
+
+  /**
+   * Writes a <code>Dictionary</code> to the implementation body output. <p>
+   *
+   * If the <code>Dictionary kvps</code> contains subkeys which are
+   * <code>String</code> element names of the child elements of 'set' in the
+   * RTS file.  The <code>Dictionary kvps</code> also contains values
+   * associated the the various subkeys which are <code>String</code> values
+   * from the XML file -- the string that appears between child start and end
+   * elements. <p>
+   *
+   * @param parms a <code>Dictionary</code> of command line parameters.
+   * @param meta a <code>Dictionary</code> of parsed non-resource data
+   * (e.g., package).
+   * @param key a <code>String</code> key.
+   * @param kvps a <code>Dictionary</code> with ordered subkey/
+   * <code>String</code> value pairs.
+   * @param attrs a <code>Dictionary</code> of XML attributes assciated with a
+   * given subkey. 
+   *
+   * The contents of the <code>attrs Dictionary</code> are keys that match the
+   * name of the child elements or subkey.  The values of the
+   * <code>attrs Dictionary</code> are <code>Dictionary</code> objects
+   * themselves.  These nested Dictionary value objects contain key/value 
pairs.
+   * The key is a <code>String</code> attribute name and the value is a
+   * <code>String</code> the value for the given attribute name.
+   *
+   * Typical use cases will probably not require attributes for any of
+   * the child elements.  Just the same, RTS is able to support attributes for
+   * these subkey/child elements.
+   */
+  public void writeDictionary(Dictionary parms, Dictionary meta, String key,
+    Dictionary kvps, Dictionary attrs) throws Throwable;
+
+  /**
+   * Writes the file or other output footer(s).
+   *
+   * @param parms a <code>Dictionary</code> of command line parameters.
+   * @param meta a <code>Dictionary</code> of parsed non-resource data
+   * (e.g., package).
+   */
+  public void endBundle(Dictionary parms, Dictionary meta) throws Throwable;
+
+}

Added: 
incubator/adffaces/trunk/plugins/maven-xrts-plugin/src/main/java/org/apache/myfaces/adfbuild/plugin/xrts/UnicodeEscapes.java
URL: 
http://svn.apache.org/viewcvs/incubator/adffaces/trunk/plugins/maven-xrts-plugin/src/main/java/org/apache/myfaces/adfbuild/plugin/xrts/UnicodeEscapes.java?rev=405242&view=auto
==============================================================================
--- 
incubator/adffaces/trunk/plugins/maven-xrts-plugin/src/main/java/org/apache/myfaces/adfbuild/plugin/xrts/UnicodeEscapes.java
 (added)
+++ 
incubator/adffaces/trunk/plugins/maven-xrts-plugin/src/main/java/org/apache/myfaces/adfbuild/plugin/xrts/UnicodeEscapes.java
 Mon May  8 17:25:44 2006
@@ -0,0 +1,104 @@
+/*
+* Copyright 2006 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.myfaces.adfbuild.plugin.xrts;
+
+/**
+ * The <code>UnicodeEscapes</code> class converts bytes and characters outside
+ * the ASCII character set to Java usable '\\u' Unicode escapes characters.  
This
+ * is a runtime version of native2ascii more or less.
+ *
+ * @version $Name:  $ ($Revision: 1.5 $) $Date: 2002/02/27 17:18:16 $
+ * @author Craig R. Cummings
+ */
+public final class UnicodeEscapes
+{
+
+  private UnicodeEscapes()
+  {
+  }
+
+  static public String convert(String s)
+  {
+    StringBuffer buffer = new StringBuffer(s.length());
+    for(int i = 0; i < s.length(); i++)
+    {
+      char c = s.charAt(i);
+      if (c < 128)
+      {
+        switch (c)
+        {
+        case '\b':
+          buffer.append("\\b");
+          break;
+        case '\t':
+          buffer.append("\\t");
+          break;
+        case '\n':
+          buffer.append("\\n");
+          break;
+        case '\f':
+          buffer.append("\\f");
+          break;
+        case '\r':
+          buffer.append("\\r");
+          break;
+        case '\"':
+          buffer.append("\\\"");
+          break;
+        case '\'':
+          buffer.append("\\\'");
+          break;
+        case '\\':
+          buffer.append("\\\\");
+          break;
+        default:
+          buffer.append(c);
+          break;
+        }
+      }
+      else
+      {
+        buffer.append("\\u");
+        buffer.append(_hex[(c>>12)& 0x0f]);
+        buffer.append(_hex[(c>>8)& 0x0f]);
+        buffer.append(_hex[(c>>4)& 0x0f]);
+        buffer.append(_hex[c & 0x0f]);
+      }
+    }
+    return buffer.toString();
+  }
+
+//  String byteToHex(byte b) {
+//    // Returns hex String representation of byte b
+//    char hexDigit[] = {
+//       '0', '1', '2', '3', '4', '5', '6', '7',
+//       '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
+//    };
+//    char[] array = { hexDigit[(b >> 4) & 0x0f], hexDigit[b & 0x0f] };
+//    return new String(array);
+//  }
+
+//  String charToHex(char c) {
+//    // Returns hex String representation of char c
+//    byte hi = (byte) (c >>> 8);
+//    byte lo = (byte) (c & 0xff);
+//    return byteToHex(hi) + byteToHex(lo);
+//  }
+
+  private static final String[] _hex =
+    {"0", "1", "2", "3", "4", "5", "6", "7",
+     "8", "9", "a", "b", "c", "d", "e", "f"};
+}

Added: 
incubator/adffaces/trunk/plugins/maven-xrts-plugin/src/main/java/org/apache/myfaces/adfbuild/plugin/xrts/XRTSGenerator.java
URL: 
http://svn.apache.org/viewcvs/incubator/adffaces/trunk/plugins/maven-xrts-plugin/src/main/java/org/apache/myfaces/adfbuild/plugin/xrts/XRTSGenerator.java?rev=405242&view=auto
==============================================================================
--- 
incubator/adffaces/trunk/plugins/maven-xrts-plugin/src/main/java/org/apache/myfaces/adfbuild/plugin/xrts/XRTSGenerator.java
 (added)
+++ 
incubator/adffaces/trunk/plugins/maven-xrts-plugin/src/main/java/org/apache/myfaces/adfbuild/plugin/xrts/XRTSGenerator.java
 Mon May  8 17:25:44 2006
@@ -0,0 +1,86 @@
+/*
+* Copyright 2006 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.myfaces.adfbuild.plugin.xrts;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.StringTokenizer;
+import java.util.Vector;
+
+import javax.xml.parsers.SAXParser;
+
+import org.xml.sax.InputSource;
+import org.xml.sax.Parser;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+/**
+ * The <code>XRTSGenerator</code> class is a online facility (as opposed to the
+ * command line utility <code>XRTSMakeBundle</code>) for parsing and building
+ * XML-based RTS files to the given implementation output. <p>
+ *
+ * @version $Name:  $ ($Revision: 1.1 $) $Date: 2001/07/09 18:15:53 $
+ * @author Craig R. Cummings
+ * @since RTS 2.0
+ */
+public final class XRTSGenerator
+{
+
+  /**
+   * Parse the XML-based RTS source and create output according to an
+   * <code>RTSWriter</code> implementation.
+   *
+   * @param parser see class description.
+   * @param is the XML-based RTS source file.
+   * @param rtsw an <code>RTSWriter</code> implementation.
+   * @param parms a <code>Dictionary</code> of command line parameters.
+   *
+   */
+  public static void generate(SAXParser parser, InputSource is, RTSWriter rtsw,
+    Dictionary parms) throws Throwable
+  {
+    XRTSParser rtsp = new XRTSParser(rtsw, parms);
+
+    try
+    {
+      parser.parse(is, rtsp);
+    }
+    catch (IOException ioe)
+    {
+      System.err.println(ioe);
+      System.exit(1);
+    }
+    catch (SAXParseException spe)
+    {
+      System.exit(1);
+    }
+    catch (SAXException se)
+    {
+      System.err.println(se);
+      System.exit(1);
+    }
+  }
+
+  //
+  // No need to instantiate this class
+  //
+  private XRTSGenerator()
+  {
+  }
+}

Added: 
incubator/adffaces/trunk/plugins/maven-xrts-plugin/src/main/java/org/apache/myfaces/adfbuild/plugin/xrts/XRTSParser.java
URL: 
http://svn.apache.org/viewcvs/incubator/adffaces/trunk/plugins/maven-xrts-plugin/src/main/java/org/apache/myfaces/adfbuild/plugin/xrts/XRTSParser.java?rev=405242&view=auto
==============================================================================
--- 
incubator/adffaces/trunk/plugins/maven-xrts-plugin/src/main/java/org/apache/myfaces/adfbuild/plugin/xrts/XRTSParser.java
 (added)
+++ 
incubator/adffaces/trunk/plugins/maven-xrts-plugin/src/main/java/org/apache/myfaces/adfbuild/plugin/xrts/XRTSParser.java
 Mon May  8 17:25:44 2006
@@ -0,0 +1,606 @@
+/*
+* Copyright 2006 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.myfaces.adfbuild.plugin.xrts;
+
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Stack;
+import java.util.Vector;
+
+import org.xml.sax.AttributeList;
+import org.xml.sax.HandlerBase;
+import org.xml.sax.InputSource;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+/**
+ *
+ * Data stored in the XML-based RTS format is parsed by 
<code>XRTSParser</code>.
+ * The data in the resource elements is parsed into a Vector of Tuples.  The
+ * data for other elements that do not have &lt;resource&gt; as their element
+ * name (e.g., &lt;authors&gt;) are parsed into a <code>Hashtable</code> of
+ * <code>Tuple</code>s. <p>
+ *
+ * The key attribute of the resource element is set to the key of the Tuple.
+ * Any other attributes
+ * for the resource element are set in the attribute Hashtable for the Tuple.
+ * The translatable value of the resource element is the text between the start
+ * of the element and the end of the element.  If the value is simply a String,
+ * then it is set in the value of the Tuple.  If the value is a String array,
+ * the value of the Tuple is set to a Vector of tuples that are built through
+ * subsequent parsing.  If the value is a Dictionary, then the value of the
+ * tuple is set to a Dictionary of Tuples that are built through subsequent
+ * parsing. <p>
+ *
+ * @version $Name:  $ ($Revision: 1.1 $) $Date: 2001/04/09 23:23:22 $
+ * @author Craig R. Cummings
+ */
+final class XRTSParser extends HandlerBase
+{
+
+  /**
+   * Empty constructor for the XRTSParser
+   *
+   */
+  public XRTSParser()
+  {
+  }
+
+  public XRTSParser(RTSWriter bw, Dictionary parms)
+  {
+    _bundleWriter = bw;
+    _parms = (Hashtable)parms;
+  }
+
+  /**
+   * Receive a Locator object for document events.
+   * Setting Locator ensures the SAX parser can find a given XML-based RTS
+   * document.  This method is closely related to the _fileToURL in
+   * <code>XRTSMakeBundle</code>.
+   *
+   * @param locator A locator for all SAX document events.
+   */
+  public void setDocumentLocator (Locator locator)
+  {
+    _locator = locator;
+  }
+
+  /**
+   * Receive notification of the beginning of the document.
+   * SAX Parser event for finding the beginning of an XML-based RTS document
+   */
+  public void startDocument() throws SAXException
+  {
+//    System.out.println("StartDocument");
+    _xmlTagStack = new Stack();
+    if (_metaHt == null)
+      _metaHt = new Hashtable();
+    _metaHt.put("fileType", "xrts");
+    _startDoc = true;
+
+  }
+
+  /**
+   * Receive notification of the end of the document.
+   * SAX Parser event for finding the end of an XML-based RTS document
+   */
+  public void endDocument() throws SAXException
+  {
+//    System.out.println("EndDocument");
+    try
+    {
+      _bundleWriter.endBundle(_parms, _metaHt);
+    }
+    catch (Throwable th)
+    {
+      throw new SAXException("endBundle Exception: " + th.getMessage());
+    }
+  }
+
+  /**
+   * Receive notification of the start of an element.
+   *
+   * @param name the element type name.
+   * @param attributes the specified or defaulted attributes.
+   */
+  public void startElement(String name, AttributeList atts) throws SAXException
+  {
+//    System.out.println("StartElement:"+name);
+    Hashtable _attsHt = new Hashtable();
+    _nestingLevel++;
+
+    if (name.equals("values"))
+      _inValues = true;
+    else if (name.equals("set"))
+      _inSet = true;
+
+    // startBundle doesn't go in the startDocument method because it
+    // requires metadata to be passed and in particular, requires
+    // at least the package for any implementation of startBundle to work
+    else if (name.equals("resource") && _startDoc)
+      try
+      {
+        _bundleWriter.startBundle(_parms, _metaHt);
+        _startDoc = false;
+      }
+      catch (Throwable th)
+      {
+        throw new SAXException("startBundle Exception: " + th.getMessage());
+      }
+
+    if (name.equals("resources"))
+    {
+      if (_metaHt == null)
+        _metaHt = new Hashtable();
+      _metaHt.put("package", atts.getValue("package"));
+      if (atts.getValue("version") != null)
+        _metaHt.put("version", atts.getValue("version"));
+      if (atts.getValue("baseversion") != null)
+        _metaHt.put("baseVersion", atts.getValue("baseversion"));
+    }
+
+    if (atts.getLength() > 0)
+      for (int i=0;i < atts.getLength(); i++)
+        _attsHt.put(atts.getName(i), atts.getValue(i));
+
+    if (name.equals("value") && _inSet)
+    {
+      System.err.println("String array structure (\'values/value\') not " +
+        "allowed within Dictionary (\'set\') XML-based RTS structure.  Please" 
+
+        "correct the XML-based RTS or DTD file and rebuild." +
+        " Line:" + _locator.getLineNumber());
+      System.exit(1);
+    }
+    else if (name.equals("set") && _inValues)
+    {
+      System.err.println("Dictionary structure (\'set\') not allowed within " +
+        "String array (\'values/value\') XML-based RTS structure.  Please" +
+        "correct the XML-based RTS or DTD file and rebuild." +
+        " Line:" + _locator.getLineNumber());
+      System.exit(1);
+    }
+    else
+    {
+      Tuple t = new Tuple();
+      t.key = name;
+      if (_attsHt.size() > 0)
+        t.attributes = _attsHt;
+      else
+        t.attributes = null;
+      t.nesting = _nestingLevel;
+      _xmlTagStack.push(t);
+    //  _printStack(_xmlTagStack);
+    }
+  }
+
+  /**
+   * Receive notification of the end of an element.
+   * @param name the element type name.
+   */
+  public void endElement(String name) throws SAXException
+  {
+//    System.out.println("EndElement:"+name);
+
+    String key = name;
+    _nestingLevel--;
+
+    // Vector of Tuples for "values" String array
+    if (name.equals("values"))
+    {
+      Vector values = new Vector();
+      Vector dicts = new Vector();
+
+      Tuple t = (Tuple)_xmlTagStack.pop();
+      while (!t.key.equals("values"))
+      {
+        if (t.value != null)
+        {
+          if (t.key.equals("value"))
+          {
+            if (t.nesting <= 4)
+            {
+              values.addElement(t.value);
+              dicts.addElement(t.attributes);
+            }
+            else
+            {
+              System.err.println("Nesting within values not permitted." +
+                " Exiting.");
+              System.exit(1);
+            }
+          }
+          else
+          {
+            System.err.println("Non value element \'" + t.key +
+              "\' found. Discarding.");
+          }
+        }
+        else
+        {
+          System.err.println("Null value found. Discarding.");
+        }
+        t = (Tuple)_xmlTagStack.pop();
+      }
+      // last element in the vector will always be the 'values' Tuple (with any
+      // associated attributes e.g., DNT=)
+
+      //      v.addElement(t.value);
+      // need to save attributes Dictionary for 'values'
+
+      // pop off the resource or metadata Tuple, set its value to the Vector,
+      // and push it back on the stack
+
+      t = (Tuple)_xmlTagStack.pop();
+      // add the attributes for 'values' element itself
+      dicts.addElement(t.attributes);
+
+      if (t.key.equals("resource"))
+      {
+        key = (String)t.attributes.get("key");
+
+        String[] strArr = new String[values.size()];
+        int j = values.size()-1;
+        for (int i = 0; i < values.size(); i++)
+        {
+          strArr[j] = (String)values.elementAt(i);
+          j--;
+        }
+
+        Hashtable[] attsArr = new Hashtable[dicts.size()];
+        j = dicts.size()-1;
+        for (int i = 0; i < dicts.size(); i++)
+        {
+          attsArr[j] = (Hashtable)dicts.elementAt(i);
+          j--;
+        }
+
+        if (_uniqKeys == null)
+          _uniqKeys = new Hashtable();
+        if (_uniqKeys.get(key) == null)
+        {
+          _uniqKeys.put(key, "OK");
+        }
+        else
+        {
+          System.err.println("Duplicate key found for " + key);
+          System.exit(1);
+        }
+
+        try
+        {
+          _bundleWriter.writeStringArray(_parms, _metaHt, key, strArr, 
attsArr);
+        }
+        catch (Throwable th)
+        {
+          throw new SAXException("writeStringArray Exception: " +
+            th.getMessage());
+        }
+      }
+      else
+      {
+        key = t.key;
+        //consider handling as meta data if enough demand
+      }
+      // debugging
+//      _printStack(_xmlTagStack);
+    }
+
+    // Hashtable of Tuples for "set" String array
+    else if (name.equals("set"))
+    {
+      Vector setVals = new Vector();
+      Hashtable setAttrHt = new Hashtable();
+      Tuple t = (Tuple)_xmlTagStack.pop();
+      while (!t.key.equals("set"))
+      {
+        // a bit of redundancy here with Hashtable key = t.key and the Tuple
+        // itself containing t.key again.  They could be converted to a pair
+        // here with the loss of some performance.  Alternatively, the pair
+        // could originate in the start element event through some detection,
+        // but that code does not appear to be that trivial an effort.  Note
+        // this duplication also occurs in the meta data handling.
+        setVals.addElement(t);
+        if (t.attributes != null)
+          setAttrHt.put(t.key, t.attributes);
+        t = (Tuple)_xmlTagStack.pop();
+      }
+      // pop off the resource or metadata Tuple, set its value to the Vector,
+      // and push it back on the stack
+      t = (Tuple)_xmlTagStack.pop();
+      // add the attributes for the 'set' element itself
+      setAttrHt.put(t.key, t.attributes);
+      if (t.key.equals("resource"))
+      {
+        key = (String)t.attributes.get("key");
+
+        OrderedDictionary setHt = new OrderedDictionary();
+        for (int i = setVals.size() - 1; i >= 0; i--)
+        {
+          Tuple tVals = (Tuple)setVals.elementAt(i);
+          if (tVals.nesting <= 4)
+          {
+            try
+            {
+              setHt.put(tVals.key, tVals.value);
+            }
+            catch (NullPointerException npe)
+            {
+              System.err.println("Value for subkey \'" + tVals.key +
+                "\' is null. Discarding.");
+            }
+          }
+          else
+          {
+            System.err.println("Nesting within set elements not permitted." +
+              " Exiting.");
+            System.exit(1);
+          }
+        }
+
+        if (_uniqKeys == null)
+          _uniqKeys = new Hashtable();
+        if (_uniqKeys.get(key) == null)
+        {
+          _uniqKeys.put(key, "OK");
+        }
+        else
+        {
+          System.err.println("Duplicate key found for " + key);
+          System.exit(1);
+        }
+
+        try
+        {
+          _bundleWriter.writeDictionary(_parms, _metaHt, key, setHt, 
setAttrHt);
+        }
+        catch (Throwable th)
+        {
+          throw new SAXException("writeDictionary Exception: " +
+            th.getMessage());
+        }
+      }
+      else
+      {
+        key = t.key;
+        //consider handling as meta data if enough demand
+      }
+
+
+      // debugging
+//      _printStack(_xmlTagStack);
+    }
+    else if (name.equals("author"))
+    {
+      if (_authors == null)
+        _authors = new Vector();
+      Tuple t = (Tuple)_xmlTagStack.pop();
+      if (t.value != null)
+      {
+        _authors.addElement(t.value);
+        _metaHt.put("authors", _authors);
+      }
+      else
+      {
+        System.err.println("Null author value.  Discarding.");
+      }
+    }
+    else if (name.equals("resource"))
+    {
+//      _printStack(_xmlTagStack);
+//      System.out.println(name + ":" + _inValues + ":" + _inSet);
+      if (_inValues)
+      {
+        _inValues = false;
+      }
+      else if (_inSet)
+      {
+        _inSet = false;
+      }
+
+      else
+      {
+        Tuple t = (Tuple)_xmlTagStack.pop();
+        try
+        {
+          Hashtable ht = t.attributes;
+          key = (String)ht.get("key");
+
+          if (_uniqKeys == null)
+            _uniqKeys = new Hashtable();
+          if (_uniqKeys.get(key) == null)
+          {
+            _uniqKeys.put(key, "OK");
+          }
+          else
+          {
+            System.err.println("Duplicate key found for " + key);
+            System.exit(1);
+          }
+
+          if (t.value != null)
+          _bundleWriter.writeString(_parms, _metaHt, key,
+            (String)t.value, t.attributes);
+          else
+            System.err.println("Value for key \'" + key + "\' is null." +
+              " Discarding.");
+        }
+        catch (Throwable th)
+        {
+          throw new SAXException("writeString Exception: " + th.getMessage());
+        }
+      }
+    }
+
+//    else
+//    {
+//      consider handling as meta data if enough demand
+//    }
+  }
+
+  /**
+   * Receive notification of ignorable whitespace in element content.
+   *
+   * @param ch the whitespace characters.
+   * @param start the start position in the character array.
+   * @param length the number of characters to use from the character array.
+   */
+  public void ignorableWhitespace(char[] cbuf, int start, int len)
+    throws SAXException
+  {
+//    System.out.println("IgnorableWhiteSpace" + len);
+  }
+
+  /**
+   * Receive notification of character data inside an element.
+   *
+   * @param ch the characters.
+   * @param start the start position in the character array.
+   * @param length the number of characters to use from the character array.
+   */
+  public void characters(char[] cbuf, int start, int len) throws SAXException
+  {
+//    System.out.println("Characters:" + len);
+
+    // Keep track of when resource elements start so we can be sure to
+    // collect and concatenate any initial whitespace for the value.  These are
+    // the pitfalls of a validating parser and I was unable to find a way to
+    // toggle separation of initial whitespace off.  Perhaps this could
+    // eventually be an enhancement request to the Oracle XML parser team.
+
+    // If it is text in a resource tag, concatenate it as it must be part of 
the
+    // value string.  The concatenation is required with a validating parser as
+    // the parser considers any leading spaces to be a string of characters
+    // separate of the string consisting of non-space and any following space
+    // characters
+    Tuple t = (Tuple)_xmlTagStack.pop();
+    String newStr = new String(cbuf,start,len);
+    if (t.value instanceof String)
+    {
+      String tStr = (String)t.value;
+      if (tStr != null && !tStr.equals(""))
+        t.value = tStr.concat(newStr);
+    }
+    else
+    {
+      t.value = newStr;
+    }
+
+    _xmlTagStack.push(t);
+
+  }
+
+  /**
+   * Receive notification of a parser warning.
+   *
+   * @param spe the warning information encoded as an exception.
+   */
+  public void warning(SAXParseException spe) throws SAXException
+  {
+    System.err.println(spe + " Line:" + spe.getLineNumber());
+  }
+
+  // validity
+  /**
+   * Receive notification of a recoverable parser error.
+   *
+   * @param spe the error information encoded as an exception.
+   */
+  public void error(SAXParseException spe) throws SAXException
+  {
+    System.err.println(spe + " Line:" + spe.getLineNumber());
+  }
+
+  // well-formedness
+  /**
+   * Receive notification of a fatal XML-based RTS parsing error.
+   *
+   * @param spe the fatal error information encoded as an exception.
+   */
+  public void fatalError(SAXParseException spe) throws SAXException
+  {
+    System.err.println(spe + " Line:" + spe.getLineNumber());
+  }
+
+  private final class Tuple
+  {
+
+    private String key;
+    /**
+     * The value is an <code>Object</code> that is either a 
<code>String</code>,
+     * an array of <code>String</code>s (stored as a <code>Vector</code>), or a
+     * <code>Dictionary</code> of key/value pairs where the values in the
+     * <code>Dictionary</code> are <code>String</code>s.
+     */
+    private Object value;
+    private Hashtable attributes;
+    private int nesting;
+
+    /**
+     * Create and empty <code>Tuple</code> object.
+     */
+    private Tuple()
+    {
+    }
+
+    /**
+     * Create a <code>Tuple</code> object with key, value, attributes, and 
type.
+     *
+     * @param key name of key
+     * @param value value <code>Object</code>
+     * @param attributes typically a <code>Hashtable</code> of attributes
+     * @param type see the field section for possible values
+     */
+    private Tuple(String key, Object value, Hashtable attributes, int nesting)
+    {
+      this.key = key;
+      this.value = value;
+      this.attributes = attributes;
+      this.nesting = nesting;
+    }
+  }
+
+  // For debugging purposes only
+  private void _printStack(Stack s)
+  {
+    Enumeration e = s.elements();
+    while (e.hasMoreElements())
+    {
+      Tuple t = (Tuple)e.nextElement();
+      System.out.println(t.key);
+      System.out.println("->" + t.value);
+      System.out.println("->" + t.attributes);
+    }
+    System.out.println();
+  }
+
+  // Store the locator
+  private Locator _locator;
+
+  private Stack _xmlTagStack;
+  private Hashtable _metaHt;
+  private Hashtable _uniqKeys;
+  private Vector _authors;
+
+  private RTSWriter _bundleWriter;
+  private Hashtable _parms;
+
+  private int _nestingLevel = 0;
+  private boolean _inValues = false;
+  private boolean _inSet = false;
+  private boolean _startDoc = false;
+}


Reply via email to