You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by an...@locus.apache.org on 2000/10/21 02:02:58 UTC

cvs commit: xml-xerces/java/src/org/apache/xerces/impl XMLDocumentScanner.java XMLEntityManager.java XMLScanner.java

andyc       00/10/20 17:02:57

  Modified:    java/src/org/apache/xerces/impl Tag: xerces_j_2
                        XMLDocumentScanner.java XMLEntityManager.java
                        XMLScanner.java
  Log:
  1) Fixed bug in XMLScanner#scanCharReferenceValue -- wasn't
     converting hex values correctly.
  2) Implemented entities appearing in attribute values. We
     still need to figure out how to keep track of offsets and
     lengths of the entities so that we set that information in
     the XMLAttributes object.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.36  +56 -10    xml-xerces/java/src/org/apache/xerces/impl/Attic/XMLDocumentScanner.java
  
  Index: XMLDocumentScanner.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/Attic/XMLDocumentScanner.java,v
  retrieving revision 1.1.2.35
  retrieving revision 1.1.2.36
  diff -u -r1.1.2.35 -r1.1.2.36
  --- XMLDocumentScanner.java	2000/10/20 23:01:29	1.1.2.35
  +++ XMLDocumentScanner.java	2000/10/21 00:02:54	1.1.2.36
  @@ -101,7 +101,7 @@
    * @author Stubs generated by DesignDoc on Mon Sep 11 11:10:57 PDT 2000
    * @author Andy Clark, IBM
    *
  - * @version $Id: XMLDocumentScanner.java,v 1.1.2.35 2000/10/20 23:01:29 andyc Exp $
  + * @version $Id: XMLDocumentScanner.java,v 1.1.2.36 2000/10/21 00:02:54 andyc Exp $
    */
   public class XMLDocumentScanner
       extends XMLScanner
  @@ -487,6 +487,8 @@
       public void endEntity(String name) throws SAXException {
   
           // sanity check
  +        // REVISIT: Shouldn't the entity manager perform this sanity
  +        //          check? -Ac
           Entity entity = (Entity)fEntityStack.pop();
           if (!name.equals(entity.name)) {
               // REVISIT: report error
  @@ -676,7 +678,6 @@
                                                  null, XMLErrorReporter.SEVERITY_FATAL_ERROR);
                   }
                   fEntityScanner.scanChar();
  -                // REVISIT: do right
                   XMLString value = fString;
                   if (fEntityScanner.scanLiteral(quote, fString) != quote) {
                       fStringBuffer.clear();
  @@ -706,7 +707,6 @@
                                                  null, XMLErrorReporter.SEVERITY_FATAL_ERROR);
                   }
                   fEntityScanner.scanChar();
  -                // REVISIT: do right
                   XMLString value = fString;
                   if (fEntityScanner.scanLiteral(quote, fString) != quote) {
                       fStringBuffer.clear();
  @@ -734,7 +734,6 @@
                                                  null, XMLErrorReporter.SEVERITY_FATAL_ERROR);
                   }
                   fEntityScanner.scanChar();
  -                // REVISIT: do right
                   value = fString;
                   if (fEntityScanner.scanLiteral(quote, fString) != quote) {
                       fStringBuffer.clear();
  @@ -952,18 +951,65 @@
           final String CDATA = fSymbolTable.addSymbol("CDATA");
           attributes.setAttribute(fAttributeQName, CDATA, null);
           XMLString value = fString;
  -        if (fEntityScanner.scanLiteral(quote, fString) != quote) {
  +        int c = fEntityScanner.scanLiteral(quote, fString);
  +        if (c != quote) {
  +            fScanningAttribute = true;
               fStringBuffer.clear();
               do {
                   fStringBuffer.append(fString);
  -                /***
  -                if (fEntityScanner.peekChar() == '&') {
  -                    // TODO: handle entities in value
  +                if (c == '&') {
  +                    fEntityScanner.skipChar('&');
  +                    if (fEntityScanner.skipChar('#')) {
  +                        int cv = scanCharReferenceValue();
  +                        if (cv != -1) {
  +                            fStringBuffer.append((char)cv);
  +                        }
  +                    }
  +                    else {
  +                        // REVISIT: Store offsets and lengths of
  +                        //          expanded entities so that we
  +                        //          can expose them in the DOM. -Ac
  +                        String entityName = fEntityScanner.scanName();
  +                        if (entityName == null) {
  +                            fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
  +                                                       "NameRequiredInReference",
  +                                                       null, XMLErrorReporter.SEVERITY_FATAL_ERROR);
  +                        }
  +                        if (!fEntityScanner.skipChar(';')) {
  +                            fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
  +                                                       "SemicolonRequiredInReference",
  +                                                       null, XMLErrorReporter.SEVERITY_FATAL_ERROR);
  +                        }
  +                        if (entityName == fAmpSymbol) {
  +                            fStringBuffer.append('&');
  +                        }
  +                        else if (entityName == fAposSymbol) {
  +                            fStringBuffer.append('\'');
  +                        }
  +                        else if (entityName == fLtSymbol) {
  +                            fStringBuffer.append('<');
  +                        }
  +                        else if (entityName == fGtSymbol) {
  +                            fStringBuffer.append('>');
  +                        }
  +                        else if (entityName == fQuotSymbol) {
  +                            fStringBuffer.append('"');
  +                        }
  +                        else {
  +                            fEntityManager.startEntity(entityName, true);
  +                        }
  +                    }
                   }
  -                /***/
  -            } while (fEntityScanner.scanLiteral(quote, fString) != quote);
  +                else if (c == '<') {
  +                    fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
  +                                               "LessthanInAttValue",
  +                                               null, XMLErrorReporter.SEVERITY_FATAL_ERROR);
  +                }
  +                c = fEntityScanner.scanLiteral(quote, fString);
  +            } while (c != quote);
               fStringBuffer.append(fString);
               value = fStringBuffer;
  +            fScanningAttribute = false;
           }
           attributes.setValue(attributes.getLength() - 1, value);
   
  
  
  
  1.1.2.33  +9 -3      xml-xerces/java/src/org/apache/xerces/impl/Attic/XMLEntityManager.java
  
  Index: XMLEntityManager.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/Attic/XMLEntityManager.java,v
  retrieving revision 1.1.2.32
  retrieving revision 1.1.2.33
  diff -u -r1.1.2.32 -r1.1.2.33
  --- XMLEntityManager.java	2000/10/20 23:01:31	1.1.2.32
  +++ XMLEntityManager.java	2000/10/21 00:02:54	1.1.2.33
  @@ -114,7 +114,7 @@
    * @author Stubs generated by DesignDoc on Mon Sep 18 18:23:16 PDT 2000
    * @author Andy Clark, IBM
    *
  - * @version $Id: XMLEntityManager.java,v 1.1.2.32 2000/10/20 23:01:31 andyc Exp $
  + * @version $Id: XMLEntityManager.java,v 1.1.2.33 2000/10/21 00:02:54 andyc Exp $
    */
   public class XMLEntityManager
       implements XMLComponent {
  @@ -2020,6 +2020,12 @@
               // return next character
               if (fCurrentEntity.position != fCurrentEntity.count) {
                   c = fCurrentEntity.ch[fCurrentEntity.position];
  +                // NOTE: We don't want to accidentally signal the
  +                //       end of the literal if we're expanding an
  +                //       entity appearing in the literal. -Ac
  +                if (c == quote && fCurrentEntity.literal) {
  +                    c = -1;
  +                }
               }
               if (DEBUG_PRINT) {
                   System.out.print(")scanLiteral, '"+(char)quote+"': ");
  @@ -2529,7 +2535,7 @@
           // Data
           //
   
  -        /** Seen first character. */
  +        /** True if we've seen the first character. */
           private boolean fSeenFirstChar;
   
           /** True if we've seen the end of the first markup. */
  @@ -2569,7 +2575,7 @@
                   fSeenEndOfMarkup = c != '<';
               }
               else {
  -                fSeenEndOfMarkup = c == '>';
  +                fSeenEndOfMarkup = c == '>' || c == '[';
               }
               if (DEBUG_ENCODINGS) {
                   System.out.println("$$$ read() -> '"+(char)c+"' (end of markup: "+fSeenEndOfMarkup+')');
  
  
  
  1.1.2.11  +2 -1      xml-xerces/java/src/org/apache/xerces/impl/Attic/XMLScanner.java
  
  Index: XMLScanner.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/Attic/XMLScanner.java,v
  retrieving revision 1.1.2.10
  retrieving revision 1.1.2.11
  diff -u -r1.1.2.10 -r1.1.2.11
  --- XMLScanner.java	2000/10/20 23:01:31	1.1.2.10
  +++ XMLScanner.java	2000/10/21 00:02:55	1.1.2.11
  @@ -92,7 +92,7 @@
    * @author Andy Clark, IBM
    * @author Arnaud  Le Hors, IBM
    *
  - * @version $Id: XMLScanner.java,v 1.1.2.10 2000/10/20 23:01:31 andyc Exp $
  + * @version $Id: XMLScanner.java,v 1.1.2.11 2000/10/21 00:02:55 andyc Exp $
    */
   public abstract class XMLScanner 
       implements XMLComponent {
  @@ -510,6 +510,7 @@
           // scan hexadecimal value
           boolean hex = false;
           if (fEntityScanner.skipChar('x')) {
  +            hex = true;
               fStringBuffer.clear();
               boolean digit = true;
               do {