sboag       00/11/16 00:14:13

  Modified:    java/src/org/apache/xalan/client XSLTProcessorApplet.java
               java/src/org/apache/xalan/serialize FormatterToHTML.java
               java/src/org/apache/xalan/stree DocumentImpl.java
                        DocumentTypeImpl.java SourceTreeHandler.java
               java/src/org/apache/xalan/transformer TransformerImpl.java
  Added:       java/src/org/apache/xalan/stree EntityImpl.java
  Log:
  Implement entity handling.
  
  Revision  Changes    Path
  1.9       +17 -1     
xml-xalan/java/src/org/apache/xalan/client/XSLTProcessorApplet.java
  
  Index: XSLTProcessorApplet.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/client/XSLTProcessorApplet.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- XSLTProcessorApplet.java  2000/11/13 16:26:35     1.8
  +++ XSLTProcessorApplet.java  2000/11/16 08:14:09     1.9
  @@ -380,10 +380,26 @@
         ContentHandler inputHandler = new SourceTreeHandler(transformer);
   
         m_reader.setContentHandler(inputHandler);
  -      try
  +      if(m_reader instanceof org.xml.sax.DTDHandler)
  +        m_reader.setDTDHandler((org.xml.sax.DTDHandler)inputHandler);
  +     try
         {
           m_reader.setProperty("http://xml.org/sax/properties/lexical-handler";,
                                inputHandler);
  +        if(inputHandler instanceof org.xml.sax.ext.DeclHandler)
  +          
m_reader.setProperty("http://xml.org/sax/properties/declaration-handler";,
  +                               inputHandler);
  +      }
  +      catch(org.xml.sax.SAXNotRecognizedException snre)
  +      {
  +      }
  +      try
  +      {
  +        m_reader.setProperty("http://xml.org/sax/handlers/LexicalHandler";,
  +                             inputHandler);
  +        if(inputHandler instanceof org.xml.sax.ext.DeclHandler)
  +          m_reader.setProperty("http://xml.org/sax/handlers/DeclHandler";,
  +                               inputHandler);
         }
         catch(org.xml.sax.SAXNotRecognizedException snre)
         {
  
  
  
  1.5       +19 -8     
xml-xalan/java/src/org/apache/xalan/serialize/FormatterToHTML.java
  
  Index: FormatterToHTML.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/serialize/FormatterToHTML.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- FormatterToHTML.java      2000/11/15 14:17:53     1.4
  +++ FormatterToHTML.java      2000/11/16 08:14:09     1.5
  @@ -73,7 +73,9 @@
   import org.apache.xalan.serialize.OutputFormat;
   import org.apache.xalan.serialize.Method;
   import org.apache.xalan.serialize.helpers.HTMLOutputFormat;
  +import org.apache.xalan.utils.StringToIntTable;
   
  +
   /**
    * <meta name="usage" content="general"/>
    * FormatterToHTML formats SAX-style events into XML.
  @@ -81,7 +83,6 @@
    */
   public class FormatterToHTML extends FormatterToXML
   {
  -
     // StringVector m_parents = new StringVector();
   
     /** NEEDSDOC Field m_isRawStack          */
  @@ -427,7 +428,7 @@
     static private ElemDesc m_dummy = new ElemDesc(0 | ElemDesc.BLOCK);
   
     /** NEEDSDOC Field m_specialEscapeURLs          */
  -  private boolean m_specialEscapeURLs = false;
  +  private boolean m_specialEscapeURLs = true;
   
     /**
      * Tells if the formatter should use special URL escaping.
  @@ -1004,12 +1005,15 @@
   
             // The next is kind of a hack to keep from escaping in the case 
             // of Shift_JIS and the like.
  +          /*
             else if ((ch < m_maxCharacter) && (m_maxCharacter == 0xFFFF)
  -                   && (ch != 160) /* nbsp */)
  +          && (ch != 160))
             {
  -            accum(ch);  // no escaping in this case
  +          accum(ch);  // no escaping in this case
             }
  -          else if ((ch >= 160) && (ch <= 255))
  +          else 
  +          */
  +          if ((ch >= 160) && (ch <= 255))
             {
               accum('&');
               accum(s_HTMLlat1[((int) ch) - 160]);
  @@ -1053,9 +1057,16 @@
             }
             else
             {
  -            accum("&#");
  -            accum(Integer.toString(ch));
  -            accum(';');
  +            if (ch < m_maxCharacter)
  +            {
  +              accum(ch);  // no escaping in this case
  +            }
  +            else
  +            {
  +              accum("&#");
  +              accum(Integer.toString(ch));
  +              accum(';');
  +            }
             }
           }
         }
  
  
  
  1.11      +6 -0      
