sboag       01/05/29 07:31:55

  Modified:    java/src/org/apache/xalan/templates Tag: DTM_EXP
                        ElemForEach.java ElemValueOf.java
               java/src/org/apache/xalan/transformer Tag: DTM_EXP
                        ClonerToResultTree.java TransformerImpl.java
               java/src/org/apache/xml/dtm Tag: DTM_EXP DTM.java
               java/src/org/apache/xml/dtm/ref Tag: DTM_EXP
                        DTMDefaultBase.java DTMDefaultBaseTraversers.java
                        DTMDocumentImpl.java DTMStringPool.java
                        DTMTreeWalker.java ExpandedNameTable.java
               java/src/org/apache/xml/dtm/ref/dom2dtm Tag: DTM_EXP
                        DOM2DTM.java
               java/src/org/apache/xml/dtm/ref/sax2dtm Tag: DTM_EXP
                        SAX2DTM.java
               java/src/org/apache/xml/utils Tag: DTM_EXP
                        FastStringBuffer.java
               java/src/org/apache/xpath Tag: DTM_EXP Expression.java
                        XPath.java XPathContext.java
               java/src/org/apache/xpath/axes Tag: DTM_EXP
                        ChildIterator.java DescendantIterator.java
                        LocPathIterator.java OneStepIteratorForward.java
                        SelfIteratorNoPredicate.java
               java/src/org/apache/xpath/functions Tag: DTM_EXP
                        FuncNormalizeSpace.java FunctionDef1Arg.java
                        FunctionOneArg.java
               java/src/org/apache/xpath/objects Tag: DTM_EXP XObject.java
  Log:
  Implemented new isNodesetExpr and asNode methods on Expression,
  and getArg0AsNode and Arg0IsNodesetExpr on FunctionDef1Arg.
  This allows functions that just take a single node to get that node
  without creating an XNodeset or iterator if the expression is a simple
  one-step LocationPath (more complicated LocationPaths still need
  iterators, at least for the moment).  There will be more to come along
  these lines, trying to reduce the number of XObject derivatives that are
  are created during function evaluation.
  
  Added sendNormalizedSAXcharacters to the FastStringBuffer, and
  a param on DTM#dispatchCharactersEvents to enable normalization
  of the characters.  This allows us to send normalized characters
  without copying.  I think the sendNormalizedSAXcharacters may
  need a little tuning.
  
  Added tweak/hack to DTMDefaultBase which is a flag telling
  if a namespace has been seen, and, if it has not, always return
  immediately from getFirstNamespaceNode, which, as it turns
  out, is called a lot in the course of copy operations.  We need to
  come up with something better than this.  I suggested to Joe
  that we use a bitset for namespaces and attributes that will
  tell us if a given element has these nodes (I think it would help
  for getFirstAttribute as well).
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.20.2.5  +1 -1      
xml-xalan/java/src/org/apache/xalan/templates/ElemForEach.java
  
  Index: ElemForEach.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemForEach.java,v
  retrieving revision 1.20.2.4
  retrieving revision 1.20.2.5
  diff -u -r1.20.2.4 -r1.20.2.5
  --- ElemForEach.java  2001/05/16 05:32:55     1.20.2.4
  +++ ElemForEach.java  2001/05/29 14:30:59     1.20.2.5
  @@ -423,7 +423,7 @@
                 case DTM.ATTRIBUTE_NODE :
                 case DTM.CDATA_SECTION_NODE :
                 case DTM.TEXT_NODE :
  -                dtm.dispatchCharactersEvents(child, rth);
  +                dtm.dispatchCharactersEvents(child, rth, false);
                   continue;
                 case DTM.DOCUMENT_NODE :
                   template = sroot.getDefaultRootRule();
  
  
  
  1.13.2.5  +60 -65    
xml-xalan/java/src/org/apache/xalan/templates/ElemValueOf.java
  
  Index: ElemValueOf.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemValueOf.java,v
  retrieving revision 1.13.2.4
  retrieving revision 1.13.2.5
  diff -u -r1.13.2.4 -r1.13.2.5
  --- ElemValueOf.java  2001/05/27 03:05:14     1.13.2.4
  +++ ElemValueOf.java  2001/05/29 14:31:00     1.13.2.5
  @@ -70,7 +70,7 @@
   import org.apache.xalan.res.XSLTErrorResources;
   import org.apache.xalan.transformer.TransformerImpl;
   import org.apache.xalan.transformer.ResultTreeHandler;
  -
  +import org.apache.xml.utils.PrefixResolver;
   import org.apache.xml.utils.QName;
   import org.apache.xml.utils.XMLString;
   
  @@ -96,7 +96,7 @@
      * @serial
      */
     private XPath m_selectExpression = null;
  -  
  +
     /**
      * True if the pattern is a simple ".".
      * @serial
  @@ -113,11 +113,14 @@
      */
     public void setSelect(XPath v)
     {
  -    if(null != v)
  +
  +    if (null != v)
       {
         String s = v.getPatternString();
  +
         m_isDot = (null != s) && s.equals(".");
       }
  +
       m_selectExpression = v;
     }
   
  @@ -229,92 +232,84 @@
      *
      * @throws TransformerException
      */
  -  public void execute(
  -          TransformerImpl transformer)
  -            throws TransformerException
  +  public void execute(TransformerImpl transformer) throws 
