jkesselm    02/04/12 11:26:20

  Modified:    java/src/org/apache/xml/dtm Tag: Xalan3 DTM.java
               java/src/org/apache/xml/dtm/ref Tag: Xalan3
                        DTMDefaultBase.java DTMDocumentImpl.java
                        DTMManagerDefault.java
                        IncrementalSAXSource_Xerces.java
               java/src/org/apache/xml/dtm/ref/sax2dtm Tag: Xalan3
                        SAX2DTM.java
  Log:
  Creating a new branch, Xalan3, for experimentation with XPath2 support.
  
  Currently the changes are limited to org.apache.xml.dtm -- enabling
  datatype support by tying into Xerces' low-level XNI layer, which
  includes experimental support for  post-schema-validation Infoset
  (PSVI) information. Eventually we'll be patching other portions of
  Xalan to actually retrieve and use this data.
  
  The code I'm now checking in is NOT in final form. Known issues:
  
  1) The logic in DTMManager which enables this behavior is
  something of a kluge -- it only kicks in if you parse incrementally
  from a StreamSource. The getDTM() method really wants to be
  rationalized somewhat, which will make adding XNI easier.
  
  2) The storage for datatype information currently adds another
  column to the DTM table. We really want to switch to associating
  the datatype with the Expanded Type table, and using some form
  of sparse array to record local overrides.
  
  3) The XNI code won't compile without Xerces2. We need to think
  about whether we want to accept that as a dependency, or use
  reflection to bind at run time rather than compile time.
  
  Note that typed values are currently computed on demand, with the
  DTM storing only the sting values. An argument could be made for
  precomputing some or all of this information and instead generating
  strings on demand (see the XPath2 Data Model spec for discussion
  of that alternative). But that's a considerably larger change, and
  would affect non-type-based users of XSLT as well since it would
  present values in their normalized form rather than as entered; I'd
  rather not go that route until we have a string-based alternative
  fully functional.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.6.6.1   +63 -1     xml-xalan/java/src/org/apache/xml/dtm/DTM.java
  
  Index: DTM.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/DTM.java,v
  retrieving revision 1.6
  retrieving revision 1.6.6.1
  diff -u -r1.6 -r1.6.6.1
  --- DTM.java  8 Feb 2002 23:33:49 -0000       1.6
  +++ DTM.java  12 Apr 2002 18:26:19 -0000      1.6.6.1
  @@ -994,6 +994,68 @@
      * to shutdown any subsystem activity that may of been assoiated with
      * the active DTM Implementation.
      */
  +  public void documentRelease();
  +   
  +   
  +   /**
  +    * EXPERIMENTAL XPath2 Support:
  +    * 
  +    * Query schema type name of a given node.
  +    * 
  +    * %REVIEW% Is this actually needed?
  +    * 
  +    * @param nodeHandle DTM Node Handle of Node to be queried
  +    * @return null if no type known, else returns the expanded-QName 
(namespace URI
  +    *        rather than prefix) of the type actually
  +    *    resolved in the instance document. Note that this may be derived 
from,
  +    *        rather than identical to, the type declared in the schema.
  +    */
  +   public String getSchemaTypeName(int nodeHandle);
  +     
  +  /** 
  +    * EXPERIMENTAL XPath2 Support:
  +    * 
  +     * Query schema type namespace of a given node.
  +    * 
  +    * %REVIEW% Is this actually needed?
  +    * 
  +    * @param nodeHandle DTM Node Handle of Node to be queried
  +    * @return null if no type known, else returns the namespace URI
  +    *        of the type actually resolved in the instance document. This may
  +    *        be null if the default/unspecified namespace was used.
  +    *    Note that this may be derived from,
  +    *        rather than identical to, the type declared in the schema.
  +    */
  +   public String getSchemaTypeNamespace(int nodeHandle);
   
  -   public void documentRelease();
  +  /** EXPERIMENTAL XPath2 Support: Query schema type localname of a given 
node.
  +   * 
  +   * %REVIEW% Is this actually needed?
  +   * 
  +   * @param nodeHandle DTM Node Handle of Node to be queried
  +   * @return null if no type known, else returns the localname of the type
  +   *    resolved in the instance document. Note that this may be derived 
from,
  +   * rather than identical to, the type declared in the schema.
  +   */
  +  public String getSchemaTypeLocalName(int nodeHandle);
  +
  +  /** EXPERIMENTAL XPath2 Support: Query whether node's type is derived from 
a specific type
  +   * 
  +   * @param nodeHandle DTM Node Handle of Node to be queried
  +   * @param namespace String containing URI of namespace for the type we're 
intersted in
  +   * @param localname String containing local name for the type we're 
intersted in
  +   * @return true if node has a Schema Type which equals or is derived from 
  +   * the specified type. False if the node has no type or that type is not
  +   *         derived from the specified type.
  +   */
  +  public boolean isNodeSchemaType(int nodeHandle, String namespace, String 
localname);
  +  
  +  /** EXPERIMENTAL XPath2 Support: Retrieve the typed value(s), based on the 
schema
  +   *  type.
  +   * 
  +   * @param nodeHandle DTM Node Handle of Node to be queried
  +   * @return XSequence object containing one or more values and their type
  +   * information. If no typed value is available, returns an empty sequence.
  +   * */
  +  public XSequence getTypedValue(int nodeHandle);
   }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.27.2.1  +70 -0     