xml-xalan/java/src/org/apache/xalan/stree/DocumentImpl.java
  
  Index: DocumentImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/stree/DocumentImpl.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- DocumentImpl.java 2000/11/06 17:48:50     1.10
  +++ DocumentImpl.java 2000/11/16 08:14:09     1.11
  @@ -215,6 +215,12 @@
     {
       return m_docType;
     }
  +  
  +  public void setDoctype(DocumentType docType)
  +  {
  +    m_docType = (DocumentTypeImpl)docType;
  +  }
  +
   
     /** If this is true, the transformation is working off of 
      * a secondary thread from the incoming SAX events, and 
  
  
  
  1.7       +178 -2    
xml-xalan/java/src/org/apache/xalan/stree/DocumentTypeImpl.java
  
  Index: DocumentTypeImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/stree/DocumentTypeImpl.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DocumentTypeImpl.java     2000/11/07 22:22:33     1.6
  +++ DocumentTypeImpl.java     2000/11/16 08:14:09     1.7
  @@ -56,15 +56,18 @@
    */
   package org.apache.xalan.stree;
   
  +import java.util.Hashtable;
  +
   import org.w3c.dom.Node;
   import org.w3c.dom.DocumentType;
   import org.w3c.dom.NamedNodeMap;
  +import org.w3c.dom.DOMException;
   
   /**
    * <meta name="usage" content="internal"/>
    * Class to hold information about a DocumentType node 
    */
  -public class DocumentTypeImpl extends Child implements DocumentType
  +public class DocumentTypeImpl extends Child implements DocumentType, 
