jbates      02/03/11 04:46:51

  Modified:    .        build.xml
               java/src/org/apache/xindice/xml/sax SAXEventGenerator.java
  Log:
  1) Turned on debugging in build.xml file, so generated jars contain debugging 
symbols.
  Can be turned off by setting an option before running ant.
  
  2) patches SAXEventGenerator to generate startPrefixMapping() and 
endPrefixMapping() events
  correctly when new namespaces are declared in XML content.
  
  Submitted by: Mike Gratton <[EMAIL PROTECTED]>
  Reviewed by: James Bates <[EMAIL PROTECTED]>
  
  Revision  Changes    Path
  1.9       +23 -1     xml-xindice/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/xml-xindice/build.xml,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- build.xml 26 Feb 2002 08:22:49 -0000      1.8
  +++ build.xml 11 Mar 2002 12:46:51 -0000      1.9
  @@ -14,7 +14,7 @@
        cd xml-xindice ; bin/ant
   
   
  -   $Id: build.xml,v 1.8 2002/02/26 08:22:49 kstaken Exp $
  +   $Id: build.xml,v 1.9 2002/03/11 12:46:51 jbates Exp $
   
   -->
   
  @@ -37,6 +37,13 @@
     <property name="javadoc.pkgs" value="org.apache.xindice.*"/>
     <property name="docs.dir" value="docs"/>
     <property name="docbook.style" 
value="${docs.dir}/src/docbook/html/docbook.xsl"/>
  +
  +  <property name="compile.debug" value="on"/>
  +  <property name="compile.optimize" value="off"/>
  +  <property name="compile.nowarn" value="off"/>
  +  <property name="compile.deprecation" value="off"/>
  +  <property name="compile.verbose" value="off"/>
  +
     
     <!-- classpath to use within project -->
     <path id="project.class.path">
  @@ -108,6 +115,11 @@
       <javac srcdir="${src.dir}"
              destdir="${build.dir}"
              classpathref="project.class.path"
  +           debug="${compile.debug}"
  +           optimize="${compile.optimize}"
  +           nowarn="${compile.nowarn}"
  +           deprecation="${compile.deprecation}"
  +           verbose="${compile.verbose}"
              />
     </target>
   
  @@ -151,12 +163,22 @@
        <javac srcdir="${examples.dir}/api/src/"
               destdir="${examples.build.dir}"
               classpathref="project.class.path"
  +            debug="${compile.debug}"
  +            optimize="${compile.optimize}"
  +            nowarn="${compile.nowarn}"
  +            deprecation="${compile.deprecation}"
  +            verbose="${compile.verbose}"
        />
   
        <echo message="Compiling Developers Guide Examples"/>
        <javac srcdir="${examples.dir}/guide/src/"
               destdir="${examples.build.dir}"
               classpathref="project.class.path"
  +            debug="${compile.debug}"
  +            optimize="${compile.optimize}"
  +            nowarn="${compile.nowarn}"
  +            deprecation="${compile.deprecation}"
  +            verbose="${compile.verbose}"
        />
     </target>
     
  
  
  
  1.5       +34 -3     
xml-xindice/java/src/org/apache/xindice/xml/sax/SAXEventGenerator.java
  
  Index: SAXEventGenerator.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xindice/java/src/org/apache/xindice/xml/sax/SAXEventGenerator.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SAXEventGenerator.java    22 Feb 2002 22:51:14 -0000      1.4
  +++ SAXEventGenerator.java    11 Mar 2002 12:46:51 -0000      1.5
  @@ -56,7 +56,7 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    *
  - * $Id: SAXEventGenerator.java,v 1.4 2002/02/22 22:51:14 kstaken Exp $
  + * $Id: SAXEventGenerator.java,v 1.5 2002/03/11 12:46:51 jbates Exp $
    */
   
   import org.apache.xindice.xml.*;
  @@ -90,6 +90,9 @@
   
      private boolean interrupt = false;
   
  +   static final String XMLNS_ATTR_PREFIX = "xmlns:";
  +   static final int XMLNS_MAP_INCREMENT = 5;
  +
      public SAXEventGenerator(SymbolTable symbols, byte[] data) {
         this.symbols = symbols;
         this.data = data;
  @@ -196,6 +199,8 @@
         String elemName = null;
         String localName = null;
         String nsURI = null;
  +      String[] mappedPrefixes = null;
  +      int nsMapCount = 0;
   
         if ( element ) {
            in.readSignature();
  @@ -216,8 +221,28 @@
               String attrName = symbols.getName(symbol);
               String attrURI = symbols.getNamespaceURI(symbol);
               String lclName = getLocalName(attrName);
  +
  +         /* UTF8TOFIX: must be fixed when switching to internal UTF-8 
representation of strings */
  +         String attrValue = new String(b);
  +
  +         // look for and buffer newly mapped namespace prefixes
  +         if (attrName.startsWith(XMLNS_ATTR_PREFIX)) {
  +             // create the buffer if needed
  +             if (mappedPrefixes == null) 
  +                 mappedPrefixes = new String[XMLNS_MAP_INCREMENT];
  +
  +             // check the buffer's capacity
  +             if (nsMapCount >= mappedPrefixes.length) {
  +                 String[] newBuf = new String[mappedPrefixes.length + 
XMLNS_MAP_INCREMENT];
  +                 System.arraycopy(mappedPrefixes, 0, newBuf, 0, 
newBuf.length);
  +                 mappedPrefixes = newBuf;
  +             }
  +
  +             content.startPrefixMapping(lclName, attrValue);
  +             mappedPrefixes[nsMapCount++] = lclName;
  +         }
               
  -            attrs.addAttribute(attrURI != null ? attrURI : "", lclName, 
attrName, "", new String(b, "UTF-8"));
  +            attrs.addAttribute(attrURI != null ? attrURI : "", lclName, 
attrName, "", attrValue);
            }
            if ( comp != null ) {
               comp.symbolID(elemSymbol);
  @@ -296,8 +321,14 @@
            bis.skip(len);
         }
   
  -      if ( element && !interrupt)
  +      if ( element && !interrupt) {
  +
  +      // unmap any prefixes
  +      for (int i = 0; i < nsMapCount; i++)
  +          content.endPrefixMapping(mappedPrefixes[i]);
  +
            content.endElement(nsURI != null ? nsURI : "", localName, elemName);
  +      }
   
         return !interrupt;
      }
  
  
  

Reply via email to