xml-xalan/java/src/org/apache/xml/dtm/ref/DTMDefaultBase.java
  
  Index: DTMDefaultBase.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/DTMDefaultBase.java,v
  retrieving revision 1.27
  retrieving revision 1.27.2.1
  diff -u -r1.27 -r1.27.2.1
  --- DTMDefaultBase.java       9 Apr 2002 19:06:42 -0000       1.27
  +++ DTMDefaultBase.java       12 Apr 2002 18:26:19 -0000      1.27.2.1
  @@ -2151,4 +2151,74 @@
                 if(m_mgr==null) return null;
                 return m_dtmIdent;
         }
  +      
  +
  +  /**
  +    * EXPERIMENTAL XPath2 Support:
  +    * 
  +    * Query schema type name of a given node.
  +    * 
  +    * %REVIEW% Is this actually needed?
  +    * 
  +    * @param nodeHandle DTM Node Handle of Node to be queried
  +    * @return null if no type known, else returns the expanded-QName 
(namespace URI
  +    *        rather than prefix) of the type actually
  +    *    resolved in the instance document. Note that this may be derived 
from,
  +    *        rather than identical to, the type declared in the schema.
  +    */
  +   public String getSchemaTypeName(int nodeHandle)
  +   { return null; }
  +     
  +  /** 
  +    * EXPERIMENTAL XPath2 Support:
  +    * 
  +     * Query schema type namespace of a given node.
  +    * 
  +    * %REVIEW% Is this actually needed?
  +    * 
  +    * @param nodeHandle DTM Node Handle of Node to be queried
  +    * @return null if no type known, else returns the namespace URI
  +    *        of the type actually resolved in the instance document. This may
  +    *        be null if the default/unspecified namespace was used.
  +    *    Note that this may be derived from,
  +    *        rather than identical to, the type declared in the schema.
  +    */
  +   public String getSchemaTypeNamespace(int nodeHandle)
  +   { return null; }
  +
  +  /** EXPERIMENTAL XPath2 Support: Query schema type localname of a given 
node.
  +   * 
  +   * %REVIEW% Is this actually needed?
  +   * 
  +   * @param nodeHandle DTM Node Handle of Node to be queried
  +   * @return null if no type known, else returns the localname of the type
  +   *    resolved in the instance document. Note that this may be derived 
from,
  +   * rather than identical to, the type declared in the schema.
  +   */
  +  public String getSchemaTypeLocalName(int nodeHandle)
  +   { return null; }
  +
  +  /** EXPERIMENTAL XPath2 Support: Query whether node's type is derived from 
a specific type
  +   * 
  +   * @param nodeHandle DTM Node Handle of Node to be queried
  +   * @param namespace String containing URI of namespace for the type we're 
intersted in
  +   * @param localname String containing local name for the type we're 
intersted in
  +   * @return true if node has a Schema Type which equals or is derived from 
  +   * the specified type. False if the node has no type or that type is not
  +   *         derived from the specified type.
  +   */
  +  public boolean isNodeSchemaType(int nodeHandle, String namespace, String 
localname)
  +   { return false; }
  +  
  +  /** EXPERIMENTAL XPath2 Support: Retrieve the typed value(s), based on the 
schema
  +   *  type.
  +   * 
  +   * @param nodeHandle DTM Node Handle of Node to be queried
  +   * @return XSequence object containing one or more values and their type
  +   * information. If no typed value is available, returns an empty sequence.
  +   * */
  +  public org.apache.xml.dtm.XSequence getTypedValue(int nodeHandle)
  +   {return org.apache.xml.dtm.XSequence.EMPTY;}
  +
  +      
   }
  
  
  
  1.7.6.1   +66 -0     