TransformerException
     {
   
  -             XPathContext xctxt = transformer.getXPathContext();
  -             boolean didPushCurrent = false;
  +    XPathContext xctxt = transformer.getXPathContext();
  +    ResultTreeHandler rth = transformer.getResultTreeHandler();
  +
       try
       {
         if (TransformerImpl.S_DEBUG)
           transformer.getTraceManager().fireTraceEvent(this);
   
  -      
  -      int sourceNode = xctxt.getCurrentNode();                       
  -      int child;
  -      XObject value;
  -      
         // Optimize for "."
  -      if(m_isDot && !TransformerImpl.S_DEBUG)
  -      {
  -        child = sourceNode;
  -        value = null;
  -      }
  -      else
  +      if (m_isDot &&!TransformerImpl.S_DEBUG)
         {
  -        value = m_selectExpression.execute(transformer.getXPathContext(),
  -                                                 sourceNode, this);
  -        if(value.getType() == XObject.CLASS_NODESET)
  -        {
  -          DTMIterator iterator = value.nodeset();
  -          child = iterator.nextNode();
  -          if(DTM.NULL == child)
  -            return;
  -        }
  -        else
  -          child = DTM.NULL;
  -        if (TransformerImpl.S_DEBUG)
  -          transformer.getTraceManager().fireSelectedEvent(sourceNode, this,
  -                                                          "select", 
m_selectExpression, value);
  -      }
  -         
  -      XMLString s;                                                           
                                  
  -      if(DTM.NULL != child)
  -      {
  -                             xctxt.pushCurrentNode(child);
  -                             didPushCurrent = true;
  +        int child = xctxt.getCurrentNode();
           DTM dtm = xctxt.getDTM(child);
  -        ResultTreeHandler rth = transformer.getResultTreeHandler();
  +
  +        xctxt.pushCurrentNode(child);
  +
           if (m_disableOutputEscaping)
  +          rth.processingInstruction(
  +            javax.xml.transform.Result.PI_DISABLE_OUTPUT_ESCAPING, "");
  +
  +        try
           {
  -          
rth.processingInstruction(javax.xml.transform.Result.PI_DISABLE_OUTPUT_ESCAPING,
 "");
  -          dtm.dispatchCharactersEvents(child, rth);
  -          
rth.processingInstruction(javax.xml.transform.Result.PI_ENABLE_OUTPUT_ESCAPING, 
"");
  +          dtm.dispatchCharactersEvents(child, rth, false);
  +
  +          // %TBD% if (TransformerImpl.S_DEBUG)
  +          //  transformer.getTraceManager().fireSelectedEvent(child, this,
  +          //          "select", m_selectExpression, ??value??);
           }
  -        else
  -          dtm.dispatchCharactersEvents(child, rth);
  -        return;
  +        finally
  +        {
  +          if (m_disableOutputEscaping)
  +            rth.processingInstruction(
  +              javax.xml.transform.Result.PI_ENABLE_OUTPUT_ESCAPING, "");
  +
  +          xctxt.popCurrentNode();
  +        }
         }
         else
  -      {
  -        s = value.xstr();
  -      }
  -      
  -      int len = (null != s) ? s.length() : 0;
  -      if(len > 0)
         {
  -        ResultTreeHandler rth = transformer.getResultTreeHandler();
  +        PrefixResolver savedPrefixResolver = xctxt.getNamespaceContext();
  +
  +        xctxt.setNamespaceContext(this);
  +
  +        int current = xctxt.getCurrentNode();
  +
  +        xctxt.pushCurrentNodeAndExpression(current, current);
   
           if (m_disableOutputEscaping)
  +          rth.processingInstruction(
  +            javax.xml.transform.Result.PI_DISABLE_OUTPUT_ESCAPING, "");
  +
  +        try
  +        {
  +          Expression expr = m_selectExpression.getExpression();
  +
  +          expr.executeCharsToContentHandler(xctxt, rth);
  +
  +          // %TBD% if (TransformerImpl.S_DEBUG)
  +          //  transformer.getTraceManager().fireSelectedEvent(child, this,
  +          //          "select", m_selectExpression, ??value??);
  +        }
  +        finally
           {
  -          
rth.processingInstruction(javax.xml.transform.Result.PI_DISABLE_OUTPUT_ESCAPING,
 "");
  -          s.dispatchCharactersEvents(rth);
  -          
rth.processingInstruction(javax.xml.transform.Result.PI_ENABLE_OUTPUT_ESCAPING, 
"");
  +          if (m_disableOutputEscaping)
  +            rth.processingInstruction(
  +              javax.xml.transform.Result.PI_ENABLE_OUTPUT_ESCAPING, "");
  +
  +          xctxt.setNamespaceContext(savedPrefixResolver);
  +          xctxt.popCurrentNodeAndExpression();
           }
  -        else
  -          s.dispatchCharactersEvents(rth);
         }
       }
  -    catch(SAXException se)
  +    catch (SAXException se)
       {
         throw new TransformerException(se);
  -    }
  -             finally
  -    {
  -                     if (didPushCurrent) 
  -                             xctxt.popCurrentNode();
       }
     }
   
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.9.2.5   +2 -2      
xml-xalan/java/src/org/apache/xalan/transformer/ClonerToResultTree.java
  
  Index: ClonerToResultTree.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/transformer/ClonerToResultTree.java,v
  retrieving revision 1.9.2.4
  retrieving revision 1.9.2.5
  diff -u -r1.9.2.4 -r1.9.2.5
  --- ClonerToResultTree.java   2001/05/22 05:48:44     1.9.2.4
  +++ ClonerToResultTree.java   2001/05/29 14:31:04     1.9.2.5
  @@ -120,7 +120,7 @@
         switch (dtm.getNodeType(node))
         {
         case DTM.TEXT_NODE :
  -        dtm.dispatchCharactersEvents(node, m_rth);
  +        dtm.dispatchCharactersEvents(node, m_rth, false);
           break;
         case DTM.DOCUMENT_FRAGMENT_NODE :
         case DTM.DOCUMENT_NODE :
  @@ -146,7 +146,7 @@
           break;
         case DTM.CDATA_SECTION_NODE :
           m_rth.startCDATA();          
  -        dtm.dispatchCharactersEvents(node, m_rth);
  +        dtm.dispatchCharactersEvents(node, m_rth, false);
           m_rth.endCDATA();
           break;
         case DTM.ATTRIBUTE_NODE :
  
  
  
  1.90.2.15 +1 -1      
xml-xalan/java/src/org/apache/xalan/transformer/TransformerImpl.java
  
  Index: TransformerImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/transformer/TransformerImpl.java,v
  retrieving revision 1.90.2.14
  retrieving revision 1.90.2.15
  diff -u -r1.90.2.14 -r1.90.2.15
  --- TransformerImpl.java      2001/05/28 04:07:22     1.90.2.14
  +++ TransformerImpl.java      2001/05/29 14:31:05     1.90.2.15
  @@ -1930,7 +1930,7 @@
             m_resultTreeHandler.m_cloner.cloneToResultTree(child, false);
             break;
           case DTM.ATTRIBUTE_NODE :
  -          dtm.dispatchCharactersEvents(child, getResultTreeHandler());
  +          dtm.dispatchCharactersEvents(child, getResultTreeHandler(), false);
             break;
           }
         }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.19  +5 -1      xml-xalan/java/src/org/apache/xml/dtm/Attic/DTM.java
  
  Index: DTM.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/Attic/DTM.java,v
  retrieving revision 1.1.2.18
  retrieving revision 1.1.2.19
  diff -u -r1.1.2.18 -r1.1.2.19
  --- DTM.java  2001/05/21 11:44:00     1.1.2.18
  +++ DTM.java  2001/05/29 14:31:08     1.1.2.19
  @@ -808,11 +808,15 @@
      *
      * @param nodeHandle The node ID.
      * @param ch A non-null reference to a ContentHandler.
  +   * @param normalize true if the content should be normalized according to 
  +   * the rules for the XPath
  +   * <a 