NamedNodeMap
   {
   
     /**
  @@ -81,6 +84,23 @@
   
       m_name = name;
     }
  +  
  +  /**
  +   * Constructor DocumentTypeImpl
  +   *
  +   *
  +   * @param doc Document Object
  +   * @param name Node name
  +   */
  +  DocumentTypeImpl(DocumentImpl doc, String name, String publicId, String 
systemId)
  +  {
  +
  +    super(doc);
  +
  +    m_name = name;
  +    m_systemID = systemId;
  +    m_publicID = publicId;
  +  }
   
     /** DocumentType node name          */
     private String m_name;
  @@ -164,7 +184,7 @@
      */
     public NamedNodeMap getEntities()
     {
  -    return null;
  +    return this;
     }
   
     /**
  @@ -213,4 +233,160 @@
     {
       return m_internalSubset;
     }
  +  
  +  Hashtable m_entities = new Hashtable();
  +  
  +  /**
  +   * Retrieves a node specified by name.
  +   * @param nameThe <code>nodeName</code> of a node to retrieve.
  +   * @return A <code>Node</code> (of any type) with the specified 
  +   *   <code>nodeName</code>, or <code>null</code> if it does not identify 
  +   *   any node in this map.
  +   */
  +  public Node getNamedItem(String name)
  +  {
  +    return (Node)m_entities.get(name);
  +  }
  +
  +  /**
  +   * Adds a node using its <code>nodeName</code> attribute. If a node with 
  +   * that name is already present in this map, it is replaced by the new 
  +   * one.
  +   * <br>As the <code>nodeName</code> attribute is used to derive the name 
  +   * which the node must be stored under, multiple nodes of certain types 
  +   * (those that have a "special" string value) cannot be stored as the 
  +   * names would clash. This is seen as preferable to allowing nodes to be 
  +   * aliased.
  +   * @param argA node to store in this map. The node will later be 
  +   *   accessible using the value of its <code>nodeName</code> attribute.
  +   * @return If the new <code>Node</code> replaces an existing node the 
  +   *   replaced <code>Node</code> is returned, otherwise <code>null</code> 
  +   *   is returned.
  +   * @exception DOMException
  +   *   WRONG_DOCUMENT_ERR: Raised if <code>arg</code> was created from a 
  +   *   different document than the one that created this map.
  +   *   <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.
  +   *   <br>INUSE_ATTRIBUTE_ERR: Raised if <code>arg</code> is an 
  +   *   <code>Attr</code> that is already an attribute of another 
  +   *   <code>Element</code> object. The DOM user must explicitly clone 
  +   *   <code>Attr</code> nodes to re-use them in other elements.
  +   */
  +  public Node setNamedItem(Node arg)
  +    throws DOMException
  +  {
  +    m_entities.put(arg.getNodeName(), arg);
  +    return null;
  +  }
  +
  +  /**
  +   * Removes a node specified by name. When this map contains the attributes 
  +   * attached to an element, if the removed attribute is known to have a 
  +   * default value, an attribute immediately appears containing the 
  +   * default value as well as the corresponding namespace URI, local name, 
  +   * and prefix when applicable.
  +   * @param nameThe <code>nodeName</code> of the node to remove.
  +   * @return The node removed from this map if a node with such a name 
  +   *   exists.
  +   * @exception DOMException
  +   *   NOT_FOUND_ERR: Raised if there is no node named <code>name</code> in 
  +   *   this map.
  +   *   <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.
  +   */
  +  public Node removeNamedItem(String name)
  +    throws DOMException
  +  {
  +    return null;
  +  }
  +
  +  /**
  +   * Returns the <code>index</code>th item in the map. If <code>index</code> 
  +   * is greater than or equal to the number of nodes in this map, this 
  +   * returns <code>null</code>.
  +   * @param indexIndex into this map.
  +   * @return The node at the <code>index</code>th position in the map, or 
  +   *   <code>null</code> if that is not a valid index.
  +   */
  +  public Node item(int index)
  +  {
  +    return null;
  +  }
  +
  +  /**
  +   * The number of nodes in this map. The range of valid child node indices 
  +   * is <code>0</code> to <code>length-1</code> inclusive. 
  +   */
  +  public int getLength()
  +  {
  +    return 0;
  +  }
  +
  +  /**
  +   * Retrieves a node specified by local name and namespace URI. HTML-only 
  +   * DOM implementations do not need to implement this method.
  +   * @param namespaceURIThe namespace URI of the node to retrieve.
  +   * @param localNameThe local name of the node to retrieve.
  +   * @return A <code>Node</code> (of any type) with the specified local 
  +   *   name and namespace URI, or <code>null</code> if they do not 
  +   *   identify any node in this map.
  +   * @since DOM Level 2
  +   */
  +  public Node getNamedItemNS(String namespaceURI, 
  +                             String localName)
  +  {
  +    return null;
  +  }
  +
  +  /**
  +   * Adds a node using its <code>namespaceURI</code> and 
  +   * <code>localName</code>. If a node with that namespace URI and that 
  +   * local name is already present in this map, it is replaced by the new 
  +   * one.
  +   * <br>HTML-only DOM implementations do not need to implement this method.
  +   * @param argA node to store in this map. The node will later be 
  +   *   accessible using the value of its <code>namespaceURI</code> and 
  +   *   <code>localName</code> attributes.
  +   * @return If the new <code>Node</code> replaces an existing node the 
  +   *   replaced <code>Node</code> is returned, otherwise <code>null</code> 
  +   *   is returned.
  +   * @exception DOMException
  +   *   WRONG_DOCUMENT_ERR: Raised if <code>arg</code> was created from a 
  +   *   different document than the one that created this map.
  +   *   <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.
  +   *   <br>INUSE_ATTRIBUTE_ERR: Raised if <code>arg</code> is an 
  +   *   <code>Attr</code> that is already an attribute of another 
  +   *   <code>Element</code> object. The DOM user must explicitly clone 
  +   *   <code>Attr</code> nodes to re-use them in other elements.
  +   * @since DOM Level 2
  +   */
  +  public Node setNamedItemNS(Node arg)
  +    throws DOMException
  +  {
  +    return null;
  +  }
  +
  +  /**
  +   * Removes a node specified by local name and namespace URI. A removed 
  +   * attribute may be known to have a default value when this map contains 
  +   * the attributes attached to an element, as returned by the attributes 
  +   * attribute of the <code>Node</code> interface. If so, an attribute 
  +   * immediately appears containing the default value as well as the 
  +   * corresponding namespace URI, local name, and prefix when applicable.
  +   * <br>HTML-only DOM implementations do not need to implement this method.
  +   * @param namespaceURIThe namespace URI of the node to remove.
  +   * @param localNameThe local name of the node to remove.
  +   * @return The node removed from this map if a node with such a local 
  +   *   name and namespace URI exists.
  +   * @exception DOMException
  +   *   NOT_FOUND_ERR: Raised if there is no node with the specified 
  +   *   <code>namespaceURI</code> and <code>localName</code> in this map.
  +   *   <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.
  +   * @since DOM Level 2
  +   */
  +  public Node removeNamedItemNS(String namespaceURI, 
  +                                String localName)
  +    throws DOMException
  +  {
  +    return null;
  +  }
  +
   }
  
  
  
  1.20      +165 -5    