xml-xalan/java/src/org/apache/xml/dtm/ref/DTMDocumentImpl.java
  
  Index: DTMDocumentImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/DTMDocumentImpl.java,v
  retrieving revision 1.7
  retrieving revision 1.7.6.1
  diff -u -r1.7 -r1.7.6.1
  --- DTMDocumentImpl.java      8 Feb 2002 23:33:50 -0000       1.7
  +++ DTMDocumentImpl.java      12 Apr 2002 18:26:19 -0000      1.7.6.1
  @@ -2445,5 +2445,71 @@
      {
      }
   
  +   /**
  +    * EXPERIMENTAL XPath2 Support:
  +    * 
  +    * Query schema type name of a given node.
  +    * 
  +    * %REVIEW% Is this actually needed?
  +    * 
  +    * @param nodeHandle DTM Node Handle of Node to be queried
  +    * @return null if no type known, else returns the expanded-QName 
(namespace URI
  +    *        rather than prefix) of the type actually
  +    *    resolved in the instance document. Note that this may be derived 
from,
  +    *        rather than identical to, the type declared in the schema.
  +    */
  +   public String getSchemaTypeName(int nodeHandle)
  +   { return null; }
  +     
  +  /** 
  +    * EXPERIMENTAL XPath2 Support:
  +    * 
  +     * Query schema type namespace of a given node.
  +    * 
  +    * %REVIEW% Is this actually needed?
  +    * 
  +    * @param nodeHandle DTM Node Handle of Node to be queried
  +    * @return null if no type known, else returns the namespace URI
  +    *        of the type actually resolved in the instance document. This may
  +    *        be null if the default/unspecified namespace was used.
  +    *    Note that this may be derived from,
  +    *        rather than identical to, the type declared in the schema.
  +    */
  +   public String getSchemaTypeNamespace(int nodeHandle)
  +   { return null; }
  +
  +  /** EXPERIMENTAL XPath2 Support: Query schema type localname of a given 
node.
  +   * 
  +   * %REVIEW% Is this actually needed?
  +   * 
  +   * @param nodeHandle DTM Node Handle of Node to be queried
  +   * @return null if no type known, else returns the localname of the type
  +   *    resolved in the instance document. Note that this may be derived 
from,
  +   * rather than identical to, the type declared in the schema.
  +   */
  +  public String getSchemaTypeLocalName(int nodeHandle)
  +   { return null; }
  +
  +  /** EXPERIMENTAL XPath2 Support: Query whether node's type is derived from 
a specific type
  +   * 
  +   * @param nodeHandle DTM Node Handle of Node to be queried
  +   * @param namespace String containing URI of namespace for the type we're 
intersted in
  +   * @param localname String containing local name for the type we're 
intersted in
  +   * @return true if node has a Schema Type which equals or is derived from 
  +   * the specified type. False if the node has no type or that type is not
  +   *         derived from the specified type.
  +   */
  +  public boolean isNodeSchemaType(int nodeHandle, String namespace, String 
localname)
  +   { return false; }
  +  
  +  /** EXPERIMENTAL XPath2 Support: Retrieve the typed value(s), based on the 
schema
  +   *  type.
  +   * 
  +   * @param nodeHandle DTM Node Handle of Node to be queried
  +   * @return XSequence object containing one or more values and their type
  +   * information. If no typed value is available, returns an empty sequence.
  +   * */
  +  public org.apache.xml.dtm.XSequence getTypedValue(int nodeHandle)
  +   {return org.apache.xml.dtm.XSequence.EMPTY;}
   
   }
  
  
  
  1.41.2.1  +14 -8     