href="http://www.w3.org/TR/xpath#function-normalize-space";>normalize-space</a>
  +   * function.
      *
      * @throws org.xml.sax.SAXException
      */
     public void dispatchCharactersEvents(
  -    int nodeHandle, org.xml.sax.ContentHandler ch)
  +    int nodeHandle, org.xml.sax.ContentHandler ch, boolean normalize)
         throws org.xml.sax.SAXException;
   
     /**
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.4   +12 -3     
xml-xalan/java/src/org/apache/xml/dtm/ref/Attic/DTMDefaultBase.java
  
  Index: DTMDefaultBase.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/Attic/DTMDefaultBase.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- DTMDefaultBase.java       2001/05/28 20:13:57     1.1.2.3
  +++ DTMDefaultBase.java       2001/05/29 14:31:12     1.1.2.4
  @@ -108,6 +108,9 @@
   
     /** Previous sibling values, one array element for each node. */
     protected short[] m_parent;
  +  
  +  /** Experemental.  -sb */
  +  protected boolean m_haveSeenNamespace = false;
   
     /**
      * These hold indexes to elements based on namespace and local name.
  @@ -295,7 +298,7 @@
     {
   
       ExpandedNameTable ent = m_expandedNameTable;
  -    int type = ent.getType(expandedTypeID);
  +    short type = ent.getType(expandedTypeID);
   
       if (DTM.ELEMENT_NODE == type)
       {
  @@ -466,7 +469,7 @@
      *
      * @return The simple type ID, or DTM.NULL.
      */
  -  protected int _type(int identity)
  +  protected short _type(int identity)
     {
   
       int info = getExpandedTypeID(identity);
  @@ -1081,6 +1084,8 @@
      */
     public int getFirstNamespaceNode(int nodeHandle, boolean inScope)
     {
  +    if(!m_haveSeenNamespace)
  +      return NULL;
   
       int type = getNodeType(nodeHandle);
   
  @@ -1783,11 +1788,15 @@
      *
      * @param nodeHandle The node ID.
      * @param ch A non-null reference to a ContentHandler.
  +   * @param normalize true if the content should be normalized according to 
  +   * the rules for the XPath
  +   * <a 
href="http://www.w3.org/TR/xpath#function-normalize-space";>normalize-space</a>
  +   * function.
      *
      * @throws org.xml.sax.SAXException
      */
     public abstract void dispatchCharactersEvents(
  -    int nodeHandle, org.xml.sax.ContentHandler ch)
  +    int nodeHandle, org.xml.sax.ContentHandler ch, boolean normalize)
         throws org.xml.sax.SAXException;
   
     /**
  
  
  
  1.1.2.7   +4 -4      
xml-xalan/java/src/org/apache/xml/dtm/ref/Attic/DTMDefaultBaseTraversers.java
  
  Index: DTMDefaultBaseTraversers.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/Attic/DTMDefaultBaseTraversers.java,v
  retrieving revision 1.1.2.6
  retrieving revision 1.1.2.7
  diff -u -r1.1.2.6 -r1.1.2.7
  --- DTMDefaultBaseTraversers.java     2001/05/28 06:21:25     1.1.2.6
  +++ DTMDefaultBaseTraversers.java     2001/05/29 14:31:13     1.1.2.7
  @@ -1090,7 +1090,7 @@
         for (current = (current & m_mask) - 1; current >= 0; current--)
         {
           int exptype = m_exptype[current];
  -        int type = ExpandedNameTable.getType(exptype);
  +        short type = ExpandedNameTable.getType(exptype);
   
           if (ATTRIBUTE_NODE == type || NAMESPACE_NODE == type
                   || isAncestor(subtreeRootIdent, current))
  @@ -1120,7 +1120,7 @@
         for (current = (current & m_mask) - 1; current >= 0; current--)
         {
           int exptype = m_exptype[current];
  -        int type = ExpandedNameTable.getType(exptype);
  +        short type = ExpandedNameTable.getType(exptype);
   
           if (exptype != extendedTypeID
                   || isAncestor(subtreeRootIdent, current))
  @@ -1156,7 +1156,7 @@
         for (current = (current & m_mask) - 1; current >= 0; current--)
         {
           int exptype = m_exptype[current];
  -        int type = ExpandedNameTable.getType(exptype);
  +        short type = ExpandedNameTable.getType(exptype);
   
           if (ATTRIBUTE_NODE == type || NAMESPACE_NODE == type)
             continue;
  @@ -1185,7 +1185,7 @@
         for (current = (current & m_mask) - 1; current >= 0; current--)
         {
           int exptype = m_exptype[current];
  -        int type = ExpandedNameTable.getType(exptype);
  +        short type = ExpandedNameTable.getType(exptype);
   
           if (exptype != extendedTypeID)
             continue;
  
  
  
  1.1.2.2   +1 -1      
xml-xalan/java/src/org/apache/xml/dtm/ref/Attic/DTMDocumentImpl.java
  
  Index: DTMDocumentImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/Attic/DTMDocumentImpl.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- DTMDocumentImpl.java      2001/05/23 02:57:01     1.1.2.1
  +++ DTMDocumentImpl.java      2001/05/29 14:31:14     1.1.2.2
  @@ -2058,7 +2058,7 @@
            * @throws org.xml.sax.SAXException
            */
           public void dispatchCharactersEvents(
  -                                                                             
                                                                           int 
nodeHandle, org.xml.sax.ContentHandler ch)
  +                                                                             
                                                                           int 
nodeHandle, org.xml.sax.ContentHandler ch, boolean normalize)
           throws org.xml.sax.SAXException {}
   
           /**
  
  
  
  1.1.2.2   +1 -1      
xml-xalan/java/src/org/apache/xml/dtm/ref/Attic/DTMStringPool.java
  
  Index: DTMStringPool.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/Attic/DTMStringPool.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- DTMStringPool.java        2001/05/23 02:57:12     1.1.2.1
  +++ DTMStringPool.java        2001/05/29 14:31:15     1.1.2.2
  @@ -99,7 +99,7 @@
     public DTMStringPool()
       {
         m_intToString=new Vector();
  -      m_hashChain=new IntVector();
  +      m_hashChain=new IntVector(512);
         removeAllElements();
         
         // -sb Add this to force empty strings to be index 0.
  
  
  
  1.1.2.2   +1 -1      
xml-xalan/java/src/org/apache/xml/dtm/ref/Attic/DTMTreeWalker.java
  
  Index: DTMTreeWalker.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/Attic/DTMTreeWalker.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- DTMTreeWalker.java        2001/05/23 02:57:15     1.1.2.1
  +++ DTMTreeWalker.java        2001/05/29 14:31:15     1.1.2.2
  @@ -241,7 +241,7 @@
     private final void dispatachChars(int node)
        throws org.xml.sax.SAXException
     {
  -    m_dtm.dispatchCharactersEvents(node, m_contentHandler);
  +    m_dtm.dispatchCharactersEvents(node, m_contentHandler, false);
     }
   
     /**
  
  
  
  1.1.2.3   +2 -2      
xml-xalan/java/src/org/apache/xml/dtm/ref/Attic/ExpandedNameTable.java
  
  Index: ExpandedNameTable.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/Attic/ExpandedNameTable.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- ExpandedNameTable.java    2001/05/28 04:07:29     1.1.2.2
  +++ ExpandedNameTable.java    2001/05/29 14:31:16     1.1.2.3
  @@ -224,9 +224,9 @@
      * @param ExpandedNameID an ID that represents an expanded-name.
      * @return The id of this local name.
      */
  -  public static final int getType(int ExpandedNameID)
  +  public static final short getType(int ExpandedNameID)
     {
  -    return ExpandedNameID >> ROTAMOUNT_TYPE;
  +    return (short)(ExpandedNameID >> ROTAMOUNT_TYPE);
     }
     
   }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.6   +3 -1      
