Changeset 7396


Ignore:
Timestamp:
11/21/06 13:35:34 (5 years ago)
Author:
sys
Message:

bug dans le reader qui dupliquait la déclaration xml + suppr rewindDeclaration non utilisé et manifestement bugué

Location:
trunk/Res_Piccolo/com/bluecast/xml
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Res_Piccolo/com/bluecast/xml/DocumentEntity.java

    r7316 r7396  
    7373                    readerReader = new XMLReaderReader(); 
    7474 
    75                     readerReader.reset(sourceReader,true); 
     75                    readerReader.reset(sourceReader); 
    7676                    isStandalone = readerReader.isXMLStandalone(); 
    7777                    activeReader = readerReader; 
     
    8484                if (streamReader == null) 
    8585                    streamReader = new XMLStreamReader(); 
    86                 streamReader.reset(in, source.getEncoding(), true); 
     86                streamReader.reset(in, source.getEncoding()); 
    8787                isOpen = true; 
    8888                isStandalone = streamReader.isXMLStandalone(); 
     
    9999        if (streamReader == null) 
    100100            streamReader = new XMLStreamReader(); 
    101         streamReader.reset(url.openStream(), encoding, true); 
     101        streamReader.reset(url.openStream(), encoding); 
    102102        isStandalone = streamReader.isXMLStandalone(); 
    103103        activeReader = streamReader; 
  • trunk/Res_Piccolo/com/bluecast/xml/EntityManager.java

    r7316 r7396  
    7474                        if (!isInternal()) { 
    7575                                if (resolver == null) { 
    76                                         reader = new XMLStreamReader((new URL(sysID)).openStream(), true); 
     76                                        reader = new XMLStreamReader((new URL(sysID)).openStream()); 
    7777                                } else { 
    7878                                        InputSource source = resolver.resolveEntity(pubID, sysID); 
    7979                                        if (source == null) { 
    80                                                 reader = new XMLStreamReader((new URL(sysID)).openStream(), true); 
     80                                                reader = new XMLStreamReader((new URL(sysID)).openStream()); 
    8181                                        } else { 
    8282                                                Reader r = source.getCharacterStream(); 
    8383                                                if (r != null) 
    84                                                         reader = new XMLReaderReader(r, true); 
     84                                                        reader = new XMLReaderReader(r); 
    8585                                                else { 
    8686                                                        InputStream in; 
     
    8888                                                        in = source.getByteStream(); 
    8989                                                        if (in != null) 
    90                                                                 reader = new XMLStreamReader(in, source.getEncoding(), true); 
    91                                                         else reader = new XMLStreamReader((new URL(source.getSystemId())).openStream(), source.getEncoding(), true); 
     90                                                                reader = new XMLStreamReader(in, source.getEncoding()); 
     91                                                        else reader = new XMLStreamReader((new URL(source.getSystemId())).openStream(), source.getEncoding()); 
    9292                                                } 
    9393                                        } 
  • trunk/Res_Piccolo/com/bluecast/xml/Piccolo.java

    r7369 r7396  
    3232import org.xml.sax.ext.DeclHandler; 
    3333import org.xml.sax.ext.LexicalHandler; 
     34import org.xml.sax.helpers.DefaultHandler; 
    3435 
    3536import com.bluecast.io.FileFormatException; 
     
    7273        public static void main(String[] pArgs){ 
    7374                try { 
    74                         Piccolo vParser = new Piccolo(); 
    75                         vParser.parse(new InputSource(new ByteArrayInputStream("<test/>".getBytes("UTF-8"))));//<?xml version=\"1.0\" encoding=\"UTF-8\"?> 
     75                        Piccolo vParser = new Piccolo(false); 
     76                        vParser.setContentHandler(new DefaultHandler()); 
     77                        vParser.parse(new InputSource(new ByteArrayInputStream("<test><!-- &amp;dpi=300--></test>".getBytes("UTF-8"))));//<?xml version=\"1.0\" encoding=\"UTF-8\"?> 
    7678                } catch (Exception e) { 
    7779                        e.printStackTrace(); 
  • trunk/Res_Piccolo/com/bluecast/xml/PiccoloLexer.java

    r7316 r7396  
    30273027        private int yy_currentPos_l; 
    30283028 
    3029         private int yy_startRead_l; 
    3030  
    30313029        private int yy_markedPos_l; 
    30323030 
     
    30833081                        yy_action = -1; 
    30843082 
    3085                         yy_startRead_l = yy_currentPos_l = yy_currentPos = yy_startRead = yy_markedPos_l; 
     3083                        yy_currentPos_l = yy_currentPos = yy_startRead = yy_markedPos_l; 
    30863084 
    30873085                        yy_state = yy_lexical_state; 
  • trunk/Res_Piccolo/com/bluecast/xml/XMLReaderReader.java

    r7033 r7396  
    3737    private static final int BUFFER_SIZE = 8192; 
    3838    private Reader in; 
    39     private boolean rewindDeclaration; 
    4039    private char[] cbuf = new char[BUFFER_SIZE]; 
    4140    private int cbufPos = 0, cbufEnd = 0; 
     
    5958 
    6059    public XMLReaderReader (Reader in) throws IOException { 
    61         this(in,true); 
    62     } 
    63  
    64     /** 
    65      * Creates an XMLReaderReader. 
    66      * 
    67      * @param     in the input source 
    68      * @param     rewindDeclaration a value of false will skip past any 
    69      *            XML declaration. True will dish out the entire document. 
    70      */ 
    71     public XMLReaderReader (Reader in, boolean rewindDeclaration) 
    72     throws IOException { 
    73         reset(in,rewindDeclaration); 
    74     } 
    75  
    76     public void reset(Reader in, boolean rewindDeclaration) 
     60        reset(in); 
     61    } 
     62 
     63    public void reset(Reader in) 
    7764    throws IOException { 
    7865 
    7966        super.resetInput(); 
    8067        this.in = in; 
    81         this.rewindDeclaration = rewindDeclaration; 
    8268        cbufPos = cbufEnd = 0; 
    8369        sawCR = false; 
     
    254240    /* Read [max] characters, parse the <?xml...?> tag 
    255241     * push it back onto the stream. Create a reader. Then, if there was 
    256      * no error parsing the declaration, eat up the declaration. 
     242     * no error parsing the declaration. 
    257243     */ 
    258244    private void processXMLDecl () throws IOException { 
    259         int numCharsParsed = parseXMLDeclaration(cbuf,0,cbufEnd); 
    260  
    261         if (numCharsParsed > 0) { 
    262             // Declaration found and parsed 
    263  
    264             // Skip the XML declaration unless told otherwise 
    265             if (!rewindDeclaration) 
    266                 cbufPos += numCharsParsed; 
    267         } 
     245        parseXMLDeclaration(cbuf,0,cbufEnd); 
    268246    } 
    269247} 
  • trunk/Res_Piccolo/com/bluecast/xml/XMLStreamReader.java

    r7316 r7396  
    6868     *            XML declaration. True will dish out the entire document. 
    6969     */ 
    70     public XMLStreamReader (InputStream in, boolean rewindDeclaration) throws IOException 
     70    public XMLStreamReader (InputStream in) throws IOException 
    7171    { 
    72         this(in, null, rewindDeclaration); 
     72        this(in, null); 
    7373    } 
    7474 
     
    7676     * Creates an XMLStreamReader while specifying a character encoding. 
    7777     */ 
    78     public XMLStreamReader (InputStream in, String encoding, 
    79                             boolean rewindDeclaration) throws IOException 
     78    public XMLStreamReader (InputStream in, String encoding) throws IOException 
    8079    { 
    81         reset(in, encoding, rewindDeclaration); 
     80        reset(in, encoding); 
    8281    } 
    8382 
     
    8584     * Reuses this XMLStreamReader for a different InputStream. 
    8685     */ 
    87     public void reset (InputStream in, String encoding, 
    88                        boolean rewindDeclaration) throws IOException { 
     86    public void reset (InputStream in, String encoding) throws IOException { 
    8987        super.resetInput(); 
    9088        this.in = in; 
    9189        eofReached = false; 
    92         this.rewindDeclaration = rewindDeclaration; 
    9390        useDeclaredEncoding = false; 
    9491        bbufPos = bbufEnd = 0; 
     
    675672         
    676673        int bbufPosTemp = bbufPos + decodeResult[0]; 
    677         cbufEnd = decodeResult[1]; 
     674        int cbufEndTemp = decodeResult[1]; 
    678675         
    679         while(r == -2 && ! eofReached && cbufEnd < cbuf.length) { 
     676        while(r == -2 && ! eofReached && cbufEndTemp < cbuf.length) { 
    680677            fillByteBuffer(); 
    681678            r = decoder.decodeXMLDecl(bbuf, bbufPosTemp, bbufEnd - bbufPosTemp, 
    682                     cbuf, cbufPos+cbufEnd, cbuf.length-cbufEnd, 
     679                    cbuf, cbufPos+cbufEndTemp, cbuf.length-cbufEndTemp, 
    683680                    decodeResult); 
    684681            bbufPosTemp += decodeResult[0]; 
    685                     cbufEnd += decodeResult[1]; 
    686         } 
    687  
    688         int numCharsParsed = parseXMLDeclaration(cbuf,0,cbufEnd); 
     682                    cbufEndTemp += decodeResult[1]; 
     683        } 
     684 
     685        parseXMLDeclaration(cbuf,0,cbufEndTemp); 
    689686 
    690687        //if (numCharsParsed > 0) { 
     
    694691 
    695692            // Skip the XML declaration unless told otherwise 
    696             if (!rewindDeclaration) 
    697                 cbufPos += numCharsParsed; 
     693            //if (!rewindDeclaration) 
     694            //    cbufPos += numCharsParsed; 
    698695 
    699696            // If another encoding was specified, use it instead of the guess. 
     
    702699                && !declaredEncoding.equalsIgnoreCase(encoding)) { 
    703700 
    704                 cbufPos = cbufEnd = 0; 
     701                cbufPos = cbufEndTemp = 0; 
     702                bbufPos = initialBBufPos; 
    705703                decoder.reset(); 
    706  
    707  
    708                 if (rewindDeclaration) 
    709                     bbufPos = initialBBufPos; 
    710                 else 
    711                     bbufPos = numCharsParsed*minBytesPerChar; 
    712704 
    713705                setEncoding(declaredEncoding); 
Note: See TracChangeset for help on using the changeset viewer.