xml-xalan/java/src/org/apache/xml/dtm/ref/DTMManagerDefault.java
  
  Index: DTMManagerDefault.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/DTMManagerDefault.java,v
  retrieving revision 1.41
  retrieving revision 1.41.2.1
  diff -u -r1.41 -r1.41.2.1
  --- DTMManagerDefault.java    10 Apr 2002 13:30:42 -0000      1.41
  +++ DTMManagerDefault.java    12 Apr 2002 18:26:19 -0000      1.41.2.1
  @@ -75,10 +75,10 @@
   import org.apache.xml.dtm.ref.sax2dtm.SAX2DTM;
   import org.apache.xml.dtm.ref.sax2dtm.SAX2RTFDTM;
   
  -/**************************************************************
  +/**************************************************************/
   // EXPERIMENTAL 3/22/02
   import org.apache.xml.dtm.ref.xni2dtm.XNI2DTM;
  -**************************************************************/
  +/**************************************************************/
   
   // W3C DOM
   import org.w3c.dom.Document;
  @@ -121,8 +121,14 @@
    * */
   public class DTMManagerDefault extends DTMManager
   {
  -  //static final boolean JKESS_XNI_EXPERIMENT=true;
  -
  +  /** TEMPORARY EXPERIMENTAL: If true, enable Joe's kluge to drag in the
  +   * XNI2DTM/XPath2 support. This may be a sloppy solution, mostly because
  +   * our getDTM() method is unnecessarily convoluted and needs to be
  +   * rationalized. There's also the problem that XNI2DTM requires Xerces2
  +   * in order to compile... so we may want reflection here. GRUMP!
  +   * */
  +  private static final boolean JKESS_XNI_EXPERIMENT=true;    
  +     
     /** Set this to true if you want a dump of the DTM after creation. */
     private static final boolean DUMPTREE = false;
   
  @@ -354,14 +360,14 @@
             dtm = new SAX2RTFDTM(this, source, documentID, whiteSpaceFilter,
                                  xstringFactory, doIndexing);
           }
  -        /**************************************************************
  +        /**************************************************************/
           // EXPERIMENTAL 3/22/02
           else if(JKESS_XNI_EXPERIMENT && m_incremental)
           {            
             dtm = new XNI2DTM(this, source, documentID, whiteSpaceFilter,
                               xstringFactory, doIndexing);
           }
  -        **************************************************************/
  +        /**************************************************************/
           else // Create the basic SAX2DTM.
           {
             dtm = new SAX2DTM(this, source, documentID, whiteSpaceFilter,
  @@ -412,7 +418,7 @@
             }
   
                        
  -        /**************************************************************
  +        /**************************************************************/
           // EXPERIMENTAL 3/22/02
             if(JKESS_XNI_EXPERIMENT && m_incremental & 
                dtm instanceof XNI2DTM && 
  @@ -427,7 +433,7 @@
                        // Listen to the SAX stream (will fail, 
diagnostically...)
                                dtm.setIncrementalSAXSource(coParser);
             } else
  -          ***************************************************************/
  +          /***************************************************************/
             
             // Have the DTM set itself up as the IncrementalSAXSource's 
listener.
             dtm.setIncrementalSAXSource(coParser);
  
  
  
  1.8.6.1   +33 -0     
xml-xalan/java/src/org/apache/xml/dtm/ref/IncrementalSAXSource_Xerces.java
  
  Index: IncrementalSAXSource_Xerces.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/IncrementalSAXSource_Xerces.java,v
  retrieving revision 1.8
  retrieving revision 1.8.6.1
  diff -u -r1.8 -r1.8.6.1
  --- IncrementalSAXSource_Xerces.java  6 Feb 2002 17:46:45 -0000       1.8
  +++ IncrementalSAXSource_Xerces.java  12 Apr 2002 18:26:19 -0000      1.8.6.1
  @@ -177,6 +177,27 @@
                        this.fParseSome=dummy.fParseSome;
                        this.fIncrementalParser=dummy.fIncrementalParser;
                }
  +
  +             // General SAX-level feature initialization
  +             try
  +             {
  +                     
fIncrementalParser.setFeature("http://xml.org/sax/features/validation",true);
  +             }
  +             catch(org.xml.sax.SAXNotRecognizedException e) 
{e.printStackTrace();}
  +             catch(org.xml.sax.SAXNotSupportedException e) 
{e.printStackTrace();}
  +             try
  +             {
  +                     
fIncrementalParser.setFeature("http://apache.org/xml/features/validation/dynamic",true);
  +             }
  +             catch(org.xml.sax.SAXNotRecognizedException e) 
{e.printStackTrace();}
  +             catch(org.xml.sax.SAXNotSupportedException e) 
{e.printStackTrace();}
  +             try
  +             {
  +                     
fIncrementalParser.setFeature("http://apache.org/xml/features/validation/schema",true);
  +             }
  +             catch(org.xml.sax.SAXNotRecognizedException e) 
{e.printStackTrace();}
  +             catch(org.xml.sax.SAXNotSupportedException e) 
{e.printStackTrace();}
  +             
     }
   
     /** Create a IncrementalSAXSource_Xerces wrapped around
  @@ -479,6 +500,18 @@
       }
       
     }
  +  
  +  /** EXPERIMENTAL AS OF 3/22/02: Support for XNI2DTM, allowing us to
  +   * bind direct to the parser's XNI stream.
  +   * 
  +   * %BUG% Gonk -- This requires hard link to Xerces2. Could use reflection
  +   * typecasting, but for now... Does anyone still care about Xerces1?
  +   * */
  +  public org.apache.xerces.xni.parser.XMLPullParserConfiguration 