xml-xalan/java/src/org/apache/xml/dtm/ref/dom2dtm/Attic/DOM2DTM.java
  
  Index: DOM2DTM.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/dom2dtm/Attic/DOM2DTM.java,v
  retrieving revision 1.1.2.5
  retrieving revision 1.1.2.6
  diff -u -r1.1.2.5 -r1.1.2.6
  --- DOM2DTM.java      2001/05/28 06:27:25     1.1.2.5
  +++ DOM2DTM.java      2001/05/29 14:31:22     1.1.2.6
  @@ -260,6 +260,7 @@
         if (name.startsWith("xmlns:") || name.equals("xmlns"))
         {
           type = DTM.NAMESPACE_NODE;
  +        m_haveSeenNamespace = true;
         }
       }
       
  @@ -1350,7 +1351,8 @@
      * @throws org.xml.sax.SAXException
      */
     public void dispatchCharactersEvents(
  -          int nodeHandle, org.xml.sax.ContentHandler ch)
  +          int nodeHandle, org.xml.sax.ContentHandler ch, 
  +          boolean normalize)
               throws org.xml.sax.SAXException
     {
       int type = getNodeType(nodeHandle);
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.4   +32 -11    
xml-xalan/java/src/org/apache/xml/dtm/ref/sax2dtm/Attic/SAX2DTM.java
  
  Index: SAX2DTM.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/sax2dtm/Attic/SAX2DTM.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- SAX2DTM.java      2001/05/28 06:22:15     1.1.2.3
  +++ SAX2DTM.java      2001/05/29 14:31:26     1.1.2.4
  @@ -124,7 +124,7 @@
     private FastStringBuffer m_chars = new FastStringBuffer(13, 13);
   
     /** This vector holds offset and length data. */
  -  protected IntVector m_data = new IntVector();
  +  protected IntVector m_data;
   
     /** The parent stack, needed only for construction. */
     transient private IntStack m_parents = new IntStack();
  @@ -210,7 +210,7 @@
      * or -1 if there is no text node in progress
      */
     private int m_textPendingStart = -1;
  -
  +  
     /**
      * Construct a SAX2DTM object ready to be constructed from SAX2
      * ContentHandler events.
  @@ -232,6 +232,8 @@
   
       super(mgr, source, dtmIdentity, whiteSpaceFilter, 
             xstringfactory, doIndexing);
  +          
  +    m_data = new IntVector(doIndexing ? (1024*4) : 512);
   
       m_dataOrQName = new short[m_initialblocksize];
   
  @@ -452,10 +454,15 @@
      *
      * @param nodeHandle The node ID.
      * @param ch A non-null reference to a ContentHandler.
  +   * @param normalize true if the content should be normalized according to 
  +   * the rules for the XPath
  +   * <a 
href="http://www.w3.org/TR/xpath#function-normalize-space";>normalize-space</a>
  +   * function.
      *
      * @throws SAXException
      */
  -  public void dispatchCharactersEvents(int nodeHandle, ContentHandler ch)
  +  public void dispatchCharactersEvents(int nodeHandle, ContentHandler ch, 
  +                                       boolean normalize)
             throws SAXException
     {
   
  @@ -467,8 +474,11 @@
         int dataIndex = m_dataOrQName[identity];
         int offset = m_data.elementAt(dataIndex);
         int length = m_data.elementAt(dataIndex + 1);
  -
  -      m_chars.sendSAXcharacters(ch, offset, length);
  +      
  +      if(normalize)
  +        m_chars.sendNormalizedSAXcharacters(ch, offset, length);
  +      else
  +        m_chars.sendSAXcharacters(ch, offset, length);
       }
       else
       {
  @@ -503,7 +513,10 @@
   
           if (length > 0)
           {
  -          m_chars.sendSAXcharacters(ch, offset, length);
  +          if(normalize)
  +            m_chars.sendNormalizedSAXcharacters(ch, offset, length);
  +          else
  +            m_chars.sendSAXcharacters(ch, offset, length);
           }
         }
         else
  @@ -518,11 +531,16 @@
   
           String str = m_valuesOrPrefixes.indexToString(dataIndex);
   
  -        ch.characters(str.toCharArray(), 0, str.length());
  +          if(normalize)
  +            FastStringBuffer.sendNormalizedSAXcharacters(str.toCharArray(), 
  +                                                         0, str.length(), 
ch);
  +          else
  +            ch.characters(str.toCharArray(), 0, str.length());
         }
       }
     }
   
  +
     /**
      * Given a node handle, return its DOM-style node name. This will
      * include names such as #text or #document.
  @@ -803,11 +821,11 @@
         m_dataOrQName = new short[newcapacity];
   
         System.arraycopy(dataOrQName, 0, m_dataOrQName, 0, capacity);
  +      
  +      // We have to do this after we do our resize, since DTMDefaultBase 
  +      // will change m_blocksize before it exits.
  +      super.ensureSize(index);
       }
  -
  -    // We have to do this after we do our resize, since DTMDefaultBase 
  -    // will change m_blocksize before it exits.
  -    super.ensureSize(index);
     }
   
     /**
  @@ -841,6 +859,9 @@
       m_parent[nodeIndex] = (short) parentIndex;
       m_exptype[nodeIndex] = expandedTypeID;
       m_dataOrQName[nodeIndex] = (short) dataOrPrefix;
  +    
  +    if(DTM.NAMESPACE_NODE == type)
  +      m_haveSeenNamespace = true;
   
       if (DTM.NULL != parentIndex && type != DTM.ATTRIBUTE_NODE
               && type != DTM.NAMESPACE_NODE)
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.10.2.3  +125 -0    
xml-xalan/java/src/org/apache/xml/utils/FastStringBuffer.java
  
  Index: FastStringBuffer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/utils/FastStringBuffer.java,v
  retrieving revision 1.10.2.2
  retrieving revision 1.10.2.3
  diff -u -r1.10.2.2 -r1.10.2.3
  --- FastStringBuffer.java     2001/05/18 21:01:27     1.10.2.2
  +++ FastStringBuffer.java     2001/05/29 14:31:29     1.10.2.3
  @@ -971,6 +971,131 @@
     }
     
     /**
  +   * Sends the specified range of characters as one or more SAX characters()
  +   * events, normalizing the characters according to XSLT rules.
  +   *
  +   * @param ch SAX ContentHandler object to receive the event.
  +   * @param start Offset of first character in the range.
  +   * @param length Number of characters to send.
  +   * @exception org.xml.sax.SAXException may be thrown by handler's
  +   * characters() method.
  +   */
  +  public void sendNormalizedSAXcharacters(
  +          org.xml.sax.ContentHandler ch, int start, int length)
  +            throws org.xml.sax.SAXException
  +  {
  +
  +    int stop = start + length;
  +    int startChunk = start >>> m_chunkBits;
  +    int startColumn = start & m_chunkMask;
  +    int stopChunk = stop >>> m_chunkBits;
  +    int stopColumn = stop & m_chunkMask;
  +
  +    for (int i = startChunk; i < stopChunk; ++i)
  +    {
  +      if (i == 0 && m_innerFSB != null)
  +        m_innerFSB.sendNormalizedSAXcharacters(ch, startColumn,
  +                                     m_chunkSize - startColumn);
  +      else
  +        sendNormalizedSAXcharacters(m_array[i], startColumn, 
  +                                    m_chunkSize - startColumn, ch);
  +
  +      startColumn = 0;  // after first chunk
  +    }
  +
  +    // Last, or only, chunk
  +    if (stopChunk == 0 && m_innerFSB != null)
  +      m_innerFSB.sendNormalizedSAXcharacters(ch, startColumn, stopColumn - 
startColumn);
  +    else if (stopColumn > startColumn)
  +    {
  +      sendNormalizedSAXcharacters(m_array[stopChunk], startColumn,
  +                    stopColumn - startColumn, ch);
  +    }
  +  }
  +  
  +  static char[] m_oneChar = {' '};
  +  
  +  /**
  +   * Directly normalize and dispatch the character array.
  +   *
  +   * @param ch The characters from the XML document.
  +   * @param start The start position in the array.
  +   * @param length The number of characters to read from the array.
  +   * 
  +   * @exception org.xml.sax.SAXException Any SAX exception, possibly
  +   *            wrapping another exception.
  +   */
  +  public static void sendNormalizedSAXcharacters(char ch[], 
  +             int start, int length, 
  +             org.xml.sax.ContentHandler handler)
  +          throws org.xml.sax.SAXException
  +  {
  +    int end = length + start;
  +    int s;
  +    for (s = start; s < end; s++)
  +    {
  +      char c = ch[s];
  +      if(!XMLCharacterRecognizer.isWhiteSpace(c))
  +        break;
  +    }
  +
  +    boolean whiteSpaceFound = false;
  +    int d = s;
  +    for (; s < end; s++)
  +    {
  +      char c = ch[s];
  +
  +      if (XMLCharacterRecognizer.isWhiteSpace(c))
  +      {
  +        if (!whiteSpaceFound)
  +        {
  +          whiteSpaceFound = true;
  +          if(c != ' ')
  +          {
  +            handler.characters(ch, d, (s-d));
  +            handler.characters(m_oneChar, 0, 1);
  +            d = s+1;
  +          }
  +        }
  +        else
  +        {
  +          int z;
  +          for (z = s+1; z < end; z++)
  +          {
  +            c = ch[z];
  +            if(!XMLCharacterRecognizer.isWhiteSpace(c))
  +              break;
  +          }
  +
  +          int len = (s-d);
  +
  +          if(z == end)
  +          {
  +            end = s;
  +            break; // Let the flush at the end handle it.
  +          }
  +          handler.characters(ch, d, len);
  +
  +          whiteSpaceFound = false;
  +          d = s = z;
  +        }
  +      }
  +      else
  +      {
  +        whiteSpaceFound = false;
  +      }
  +    }
  +
  +    if (whiteSpaceFound)
  +      s--;
  +    
  +    int len = (s-d);
  +    
  +    if(len > 0)
  +      handler.characters(ch, d, len);
  +  }
  +  
  +  /**
      * Sends the specified range of characters as sax Comment.
      * <p>
      * Note that, unlike sendSAXcharacters, this has to be done as a single 
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.14.2.2  +45 -0     xml-xalan/java/src/org/apache/xpath/Expression.java
  
  Index: Expression.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/Expression.java,v
  retrieving revision 1.14.2.1
  retrieving revision 1.14.2.2
  diff -u -r1.14.2.1 -r1.14.2.2
  --- Expression.java   2001/04/10 18:45:10     1.14.2.1
  +++ Expression.java   2001/05/29 14:31:31     1.14.2.2
  @@ -63,6 +63,7 @@
   import org.apache.xalan.res.XSLMessages;
   
   import org.xml.sax.XMLReader;
  +import org.xml.sax.ContentHandler;
   
   import javax.xml.transform.TransformerConfigurationException;
   import javax.xml.transform.TransformerException;
  @@ -128,6 +129,50 @@
      */
     public abstract XObject execute(XPathContext xctxt)
       throws javax.xml.transform.TransformerException;
  +    
  +  /**
  +   * Tell if the expression is a nodeset expression.  In other words, tell 
  +   * if you can execute [EMAIL PROTECTED] asNode() asNode} without an 
exception.
  +   * @return true if the expression can be represented as a nodeset.
  +   */
  +  public boolean isNodesetExpr()
  +  {
  +    return false;
  +  }
  +  
  +  /**
  +   * Return the first node out of the nodeset, if this expression is 
  +   * a nodeset expression.
  +   * @param xctxt The XPath runtime context.
  +   * @return the first node out of the nodeset, or DTM.NULL.
  +   */
  +  public int asNode(XPathContext xctxt)
  +    throws javax.xml.transform.TransformerException
  +  {
  +    return execute(xctxt).nodeset().nextNode();
  +  }
  +    
  +  /**
  +   * Execute an expression in the XPath runtime context, and return the 
  +   * result of the expression.
  +   *
  +   *
  +   * @param xctxt The XPath runtime context.
  +   *
  +   * @return The result of the expression in the form of a 
<code>XObject</code>.
  +   *
  +   * @throws javax.xml.transform.TransformerException if a runtime exception 
  +   *         occurs.
  +   */
  +  public void executeCharsToContentHandler(XPathContext xctxt, 
  +                                              ContentHandler handler)
  +    throws javax.xml.transform.TransformerException,
  +           org.xml.sax.SAXException
  +  {
  +    XObject obj = execute(xctxt);
  +    obj.dispatchCharactersEvents(handler);
  +  }
  +
   
     /**
      * Warn the user of an problem.
  
  
  
  1.18.2.5  +3 -3      xml-xalan/java/src/org/apache/xpath/XPath.java
  
  Index: XPath.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/XPath.java,v
  retrieving revision 1.18.2.4
  retrieving revision 1.18.2.5
  diff -u -r1.18.2.4 -r1.18.2.5
  --- XPath.java        2001/05/27 03:05:15     1.18.2.4
  +++ XPath.java        2001/05/29 14:31:32     1.18.2.5
  @@ -286,7 +286,7 @@
   
       PrefixResolver savedPrefixResolver = xctxt.getNamespaceContext();
   
  -    xctxt.m_currentPrefixResolver = namespaceContext;
  +    xctxt.setNamespaceContext(namespaceContext);
   
       xctxt.pushCurrentNodeAndExpression(contextNode, contextNode);
   
  @@ -313,7 +313,7 @@
         {
           e = ((org.apache.xml.utils.WrappedRuntimeException) 
e).getException();
         }
  -      e.printStackTrace();
  +      // e.printStackTrace();
   
         String msg = e.getMessage();
         msg = (msg == null || msg.length()== 0)? "Unknown error in XPath" : 
msg;
  @@ -330,7 +330,7 @@
       }
       finally
       {
  -      xctxt.m_currentPrefixResolver = savedPrefixResolver;
  +      xctxt.setNamespaceContext(savedPrefixResolver);
   
         xctxt.popCurrentNodeAndExpression();
       }
  
  
  
  1.20.2.12 +1 -1      xml-xalan/java/src/org/apache/xpath/XPathContext.java
  
  Index: XPathContext.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/XPathContext.java,v
  retrieving revision 1.20.2.11
  retrieving revision 1.20.2.12
  diff -u -r1.20.2.11 -r1.20.2.12
  --- XPathContext.java 2001/05/28 04:07:36     1.20.2.11
  +++ XPathContext.java 2001/05/29 14:31:33     1.20.2.12
  @@ -665,7 +665,7 @@
      * the source tree context).
      * (Is this really needed?)
      */
  -  PrefixResolver m_currentPrefixResolver = null;
  +  private PrefixResolver m_currentPrefixResolver = null;
   
     /** The stack of <a 
href="http://www.w3.org/TR/xslt#dt-current-node";>current node</a> objects.
      *  Not to be confused with the current node list.  */
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.6.2.4   +19 -1     
xml-xalan/java/src/org/apache/xpath/axes/ChildIterator.java
  
  Index: ChildIterator.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xpath/axes/ChildIterator.java,v
  retrieving revision 1.6.2.3
  retrieving revision 1.6.2.4
  diff -u -r1.6.2.3 -r1.6.2.4
  --- ChildIterator.java        2001/05/27 02:28:48     1.6.2.3
  +++ ChildIterator.java        2001/05/29 14:31:37     1.6.2.4
  @@ -60,7 +60,7 @@
   
   import org.apache.xpath.compiler.Compiler;
   import org.apache.xpath.patterns.NodeTest;
  -import org.apache.xpath.WhitespaceStrippingElementMatcher;
  +import org.apache.xpath.XPathContext;
   import org.apache.xml.utils.PrefixResolver;
   
   //import org.w3c.dom.Node;
  @@ -91,6 +91,24 @@
             throws javax.xml.transform.TransformerException
     {
       super(compiler, opPos, analysis, false);
  +  }
  +  
  +  /**
  +   * Return the first node out of the nodeset, if this expression is 
  +   * a nodeset expression.  This is the default implementation for 
  +   * nodesets.
  +   * <p>WARNING: Do not mutate this class from this function!</p>
  +   * @param xctxt The XPath runtime context.
  +   * @return the first node out of the nodeset, or DTM.NULL.
  +   */
  +  public int asNode(XPathContext xctxt)
  +    throws javax.xml.transform.TransformerException
  +  {
  +    int current = xctxt.getCurrentNode();
  +    
  +    DTM dtm = xctxt.getDTM(current);
  +    
  +    return dtm.getFirstChild(current);
     }
   
     /**
  
  
  
  1.8.2.9   +40 -0     
xml-xalan/java/src/org/apache/xpath/axes/DescendantIterator.java
  
  Index: DescendantIterator.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xpath/axes/DescendantIterator.java,v
  retrieving revision 1.8.2.8
  retrieving revision 1.8.2.9
  diff -u -r1.8.2.8 -r1.8.2.9
  --- DescendantIterator.java   2001/05/28 04:07:38     1.8.2.8
  +++ DescendantIterator.java   2001/05/29 14:31:37     1.8.2.9
  @@ -316,6 +316,46 @@
       
     }
     
  +  /**
  +   * Return the first node out of the nodeset, if this expression is 
  +   * a nodeset expression.  This is the default implementation for 
  +   * nodesets.
  +   * <p>WARNING: Do not mutate this class from this function!</p>
  +   * @param xctxt The XPath runtime context.
  +   * @return the first node out of the nodeset, or DTM.NULL.
  +   */
  +  public int asNode(XPathContext xctxt)
  +    throws javax.xml.transform.TransformerException
  +  {
  +    if(getPredicateCount() > 0)
  +      return super.asNode(xctxt);
  +
  +    int current = xctxt.getCurrentNode();
  +    
  +    DTM dtm = xctxt.getDTM(current);
  +    DTMAxisTraverser traverser = dtm.getAxisTraverser(m_axis);
  +    
  +    String localName = getLocalName();
  +    String namespace = getNamespace();
  +    int what = m_whatToShow;
  +    
  +    // System.out.println("what: ");
  +    // NodeTest.debugWhatToShow(what);
  +    if(DTMFilter.SHOW_ALL == what
  +       || localName == NodeTest.WILD
  +       || namespace == NodeTest.WILD)
  +    {
  +      return traverser.first(current);
  +    }
  +    else
  +    {
  +      int type = getNodeTypeTest(what);
  +      int extendedType = dtm.getExpandedTypeID(namespace, localName, type);
  +      return traverser.first(current, extendedType);
  +    }
  +  }
  +
  +  
     /** The traverser to use to navigate over the descendants. */
     transient protected DTMAxisTraverser m_traverser;
     
  
  
  
  1.24.2.9  +38 -0     