xml-xalan/java/src/org/apache/xalan/stree/SourceTreeHandler.java
  
  Index: SourceTreeHandler.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/stree/SourceTreeHandler.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- SourceTreeHandler.java    2000/11/15 22:25:11     1.19
  +++ SourceTreeHandler.java    2000/11/16 08:14:11     1.20
  @@ -75,10 +75,12 @@
   
   import org.xml.sax.Attributes;
   import org.xml.sax.ext.LexicalHandler;
  +import org.xml.sax.ext.DeclHandler;
   import org.xml.sax.Locator;
   import javax.xml.transform.TransformerException;
   import org.xml.sax.ContentHandler;
   import org.xml.sax.InputSource;
  +import org.xml.sax.DTDHandler;
   
   import javax.xml.transform.Transformer;
   import javax.xml.transform.TransformerException;
  @@ -93,7 +95,7 @@
    * This class handles SAX2 parse events to create a source
    * tree for transformation.
    */
  -public class SourceTreeHandler implements TransformerHandler
  +public class SourceTreeHandler extends org.xml.sax.helpers.DefaultHandler 
implements TransformerHandler, DeclHandler, DTDHandler
   {
     static int m_idCount = 0;
     int m_id;
  @@ -616,7 +618,6 @@
      */
     public void startEntity(String name) throws org.xml.sax.SAXException
     {
  -
       synchronized (m_root)
       {
         m_sourceTreeHandler.startEntity(name);
  @@ -661,7 +662,12 @@
      * @see #startEntity
      */
     public void startDTD(String name, String publicId, String systemId)
  -          throws org.xml.sax.SAXException{}
  +          throws org.xml.sax.SAXException
  +  {
  +    DocumentImpl doc = ((DocumentImpl)m_root);
  +    DocumentTypeImpl dtd = new DocumentTypeImpl(doc, name, publicId, 
systemId);
  +    ((DocumentImpl)m_root).setDoctype(dtd);
  +  }
   
     /**
      * Report the end of DTD declarations.
  @@ -669,7 +675,9 @@
      * @exception TransformerException The application may raise an exception.
      * @see #startDTD
      */
  -  public void endDTD() throws org.xml.sax.SAXException{}
  +  public void endDTD() throws org.xml.sax.SAXException
  +  {
  +  }
   
     /**
      * Begin the scope of a prefix-URI Namespace mapping.
  @@ -755,7 +763,9 @@
      *
      * @throws TransformerException
      */
  -  public void skippedEntity(String name) throws org.xml.sax.SAXException{}
  +  public void skippedEntity(String name) throws org.xml.sax.SAXException
  +  {
  +  }
   
     /** Flag indicating whether to strip whitespace nodes          */
     private boolean m_shouldStripWS = false;
  @@ -880,6 +890,156 @@
     {
       return m_transformer;
     }
  +  
  +  /**
  +   * Report an element type declaration.
  +   *
  +   * <p>The content model will consist of the string "EMPTY", the
  +   * string "ANY", or a parenthesised group, optionally followed
  +   * by an occurrence indicator.  The model will be normalized so
  +   * that all whitespace is removed,and will include the enclosing
  +   * parentheses.</p>
  +   *
  +   * @param name The element type name.
  +   * @param model The content model as a normalized string.
  +   * @exception SAXException The application may raise an exception.
  +   */
  +  public void elementDecl (String name, String model)
  +    throws org.xml.sax.SAXException
  +  {
  +  }
  +
   
  +  /**
  +   * Report an attribute type declaration.
  +   *
  +   * <p>Only the effective (first) declaration for an attribute will
  +   * be reported.  The type will be one of the strings "CDATA",
  +   * "ID", "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY",
  +   * "ENTITIES", or "NOTATION", or a parenthesized token group with 
  +   * the separator "|" and all whitespace removed.</p>
  +   *
  +   * @param eName The name of the associated element.
  +   * @param aName The name of the attribute.
  +   * @param type A string representing the attribute type.
  +   * @param valueDefault A string representing the attribute default
  +   *        ("#IMPLIED", "#REQUIRED", or "#FIXED") or null if
  +   *        none of these applies.
  +   * @param value A string representing the attribute's default value,
  +   *        or null if there is none.
  +   * @exception SAXException The application may raise an exception.
  +   */
  +  public void attributeDecl (String eName,
  +                             String aName,
  +                             String type,
  +                             String valueDefault,
  +                             String value)
  +    throws org.xml.sax.SAXException
  +  {
  +  }
  +
  +
  +  /**
  +   * Report an internal entity declaration.
  +   *
  +   * <p>Only the effective (first) declaration for each entity
  +   * will be reported.</p>
  +   *
  +   * @param name The name of the entity.  If it is a parameter
  +   *        entity, the name will begin with '%'.
  +   * @param value The replacement text of the entity.
  +   * @exception SAXException The application may raise an exception.
  +   * @see #externalEntityDecl
  +   * @see org.xml.sax.DTDHandler#unparsedEntityDecl
  +   */
  +  public void internalEntityDecl (String name, String value)
  +    throws org.xml.sax.SAXException
  +  {
  +  }
  +
  +
  +  /**
  +   * Report a parsed external entity declaration.
  +   *
  +   * <p>Only the effective (first) declaration for each entity
  +   * will be reported.</p>
  +   *
  +   * @param name The name of the entity.  If it is a parameter
  +   *        entity, the name will begin with '%'.
  +   * @param publicId The declared public identifier of the entity, or
  +   *        null if none was declared.
  +   * @param systemId The declared system identifier of the entity.
  +   * @exception SAXException The application may raise an exception.
  +   * @see #internalEntityDecl
  +   * @see org.xml.sax.DTDHandler#unparsedEntityDecl
  +   */
  +  public void externalEntityDecl (String name, String publicId,
  +                                  String systemId)
  +    throws org.xml.sax.SAXException
  +  {
  +  }
  +
  +  /**
  +   * Receive notification of a notation declaration event.
  +   *
  +   * <p>It is up to the application to record the notation for later
  +   * reference, if necessary.</p>
  +   *
  +   * <p>At least one of publicId and systemId must be non-null.
  +   * If a system identifier is present, and it is a URL, the SAX
  +   * parser must resolve it fully before passing it to the
  +   * application through this event.</p>
  +   *
  +   * <p>There is no guarantee that the notation declaration will be
  +   * reported before any unparsed entities that use it.</p>
  +   *
  +   * @param name The notation name.
  +   * @param publicId The notation's public identifier, or null if
  +   *        none was given.
  +   * @param systemId The notation's system identifier, or null if
  +   *        none was given.
  +   * @exception org.xml.sax.SAXException Any SAX exception, possibly
  +   *            wrapping another exception.
  +   * @see #unparsedEntityDecl
  +   * @see org.xml.sax.AttributeList
  +   */
  +  public void notationDecl (String name,
  +                            String publicId,
  +                            String systemId)
  +    throws org.xml.sax.SAXException
  +  {
  +  }
  +  
  +  
  +  /**
  +   * Receive notification of an unparsed entity declaration event.
  +   *
  +   * <p>Note that the notation name corresponds to a notation
  +   * reported by the [EMAIL PROTECTED] #notationDecl notationDecl} event.  
  +   * It is up to the application to record the entity for later 
  +   * reference, if necessary.</p>
  +   *
  +   * <p>If the system identifier is a URL, the parser must resolve it
  +   * fully before passing it to the application.</p>
  +   *
  +   * @exception org.xml.sax.SAXException Any SAX exception, possibly
  +   *            wrapping another exception.
  +   * @param name The unparsed entity's name.
  +   * @param publicId The entity's public identifier, or null if none
  +   *        was given.
  +   * @param systemId The entity's system identifier.
  +   * @param notation name The name of the associated notation.
  +   * @see #notationDecl
  +   * @see org.xml.sax.AttributeList
  +   */
  +  public void unparsedEntityDecl (String name,
  +                                  String publicId,
  +                                  String systemId,
  +                                  String notationName)
  +    throws org.xml.sax.SAXException
  +  {
  +    EntityImpl entity = new EntityImpl(name, notationName, publicId, 
systemId);
  +    m_root.getDoctype().getEntities().setNamedItem(entity);
  +  }
   
   }
  
  
  
  1.1                  xml-xalan/java/src/org/apache/xalan/stree/EntityImpl.java
  
  Index: EntityImpl.java
  ===================================================================
  package org.apache.xalan.stree;
  
  import org.w3c.dom.Node;
  import org.w3c.dom.DOMException;
  import org.w3c.dom.Entity;
  
  
  public class EntityImpl extends org.apache.xalan.utils.UnImplNode implements 
Entity
  {
    String m_publicId;
    String m_systemId;
    String m_notationName;
    String m_name;
    
    EntityImpl(String name, String notationName, String publicId, String 
systemId)
    {
      m_publicId = publicId;
      m_systemId = systemId;
      m_notationName = notationName;
      m_name = name;
    }
    
    public String getNodeName()
    {
      return m_name;
    }
  
    
    /**
     * The public identifier associated with the entity, if specified. If the 
     * public identifier was not specified, this is <code>null</code>.
     */
    public String getPublicId()
    {
      return m_publicId;
    }
  
    /**
     * The system identifier associated with the entity, if specified. If the 
     * system identifier was not specified, this is <code>null</code>.
     */
    public String getSystemId()
    {
      return m_systemId;
    }
  
    /**
     * For unparsed entities, the name of the notation for the entity. For 
     * parsed entities, this is <code>null</code>. 
     */
    public String getNotationName()
    {
      return m_notationName;
    }
  
  }
  
  
  
  1.52      +40 -4     
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.51
  retrieving revision 1.52
  diff -u -r1.51 -r1.52
  --- TransformerImpl.java      2000/11/16 03:22:22     1.51
  +++ TransformerImpl.java      2000/11/16 08:14:13     1.52
  @@ -511,12 +511,30 @@
         ContentHandler inputHandler = getInputContentHandler();
   
         reader.setContentHandler(inputHandler);
  +      if(inputHandler instanceof org.xml.sax.DTDHandler)
  +        reader.setDTDHandler((org.xml.sax.DTDHandler)inputHandler);
         try
         {
  -        reader.setProperty("http://xml.org/sax/properties/lexical-handler";,
  -                           inputHandler);
  +        if(inputHandler instanceof org.xml.sax.ext.LexicalHandler)
  +          reader.setProperty("http://xml.org/sax/properties/lexical-handler";,
  +                             inputHandler);
  +        if(inputHandler instanceof org.xml.sax.ext.DeclHandler)
  +          
reader.setProperty("http://xml.org/sax/properties/declaration-handler";,
  +                             inputHandler);
         }
         catch(org.xml.sax.SAXException se) {}
  +      try
  +      {
  +        if(inputHandler instanceof org.xml.sax.ext.LexicalHandler)
  +          reader.setProperty("http://xml.org/sax/handlers/LexicalHandler";,
  +                             inputHandler);
  +        if(inputHandler instanceof org.xml.sax.ext.DeclHandler)
  +          reader.setProperty("http://xml.org/sax/handlers/DeclHandler";,
  +                             inputHandler);
  +      }
  +      catch(org.xml.sax.SAXNotRecognizedException snre)
  +      {
  +      }
   
         // Set the reader for cloning purposes.
         getXPathContext().setPrimaryReader(reader);
  @@ -949,12 +967,30 @@
         inputHandler = (ContentHandler) inputHandlerClass.newInstance();
   
         reader.setContentHandler(inputHandler);
  +      if(inputHandler instanceof org.xml.sax.DTDHandler)
  +        reader.setDTDHandler((org.xml.sax.DTDHandler)inputHandler);
         try
         {
  -        reader.setProperty("http://xml.org/sax/properties/lexical-handler";,
  -                           inputHandler);
  +        if(inputHandler instanceof org.xml.sax.ext.LexicalHandler)
  +          reader.setProperty("http://xml.org/sax/properties/lexical-handler";,
  +                             inputHandler);
  +        if(inputHandler instanceof org.xml.sax.ext.DeclHandler)
  +          
reader.setProperty("http://xml.org/sax/properties/declaration-handler";,
  +                             inputHandler);
         }
         catch(SAXNotRecognizedException snre){}
  +      try
  +      {
  +        if(inputHandler instanceof org.xml.sax.ext.LexicalHandler)
  +          reader.setProperty("http://xml.org/sax/handlers/LexicalHandler";,
  +                             inputHandler);
  +        if(inputHandler instanceof org.xml.sax.ext.DeclHandler)
  +          reader.setProperty("http://xml.org/sax/handlers/DeclHandler";,
  +                             inputHandler);
  +      }
  +      catch(org.xml.sax.SAXNotRecognizedException snre)
  +      {
  +      }
         getXPathContext().setPrimaryReader(reader);
   
         // ...and of course I need a standard way to get a node...
  
  
  

Reply via email to