mrglavas    2003/11/16 20:49:18

  Modified:    java/src/org/apache/xerces/xinclude XIncludeHandler.java
                        XIncludeTextReader.java
  Added:       java/src/org/apache/xerces/xinclude
                        XInclude11TextReader.java
  Log:
  Adding support for XML 1.1 text inclusion.
  
  Revision  Changes    Path
  1.8       +11 -1     
xml-xerces/java/src/org/apache/xerces/xinclude/XIncludeHandler.java
  
  Index: XIncludeHandler.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xerces/java/src/org/apache/xerces/xinclude/XIncludeHandler.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- XIncludeHandler.java      9 Nov 2003 23:27:49 -0000       1.7
  +++ XIncludeHandler.java      17 Nov 2003 04:49:18 -0000      1.8
  @@ -277,6 +277,9 @@
       // for SAX compatibility.
       // Has the value of the ALLOW_UE_AND_NOTATION_EVENTS feature
       private boolean fSendUEAndNotationEvents;
  +    
  +    // track the version of the document being parsed
  +    private boolean fIsXML11;
   
       // Constructors
   
  @@ -305,6 +308,7 @@
           fNotations = new Vector();
           fUnparsedEntities = new Vector();
           fParentRelativeURI = null;
  +        fIsXML11 = false;
   
           baseURIScope.clear();
           baseURI.clear();
  @@ -544,6 +548,7 @@
           String standalone,
           Augmentations augs)
           throws XNIException {
  +        fIsXML11 = "1.1".equals(version);
           if (isRootDocument() && fDocumentHandler != null) {
               fDocumentHandler.xmlDecl(version, encoding, standalone, augs);
           }
  @@ -1202,7 +1207,12 @@
   
               XIncludeTextReader reader = null;
               try {
  -                reader = new XIncludeTextReader(includedSource, this);
  +                if (fIsXML11) {
  +                    reader = new XInclude11TextReader(includedSource, this);
  +                }
  +                else {
  +                    reader = new XIncludeTextReader(includedSource, this);
  +                }
                   reader.setErrorReporter(fErrorReporter);
                   reader.parse();
               }
  
  
  
  1.5       +5 -4      
xml-xerces/java/src/org/apache/xerces/xinclude/XIncludeTextReader.java
  
  Index: XIncludeTextReader.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xerces/java/src/org/apache/xerces/xinclude/XIncludeTextReader.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- XIncludeTextReader.java   9 Nov 2003 23:27:49 -0000       1.4
  +++ XIncludeTextReader.java   17 Nov 2003 04:49:18 -0000      1.5
  @@ -77,7 +77,7 @@
   import org.apache.xerces.xni.parser.XMLInputSource;
   
   /**
  - * This class is used for reading files requested in <include> elements,
  + * This class is used for reading resources requested in <include> elements,
    * when the parse attribute of the <include> element is "text".  Using this
    * class will open the location, detect the encoding, and discard the byte order
    * mark, if applicable.
  @@ -481,11 +481,12 @@
       }
       
       /**
  -     * Returns true if the specified character is a valid XML character.
  +     * Returns true if the specified character is a valid XML character
  +     * as per the rules of XML 1.0.
        *
        * @param ch The character to check.
        */
  -    private boolean isValid(int ch) {
  +    protected boolean isValid(int ch) {
           return XMLChar.isValid(ch);
       }
   }
  
  
  
  1.1                  
xml-xerces/java/src/org/apache/xerces/xinclude/XInclude11TextReader.java
  
  Index: XInclude11TextReader.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Xerces" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 2003, International
   * Business Machines, Inc., http://www.apache.org.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.xerces.xinclude;
  
  import java.io.IOException;
  
  import org.apache.xerces.util.XML11Char;
  import org.apache.xerces.xni.parser.XMLInputSource;
  
  /**
   * This class is used for reading resources requested in &lt;include&gt; elements in
   * XML 1.1 entities, when the parse attribute of the &lt;include&gt; element is 
"text".
   * Using this class will open the location, detect the encoding, and discard the 
   * byte order mark, if applicable.
   * 
   * @author Michael Glavassevich, IBM
   *
   * @version $Id: XInclude11TextReader.java,v 1.1 2003/11/17 04:49:18 mrglavas Exp $
   *
   * @see XIncludeHandler
   */
  public class XInclude11TextReader
      extends XIncludeTextReader {
  
      /**
       * Construct the XIncludeReader using the XMLInputSource and XIncludeHandler.
       *
       * @param source The XMLInputSource to use.
       * @param handler The XIncludeHandler to use.
       */
      public XInclude11TextReader(XMLInputSource source, XIncludeHandler handler)
          throws IOException {
          super(source, handler);
      }
      
      /**
       * Returns true if the specified character is a valid XML character
       * as per the rules of XML 1.1.
       *
       * @param ch The character to check.
       */
      protected boolean isValid(int ch) {
          return XML11Char.isXML11Valid(ch);
      }
  }
  
  
  

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

Reply via email to