You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by sb...@locus.apache.org on 2000/03/15 23:02:37 UTC

cvs commit: xml-xalan/src/org/apache/xalan/xslt XSLTEngineImpl.java XSLTProcessor.java

sboag       00/03/15 14:02:37

  Modified:    src/org/apache/xalan/xslt Tag: Bxalan_1_0_0
                        XSLTEngineImpl.java XSLTProcessor.java
  Log:
  Fix support for LexicalHandler interface when being configured with SAX.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.55.2.2  +114 -11   xml-xalan/src/org/apache/xalan/xslt/XSLTEngineImpl.java
  
  Index: XSLTEngineImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xslt/XSLTEngineImpl.java,v
  retrieving revision 1.55.2.1
  retrieving revision 1.55.2.2
  diff -u -r1.55.2.1 -r1.55.2.2
  --- XSLTEngineImpl.java	2000/03/14 21:57:16	1.55.2.1
  +++ XSLTEngineImpl.java	2000/03/15 22:02:36	1.55.2.2
  @@ -3361,6 +3361,36 @@
     {
       m_sourceTreeHandler.endElement(name);
     }
  +  
  +  private boolean m_isCData = false;
  +  
  +  /**
  +   * Report the start of a CDATA section.
  +   *
  +   * <p>The contents of the CDATA section will be reported through
  +   * the regular {@link org.xml.sax.ContentHandler#characters
  +   * characters} event.</p>
  +   *
  +   * @exception SAXException The application may raise an exception.
  +   * @see #endCDATA
  +   */
  +  public void startCDATA ()
  +    throws SAXException
  +  {
  +    m_isCData = true;
  +  }
  +  
  +  /**
  +   * Report the end of a CDATA section.
  +   *
  +   * @exception SAXException The application may raise an exception.
  +   * @see #startCDATA
  +   */
  +  public void endCDATA ()
  +    throws SAXException
  +  {
  +    m_isCData = false;
  +  }
   
     /**
      * Implement the characters event.
  @@ -3368,7 +3398,14 @@
     public void characters (char ch[], int start, int length)
       throws SAXException
     {
  -    m_sourceTreeHandler.characters(ch, start, length);
  +    if(m_isCData)
  +    {
  +      m_sourceTreeHandler.cdata(ch, start, length);
  +    }
  +    else
  +    {
  +      m_sourceTreeHandler.characters(ch, start, length);
  +    }
     }
   
     /**
  @@ -3399,30 +3436,96 @@
     }
   
     /**
  -   * Implement the comment event.
  +   * Report an XML comment anywhere in the document.
  +   *
  +   * <p>This callback will be used for comments inside or outside the
  +   * document element, including comments in the external DTD
  +   * subset (if read).</p>
  +   *
  +   * @param ch An array holding the characters in the comment.
  +   * @param start The starting position in the array.
  +   * @param length The number of characters to use from the array.
  +   * @exception SAXException The application may raise an exception.
      */
  -  public void comment(String data) throws SAXException
  +  public void comment (char ch[], int start, int length)
  +    throws SAXException
     {
  -    m_sourceTreeHandler.comment(data.toCharArray(), 0, data.length());
  +    m_sourceTreeHandler.comment(ch, start, length);
     }
  -
  +      
     /**
  -   * Implement the entityReference event.
  +   * Report the beginning of an entity.
  +   *
  +   * <p>The start and end of the document entity are not reported.
  +   * The start and end of the external DTD subset are reported
  +   * using the pseudo-name "[dtd]".  All other events must be
  +   * properly nested within start/end entity events.</p>
  +   *
  +   * <p>Note that skipped entities will be reported through the
  +   * {@link org.xml.sax.ContentHandler#skippedEntity skippedEntity}
  +   * event, which is part of the ContentHandler interface.</p>
  +   *
  +   * @param name The name of the entity.  If it is a parameter
  +   *        entity, the name will begin with '%'.
  +   * @exception SAXException The application may raise an exception.
  +   * @see #endEntity
  +   * @see org.xml.sax.ext.DeclHandler#internalEntityDecl
  +   * @see org.xml.sax.ext.DeclHandler#externalEntityDecl
      */
  -  public void entityReference(String name) throws SAXException
  +  public void startEntity (String name)
  +    throws SAXException
     {
  -    m_sourceTreeHandler.entityReference(name);
  +    m_sourceTreeHandler.startEntity(name);
     }
   
     /**
  -   * Implement the cdata event.
  +   * Report the end of an entity.
  +   *
  +   * @param name The name of the entity that is ending.
  +   * @exception SAXException The application may raise an exception.
  +   * @see #startEntity
      */
  -  public void cdata (char ch[], int start, int length)
  +  public void endEntity (String name)
       throws SAXException
     {
  -    m_sourceTreeHandler.cdata(ch, start, length);
  +    m_sourceTreeHandler.endEntity(name);
     }
  +  
  +  /**
  +   * Report the start of DTD declarations, if any.
  +   *
  +   * <p>Any declarations are assumed to be in the internal subset
  +   * unless otherwise indicated by a {@link #startEntity startEntity}
  +   * event.</p>
  +   *
  +   * @param name The document type name.
  +   * @param publicId The declared public identifier for the
  +   *        external DTD subset, or null if none was declared.
  +   * @param systemId The declared system identifier for the
  +   *        external DTD subset, or null if none was declared.
  +   * @exception SAXException The application may raise an
  +   *            exception.
  +   * @see #endDTD
  +   * @see #startEntity
  +   */
  +  public void startDTD (String name, String publicId,
  +                                 String systemId)
  +    throws SAXException
  +  {
  +  }
  +
   
  +  /**
  +   * Report the end of DTD declarations.
  +   *
  +   * @exception SAXException The application may raise an exception.
  +   * @see #startDTD
  +   */
  +  public void endDTD ()
  +    throws SAXException
  +  {
  +  }
  +    
     /**
      * An exception for that occurs when a given stylesheet
      * goes into an infinite loop.
  
  
  
  1.12.2.1  +2 -1      xml-xalan/src/org/apache/xalan/xslt/XSLTProcessor.java
  
  Index: XSLTProcessor.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xslt/XSLTProcessor.java,v
  retrieving revision 1.12
  retrieving revision 1.12.2.1
  diff -u -r1.12 -r1.12.2.1
  --- XSLTProcessor.java	2000/03/02 10:23:09	1.12
  +++ XSLTProcessor.java	2000/03/15 22:02:36	1.12.2.1
  @@ -71,6 +71,7 @@
   import org.w3c.dom.NodeList;
   import org.w3c.dom.Node;
   import org.xml.sax.DocumentHandler;
  +import org.xml.sax.ext.LexicalHandler;
   import org.xml.sax.SAXException;
   import java.io.OutputStream;
   import java.io.UnsupportedEncodingException;
  @@ -92,7 +93,7 @@
    *
    * <p>If you reuse the processor instance, you should call reset() between transformations.</p>
    */
  -public interface XSLTProcessor extends DocumentHandler
  +public interface XSLTProcessor extends DocumentHandler, LexicalHandler
   {
     /**
      * Use the XSL stylesheet to transform the XML input, placing the result in the result tree.