getXNIParserConfiguration()
  +  {
  +     return 
(org.apache.xerces.xni.parser.XMLPullParserConfiguration)fPullParserConfig;
  +  }
  +
   
     
   } // class IncrementalSAXSource_Xerces
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.27.6.1  +36 -16    
xml-xalan/java/src/org/apache/xml/dtm/ref/sax2dtm/SAX2DTM.java
  
  Index: SAX2DTM.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/sax2dtm/SAX2DTM.java,v
  retrieving revision 1.27
  retrieving revision 1.27.6.1
  diff -u -r1.27 -r1.27.6.1
  --- SAX2DTM.java      6 Feb 2002 17:46:45 -0000       1.27
  +++ SAX2DTM.java      12 Apr 2002 18:26:19 -0000      1.27.6.1
  @@ -116,11 +116,26 @@
      * between RTFs, and tail-pruning... consider going back to the 
larger/faster.
      *
      * Made protected rather than private so SAX2RTFDTM can access it.
  -   */
  -  //private FastStringBuffer m_chars = new FastStringBuffer(13, 13);
  -  protected FastStringBuffer m_chars = new FastStringBuffer(5, 13);
  -
  -  /** This vector holds offset and length data.
  +   * Minimum chunk size pushed up now that SAX2RTFDTM is in use (larger
  +   * minimum allocation, lower overhead as it grows). 
  +   * %REVIEW% Variable size disabled in FSB. Consider (13,13).
  +   */
  +  protected FastStringBuffer m_chars = new FastStringBuffer(10, 13);
  +
  +  /** This vector holds _integer pairs_ representing the "node value"
  +   * referenced by m_dataOrQName. It's basically a kluge to save a word 
  +   * per node for nodes which don't carry this information... AND is
  +   * overloaded to handle two distinct cases.
  +   * 
  +   * In: index (and index+1) from m_dataOrQName 
  +   * 
  +   * Out: Offset and length references into m_chars (for character content)
  +   *         ***OR***
  +   *         (IF m_dataOrQName returned a negated index for an Attr node,
  +   *    indicating a prefixed attribute):
  +   *         m_valuesOrPrefixes identifiers of prefix and value 
  +   *
  +   * %REVIEW% Is this really the best solution? I hae me doots!
      */
     protected SuballocatedIntVector m_data;
   
  @@ -164,7 +179,7 @@
     protected DTMTreeWalker m_walker = new DTMTreeWalker();
   
     /** pool of string values that come as strings. */
  -  private DTMStringPool m_valuesOrPrefixes = new DTMStringPool();
  +  protected DTMStringPool m_valuesOrPrefixes = new DTMStringPool();
   
     /** End document has been reached.
      * Made protected rather than private so SAX2RTFDTM can access it.
  @@ -693,13 +708,13 @@
   
       identity += 1;
   
  -    while (identity >= m_size)
  -    {
  -      if (null == m_incrementalSAXSource)
  -        return DTM.NULL;
  +    while (identity >= m_size && nextNode())
  +     ;
   
  -      nextNode();
  -    }
  +     // If we exited because nextNode ran off the end of the document,
  +     // rather than because we found the node we needed, return null.
  +     if(identity>=m_size)
  +             return DTM.NULL;
   
       return identity;
     }
  @@ -749,8 +764,13 @@
   
     /**
      * This method should try and build one or more nodes in the table.
  +   * 
  +   * %OPT% When working with Xerces2, an incremental parsing step may not
  +   * actually generate a SAX event that causes a node to be built. Our 
higher-
  +   * level code is already looping to see if the desired node was obtained...
  +   * but should we also be looping more tightly here?
      *
  -   * @return The true if a next node is found or false if
  +   * @return True if parsing proceeded normally or false if
      *         there are no more nodes.
      */
     protected boolean nextNode()
  @@ -1078,7 +1098,7 @@
     {
   
       int identity = makeNodeIdentity(nodeHandle);
  -    int type = getNodeType(identity);
  +    int type = _type(identity);
   
       if (DTM.ELEMENT_NODE == type)
       {
  @@ -1305,7 +1325,7 @@
      *
      * @return The prefix if there is one, or null.
      */
  -  private String getPrefix(String qname, String uri)
  +  protected String getPrefix(String qname, String uri)
     {
   
       String prefix;
  @@ -1682,7 +1702,7 @@
       return false;
     }
        
  -     boolean m_pastFirstElement=false;
  +     protected boolean m_pastFirstElement=false;
   
     /**
      * Receive notification of the start of an element.
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to