xml-xalan/java/src/org/apache/xpath/axes/LocPathIterator.java
  
  Index: LocPathIterator.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xpath/axes/LocPathIterator.java,v
  retrieving revision 1.24.2.8
  retrieving revision 1.24.2.9
  diff -u -r1.24.2.8 -r1.24.2.9
  --- LocPathIterator.java      2001/05/27 02:28:49     1.24.2.8
  +++ LocPathIterator.java      2001/05/29 14:31:38     1.24.2.9
  @@ -230,6 +230,44 @@
         throw new javax.xml.transform.TransformerException(ncse);
       }
     }
  +  
  +  /**
  +   * Tell if the expression is a nodeset expression.  In other words, tell 
  +   * if you can execute [EMAIL PROTECTED] asNode() asNode} without an 
exception.
  +   * @return true if the expression can be represented as a nodeset.
  +   */
  +  public boolean isNodesetExpr()
  +  {
  +    return true;
  +  }
  +  
  +  /**
  +   * Return the first node out of the nodeset, if this expression is 
  +   * a nodeset expression.  This is the default implementation for 
  +   * nodesets.  Derived classes should try and override this and return a 
  +   * value without having to do a clone operation.
  +   * @param xctxt The XPath runtime context.
  +   * @return the first node out of the nodeset, or DTM.NULL.
  +   */
  +  public int asNode(XPathContext xctxt)
  +    throws javax.xml.transform.TransformerException
  +  {
  +    try
  +    {
  +
  +      // LocPathIterator clone = (LocPathIterator) 
m_pool.getInstanceIfFree();
  +      // if (null == clone)
  +      LocPathIterator clone = (LocPathIterator) this.clone();
  +
  +      clone.initContext(xctxt);
  +
  +      return clone.nextNode();
  +    }
  +    catch (CloneNotSupportedException ncse)
  +    {
  +      throw new javax.xml.transform.TransformerException(ncse);
  +    }
  +  }
   
     /**
      * <meta name="usage" content="advanced"/>
  
  
  
  1.1.2.2   +39 -0     
xml-xalan/java/src/org/apache/xpath/axes/Attic/OneStepIteratorForward.java
  
  Index: OneStepIteratorForward.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xpath/axes/Attic/OneStepIteratorForward.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- OneStepIteratorForward.java       2001/05/27 02:28:49     1.1.2.1
  +++ OneStepIteratorForward.java       2001/05/29 14:31:40     1.1.2.2
  @@ -64,6 +64,45 @@
     }
     
     /**
  +   * Return the first node out of the nodeset, if this expression is 
  +   * a nodeset expression.  This is the default implementation for 
  +   * nodesets.
  +   * <p>WARNING: Do not mutate this class from this function!</p>
  +   * @param xctxt The XPath runtime context.
  +   * @return the first node out of the nodeset, or DTM.NULL.
  +   */
  +  public int asNode(XPathContext xctxt)
  +    throws javax.xml.transform.TransformerException
  +  {
  +    if(getPredicateCount() > 0)
  +      return super.asNode(xctxt);
  +      
  +    int current = xctxt.getCurrentNode();
  +    
  +    DTM dtm = xctxt.getDTM(current);
  +    DTMAxisTraverser traverser = dtm.getAxisTraverser(m_axis);
  +    
  +    String localName = getLocalName();
  +    String namespace = getNamespace();
  +    int what = m_whatToShow;
  +    
  +    // System.out.println("what: ");
  +    // NodeTest.debugWhatToShow(what);
  +    if(DTMFilter.SHOW_ALL == what
  +       || localName == NodeTest.WILD
  +       || namespace == NodeTest.WILD)
  +    {
  +      return traverser.first(current);
  +    }
  +    else
  +    {
  +      int type = getNodeTypeTest(what);
  +      int extendedType = dtm.getExpandedTypeID(namespace, localName, type);
  +      return traverser.first(current, extendedType);
  +    }
  +  }
  +  
  +  /**
      * Get the next node via getFirstAttribute && getNextAttribute.
      */
     protected int getNextNode()
  
  
  
  1.1.2.2   +16 -1     
xml-xalan/java/src/org/apache/xpath/axes/Attic/SelfIteratorNoPredicate.java
  
  Index: SelfIteratorNoPredicate.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xpath/axes/Attic/SelfIteratorNoPredicate.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- SelfIteratorNoPredicate.java      2001/05/27 02:28:50     1.1.2.1
  +++ SelfIteratorNoPredicate.java      2001/05/29 14:31:41     1.1.2.2
  @@ -4,7 +4,7 @@
   
   import org.apache.xpath.compiler.Compiler;
   import org.apache.xpath.patterns.NodeTest;
  -import org.apache.xpath.WhitespaceStrippingElementMatcher;
  +import org.apache.xpath.XPathContext;
   import org.apache.xml.utils.PrefixResolver;
   
   //import org.w3c.dom.Node;
  @@ -89,4 +89,19 @@
         return DTM.NULL;
       }
     }
  +  
  +  /**
  +   * Return the first node out of the nodeset, if this expression is 
  +   * a nodeset expression.  This is the default implementation for 
  +   * nodesets.  Derived classes should try and override this and return a 
  +   * value without having to do a clone operation.
  +   * @param xctxt The XPath runtime context.
  +   * @return the first node out of the nodeset, or DTM.NULL.
  +   */
  +  public int asNode(XPathContext xctxt)
  +    throws javax.xml.transform.TransformerException
  +  {
  +    return xctxt.getCurrentNode();
  +  }
  +
   }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.6.2.3   +33 -1     
xml-xalan/java/src/org/apache/xpath/functions/FuncNormalizeSpace.java
  
  Index: FuncNormalizeSpace.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xpath/functions/FuncNormalizeSpace.java,v
  retrieving revision 1.6.2.2
  retrieving revision 1.6.2.3
  diff -u -r1.6.2.2 -r1.6.2.3
  --- FuncNormalizeSpace.java   2001/05/18 07:17:07     1.6.2.2
  +++ FuncNormalizeSpace.java   2001/05/29 14:31:46     1.6.2.3
  @@ -73,6 +73,9 @@
   import org.apache.xml.utils.XMLStringFactory;
   import org.apache.xml.utils.FastStringBuffer;
   
  +import org.apache.xml.dtm.DTM;
  +import org.xml.sax.ContentHandler;
  +
   /**
    * <meta name="usage" content="advanced"/>
    * Execute the normalize-space() function.
  @@ -90,10 +93,39 @@
      */
     public XObject execute(XPathContext xctxt) throws 
javax.xml.transform.TransformerException
     {
  -
       XMLString s1 = getArg0AsString(xctxt);
   
       return (XString)s1.fixWhiteSpace(true, true, false);
  +  }
  +  
  +  /**
  +   * Execute an expression in the XPath runtime context, and return the 
  +   * result of the expression.
  +   *
  +   *
  +   * @param xctxt The XPath runtime context.
  +   *
  +   * @return The result of the expression in the form of a 
<code>XObject</code>.
  +   *
  +   * @throws javax.xml.transform.TransformerException if a runtime exception 
  +   *         occurs.
  +   */
  +  public void executeCharsToContentHandler(XPathContext xctxt, 
  +                                              ContentHandler handler)
  +    throws javax.xml.transform.TransformerException,
  +           org.xml.sax.SAXException
  +  {
  +    if(Arg0IsNodesetExpr())
  +    {
  +      int node = getArg0AsNode(xctxt);
  +      DTM dtm = xctxt.getDTM(node);
  +      dtm.dispatchCharactersEvents(node, handler, true);
  +    }
  +    else
  +    {
  +      XObject obj = execute(xctxt);
  +      obj.dispatchCharactersEvents(handler);
  +    }
     }
   
   }
  
  
  
  1.5.2.5   +10 -2     
xml-xalan/java/src/org/apache/xpath/functions/FunctionDef1Arg.java
  
  Index: FunctionDef1Arg.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xpath/functions/FunctionDef1Arg.java,v
  retrieving revision 1.5.2.4
  retrieving revision 1.5.2.5
  diff -u -r1.5.2.4 -r1.5.2.5
  --- FunctionDef1Arg.java      2001/05/19 07:05:54     1.5.2.4
  +++ FunctionDef1Arg.java      2001/05/29 14:31:47     1.5.2.5
  @@ -92,8 +92,16 @@
     {
   
       return (null == m_arg0)
  -           ? xctxt.getCurrentNode()
  -           : m_arg0.execute(xctxt).nodeset().nextNode();
  +           ? xctxt.getCurrentNode() : m_arg0.asNode(xctxt);
  +  }
  +  
  +  /**
  +   * Tell if the expression is a nodeset expression.
  +   * @return true if the expression can be represented as a nodeset.
  +   */
  +  public boolean Arg0IsNodesetExpr()
  +  {
  +    return (null == m_arg0) ? true : m_arg0.isNodesetExpr();
     }
   
     /**
  
  
  
  1.5.2.1   +1 -1      
xml-xalan/java/src/org/apache/xpath/functions/FunctionOneArg.java
  
  Index: FunctionOneArg.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xpath/functions/FunctionOneArg.java,v
  retrieving revision 1.5
  retrieving revision 1.5.2.1
  diff -u -r1.5 -r1.5.2.1
  --- FunctionOneArg.java       2001/01/02 03:47:16     1.5
  +++ FunctionOneArg.java       2001/05/29 14:31:48     1.5.2.1
  @@ -79,7 +79,7 @@
     {
       return m_arg0;
     }
  -
  +  
     /**
      * Set an argument expression for a function.  This method is called by 
the 
      * XPath compiler.
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.8.2.8   +17 -0     xml-xalan/java/src/org/apache/xpath/objects/XObject.java
  
  Index: XObject.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/objects/XObject.java,v
  retrieving revision 1.8.2.7
  retrieving revision 1.8.2.8
  diff -u -r1.8.2.7 -r1.8.2.8
  --- XObject.java      2001/05/27 03:53:52     1.8.2.7
  +++ XObject.java      2001/05/29 14:31:54     1.8.2.8
  @@ -117,6 +117,23 @@
     {
       return this;
     }
  +  
  +  /**
  +   * Directly call the
  +   * characters method on the passed ContentHandler for the
  +   * string-value. Multiple calls to the
  +   * ContentHandler's characters methods may well occur for a single call to
  +   * this method.
  +   *
  +   * @param ch A non-null reference to a ContentHandler.
  +   *
  +   * @throws org.xml.sax.SAXException
  +   */
  +  public void dispatchCharactersEvents(org.xml.sax.ContentHandler ch)
  +          throws org.xml.sax.SAXException
  +  {
  +    xstr().dispatchCharactersEvents(ch);
  +  }
   
     /**
      * Create the right XObject based on the type of the object passed.
  
  
  

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

Reply via email to