< prev index next >

src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java

Print this page

        

*** 216,227 **** null, JdkXmlUtils.CDATA_CHUNK_SIZE_DEFAULT }; ! private static final char [] cdata = {'[','C','D','A','T','A','['}; ! static final char [] xmlDecl = {'<','?','x','m','l'}; // private static final char [] endTag = {'<','/'}; // debugging /** Debug scanner state. */ private static final boolean DEBUG_SCANNER_STATE = false; --- 216,227 ---- null, JdkXmlUtils.CDATA_CHUNK_SIZE_DEFAULT }; ! private static final char [] CDATA = {'[','C','D','A','T','A','['}; ! static final char [] XMLDECL = {'<','?','x','m','l'}; // private static final char [] endTag = {'<','/'}; // debugging /** Debug scanner state. */ private static final boolean DEBUG_SCANNER_STATE = false;
*** 230,246 **** private static final boolean DEBUG_DISPATCHER = false; /** Debug content driver scanning. */ protected static final boolean DEBUG_START_END_ELEMENT = false; - - /** Debug driver next */ - protected static final boolean DEBUG_NEXT = false ; - /** Debug driver next */ protected static final boolean DEBUG = false; ! protected static final boolean DEBUG_COALESCE = false; // // Data // // protected data --- 230,242 ---- private static final boolean DEBUG_DISPATCHER = false; /** Debug content driver scanning. */ protected static final boolean DEBUG_START_END_ELEMENT = false; /** Debug driver next */ protected static final boolean DEBUG = false; ! // // Data // // protected data
*** 369,388 **** /** String. */ protected XMLString fTempString2 = new XMLString(); /** Array of 3 strings. */ ! private String[] fStrings = new String[3]; ! /** Making the buffer accesible to derived class -- String buffer. */ protected XMLStringBuffer fStringBuffer = new XMLStringBuffer(); ! /** Making the buffer accesible to derived class -- String buffer. */ protected XMLStringBuffer fStringBuffer2 = new XMLStringBuffer(); /** stores character data. */ ! /** Making the buffer accesible to derived class -- stores PI data */ protected XMLStringBuffer fContentBuffer = new XMLStringBuffer(); /** Single character array. */ private final char[] fSingleChar = new char[1]; private String fCurrentEntityName = null; --- 365,384 ---- /** String. */ protected XMLString fTempString2 = new XMLString(); /** Array of 3 strings. */ ! private final String[] fStrings = new String[3]; ! /** Making the buffer accessible to derived class -- String buffer. */ protected XMLStringBuffer fStringBuffer = new XMLStringBuffer(); ! /** Making the buffer accessible to derived class -- String buffer. */ protected XMLStringBuffer fStringBuffer2 = new XMLStringBuffer(); /** stores character data. */ ! /** Making the buffer accessible to derived class -- stores PI data */ protected XMLStringBuffer fContentBuffer = new XMLStringBuffer(); /** Single character array. */ private final char[] fSingleChar = new char[1]; private String fCurrentEntityName = null;
*** 631,656 **** super.reset(propertyManager); // other settings // fDocumentSystemId = null; ! fNamespaces = ((Boolean)propertyManager.getProperty(XMLInputFactory.IS_NAMESPACE_AWARE)).booleanValue(); fNotifyBuiltInRefs = false ; //fElementStack2.clear(); //fReplaceEntityReferences = true; //fSupportExternalEntities = true; Boolean bo = (Boolean)propertyManager.getProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES); ! fReplaceEntityReferences = bo.booleanValue(); bo = (Boolean)propertyManager.getProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES); ! fSupportExternalEntities = bo.booleanValue(); ! Boolean cdata = (Boolean)propertyManager.getProperty(Constants.ZEPHYR_PROPERTY_PREFIX + Constants.STAX_REPORT_CDATA_EVENT) ; if(cdata != null) ! fReportCdataEvent = cdata.booleanValue() ; Boolean coalesce = (Boolean)propertyManager.getProperty(XMLInputFactory.IS_COALESCING) ; if(coalesce != null) ! fIsCoalesce = coalesce.booleanValue(); fReportCdataEvent = fIsCoalesce ? false : (fReportCdataEvent && true) ; //if fIsCoalesce is set to true, set the value of fReplaceEntityReferences to true, //if fIsCoalesce is set to false, take the value of fReplaceEntityReferences as set by application fReplaceEntityReferences = fIsCoalesce ? true : fReplaceEntityReferences; // setup Driver --- 627,653 ---- super.reset(propertyManager); // other settings // fDocumentSystemId = null; ! fNamespaces = ((Boolean)propertyManager.getProperty(XMLInputFactory.IS_NAMESPACE_AWARE)); fNotifyBuiltInRefs = false ; //fElementStack2.clear(); //fReplaceEntityReferences = true; //fSupportExternalEntities = true; Boolean bo = (Boolean)propertyManager.getProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES); ! fReplaceEntityReferences = bo; bo = (Boolean)propertyManager.getProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES); ! fSupportExternalEntities = bo; ! Boolean cdata = (Boolean)propertyManager.getProperty( ! Constants.ZEPHYR_PROPERTY_PREFIX + Constants.STAX_REPORT_CDATA_EVENT) ; if(cdata != null) ! fReportCdataEvent = cdata ; Boolean coalesce = (Boolean)propertyManager.getProperty(XMLInputFactory.IS_COALESCING) ; if(coalesce != null) ! fIsCoalesce = coalesce; fReportCdataEvent = fIsCoalesce ? false : (fReportCdataEvent && true) ; //if fIsCoalesce is set to true, set the value of fReplaceEntityReferences to true, //if fIsCoalesce is set to false, take the value of fReplaceEntityReferences as set by application fReplaceEntityReferences = fIsCoalesce ? true : fReplaceEntityReferences; // setup Driver
*** 701,711 **** * Returns a list of feature identifiers that are recognized by * this component. This method may return null if no features * are recognized by this component. */ public String[] getRecognizedFeatures() { ! return (String[])(RECOGNIZED_FEATURES.clone()); } // getRecognizedFeatures():String[] /** * Sets the state of a feature. This method is called by the component * manager any time after reset when a feature changes state. --- 698,708 ---- * Returns a list of feature identifiers that are recognized by * this component. This method may return null if no features * are recognized by this component. */ public String[] getRecognizedFeatures() { ! return RECOGNIZED_FEATURES.clone(); } // getRecognizedFeatures():String[] /** * Sets the state of a feature. This method is called by the component * manager any time after reset when a feature changes state.
*** 740,750 **** * Returns a list of property identifiers that are recognized by * this component. This method may return null if no properties * are recognized by this component. */ public String[] getRecognizedProperties() { ! return (String[])(RECOGNIZED_PROPERTIES.clone()); } // getRecognizedProperties():String[] /** * Sets the value of a property. This method is called by the component * manager any time after reset when a property changes value. --- 737,747 ---- * Returns a list of property identifiers that are recognized by * this component. This method may return null if no properties * are recognized by this component. */ public String[] getRecognizedProperties() { ! return RECOGNIZED_PROPERTIES.clone(); } // getRecognizedProperties():String[] /** * Sets the value of a property. This method is called by the component * manager any time after reset when a property changes value.
*** 988,998 **** String standalone = fStrings[2]; fDeclaredEncoding = encoding; // set standalone fStandaloneSet = standalone != null; fStandalone = fStandaloneSet && standalone.equals("yes"); ! ///xxx see where its used.. this is not used anywhere. it may be useful for entity to store this information //but this information is only related with Document Entity. fEntityManager.setStandalone(fStandalone); // call handler --- 985,996 ---- String standalone = fStrings[2]; fDeclaredEncoding = encoding; // set standalone fStandaloneSet = standalone != null; fStandalone = fStandaloneSet && standalone.equals("yes"); ! ///xxx see where its used.. this is not used anywhere. ! //it may be useful for entity to store this information //but this information is only related with Document Entity. fEntityManager.setStandalone(fStandalone); // call handler
*** 1197,1207 **** //Look at the next element stored in the array list.. we might just get a match. String rawname = fElementArray[fLastPointerLocation + 1] ; if(rawname != null && skipFromTheBuffer(rawname)){ fLastPointerLocation++ ; if(DEBUG_SKIP_ALGORITHM){ ! System.out.println("Element " + fElementRawname + " was SKIPPED at pointer location = " + fLastPointerLocation); } return true ; } else{ //reset it back to zero... we haven't got the correct subset yet. fLastPointerLocation = 0 ; --- 1195,1206 ---- //Look at the next element stored in the array list.. we might just get a match. String rawname = fElementArray[fLastPointerLocation + 1] ; if(rawname != null && skipFromTheBuffer(rawname)){ fLastPointerLocation++ ; if(DEBUG_SKIP_ALGORITHM){ ! System.out.println("Element " + fElementRawname + ! " was SKIPPED at pointer location = " + fLastPointerLocation); } return true ; } else{ //reset it back to zero... we haven't got the correct subset yet. fLastPointerLocation = 0 ;
*** 1231,1241 **** } if(fElementArray[pointer] != null && skipFromTheBuffer(fElementArray[pointer])){ if(DEBUG_SKIP_ALGORITHM){ System.out.println(); ! System.out.println("Element " + fElementRawname + " was SKIPPED at depth = " + fElementStack.fDepth + " column = " + column ); System.out.println(); } fLastPointerLocation = pointer ; return fShouldSkip = true ; } --- 1230,1241 ---- } if(fElementArray[pointer] != null && skipFromTheBuffer(fElementArray[pointer])){ if(DEBUG_SKIP_ALGORITHM){ System.out.println(); ! System.out.println("Element " + fElementRawname + " was SKIPPED at depth = " + ! fElementStack.fDepth + " column = " + column ); System.out.println(); } fLastPointerLocation = pointer ; return fShouldSkip = true ; }
*** 1315,1325 **** } if(DEBUG)System.out.println("Element scanned in start element is " + fElementQName.toString()); if(DEBUG_SKIP_ALGORITHM){ if(fAdd){ ! System.out.println("Elements are being ADDED -- elemet added is = " + fElementQName.rawname + " at count = " + fElementStack.fCount); } } } --- 1315,1326 ---- } if(DEBUG)System.out.println("Element scanned in start element is " + fElementQName.toString()); if(DEBUG_SKIP_ALGORITHM){ if(fAdd){ ! System.out.println("Elements are being ADDED -- elemet added is = " + ! fElementQName.rawname + " at count = " + fElementStack.fCount); } } }
*** 1393,1403 **** fDocumentHandler.startElement(fElementQName, fAttributes, null); } } ! if (DEBUG_START_END_ELEMENT) System.out.println(this.getClass().toString() + "<<< scanStartElement(): "+fEmptyElement); return fEmptyElement; } // scanStartElement():boolean /** --- 1394,1405 ---- fDocumentHandler.startElement(fElementQName, fAttributes, null); } } ! if (DEBUG_START_END_ELEMENT) System.out.println(this.getClass().toString() + ! "<<< scanStartElement(): "+fEmptyElement); return fEmptyElement; } // scanStartElement():boolean /**
*** 1432,1519 **** return false; } public boolean hasAttributes(){ ! return fAttributes.getLength() > 0 ? true : false ; } - - /** - * Scans an attribute. - * <p> - * <pre> - * [41] Attribute ::= Name Eq AttValue - * </pre> - * <p> - * <strong>Note:</strong> This method assumes that the next - * character on the stream is the first character of the attribute - * name. - * <p> - * <strong>Note:</strong> This method uses the fAttributeQName and - * fQName variables. The contents of these variables will be - * destroyed. - * - * @param attributes The attributes list for the scanned attribute. - */ - - /** - * protected void scanAttribute(AttributeIteratorImpl attributes) - * throws IOException, XNIException { - * if (DEBUG_START_END_ELEMENT) System.out.println(">>> scanAttribute()"); - * - * - * // name - * if (fNamespaces) { - * fEntityScanner.scanQName(fAttributeQName); - * } - * else { - * String name = fEntityScanner.scanName(); - * fAttributeQName.setValues(null, name, name, null); - * } - * - * // equals - * fEntityScanner.skipSpaces(); - * if (!fEntityScanner.skipChar('=')) { - * reportFatalError("EqRequiredInAttribute", - * new Object[]{fAttributeQName.rawname}); - * } - * fEntityScanner.skipSpaces(); - * - * - * // content - * int oldLen = attributes.getLength(); - */ - /**xxx there is one check of duplicate attribute that has been removed. - * attributes.addAttribute(fAttributeQName, XMLSymbols.fCDATASymbol, null); - * - * // WFC: Unique Att Spec - * if (oldLen == attributes.getLength()) { - * reportFatalError("AttributeNotUnique", - * new Object[]{fCurrentElement.rawname, - * fAttributeQName.rawname}); - * } - */ - - /* - //REVISIT: one more case needs to be included: external PE and standalone is no - boolean isVC = fHasExternalDTD && !fStandalone; - scanAttributeValue(fTempString, fTempString2, - fAttributeQName.rawname, attributes, - oldLen, isVC); - - //attributes.setValue(oldLen, fTempString.toString()); - //attributes.setNonNormalizedValue(oldLen, fTempString2.toString()); - //attributes.setSpecified(oldLen, true); - - AttributeImpl attribute = new AttributeImpl(fAttributeQName.prefix,fAttributeQName.localpart,fAttributeQName.uri,fTempString.toString(),fTempString2.toString(),XMLSymbols.fCDATASymbol,true); - fAttributes.addAttribute(attribute); - if (DEBUG_START_END_ELEMENT) System.out.println("<<< scanAttribute()"); - } // scanAttribute(XMLAttributes) - - */ - /** return the attribute iterator implementation */ public XMLAttributesIteratorImpl getAttributeIterator(){ if(dtdGrammarUtil != null && fAddDefaultAttr){ dtdGrammarUtil.addDTDDefaultAttrs(fElementQName,fAttributes); fAddDefaultAttr = false; --- 1434,1446 ---- return false; } public boolean hasAttributes(){ ! return fAttributes.getLength() > 0; } /** return the attribute iterator implementation */ public XMLAttributesIteratorImpl getAttributeIterator(){ if(dtdGrammarUtil != null && fAddDefaultAttr){ dtdGrammarUtil.addDTDDefaultAttrs(fElementQName,fAttributes); fAddDefaultAttr = false;
*** 2622,2632 **** if (!fEntityScanner.skipChar('-', NameType.COMMENT)) { reportFatalError("InvalidCommentStart", null); } setScannerState(SCANNER_STATE_COMMENT); ! } else if (fEntityScanner.skipString(cdata)) { fCDataStart = true; setScannerState(SCANNER_STATE_CDATA ); } else if (!scanForDoctypeHook()) { reportFatalError("MarkupNotRecognizedInContent", null); --- 2549,2559 ---- if (!fEntityScanner.skipChar('-', NameType.COMMENT)) { reportFatalError("InvalidCommentStart", null); } setScannerState(SCANNER_STATE_COMMENT); ! } else if (fEntityScanner.skipString(CDATA)) { fCDataStart = true; setScannerState(SCANNER_STATE_CDATA ); } else if (!scanForDoctypeHook()) { reportFatalError("MarkupNotRecognizedInContent", null);
*** 2708,2794 **** */ public int next() throws IOException, XNIException { while (true) { try { - if(DEBUG_NEXT){ - System.out.println("NOW IN FragmentContentDriver"); - System.out.println("Entering the FragmentContentDriver with = " + getScannerStateName(fScannerState)); - } //decide the actual sub state of the scanner.For more information refer to the javadoc of //decideSubState. ! switch (fScannerState) { ! case SCANNER_STATE_CONTENT: { final int ch = fEntityScanner.peekChar(); if (ch == '<') { fEntityScanner.scanChar(null); setScannerState(SCANNER_STATE_START_OF_MARKUP); } else if (ch == '&') { fEntityScanner.scanChar(NameType.REFERENCE); ! setScannerState(SCANNER_STATE_REFERENCE) ; //XMLEvent.ENTITY_REFERENCE ); //SCANNER_STATE_REFERENCE ! break; } else { //element content is there.. setScannerState(SCANNER_STATE_CHARACTER_DATA); - break; } } ! case SCANNER_STATE_START_OF_MARKUP: { startOfMarkup(); ! break; ! }//case: SCANNER_STATE_START_OF_MARKUP - }//end of switch //decideSubState() ; //do some special handling if isCoalesce is set to true. ! if(fIsCoalesce){ fUsebuffer = true ; //if the last section was character data ! if(fLastSectionWasCharacterData){ ! //if we dont encounter any CDATA or ENTITY REFERENCE and current state is also not SCANNER_STATE_CHARACTER_DATA //return the last scanned charactrer data. ! if((fScannerState != SCANNER_STATE_CDATA) && (fScannerState != SCANNER_STATE_REFERENCE) ! && (fScannerState != SCANNER_STATE_CHARACTER_DATA)){ fLastSectionWasCharacterData = false; return XMLEvent.CHARACTERS; } }//if last section was CDATA or ENTITY REFERENCE //xxx: there might be another entity reference or CDATA after this //<foo>blah blah &amp;&lt;<![CDATA[[aa]]>blah blah</foo> ! else if((fLastSectionWasCData || fLastSectionWasEntityReference)){ //and current state is not SCANNER_STATE_CHARACTER_DATA //or SCANNER_STATE_CDATA or SCANNER_STATE_REFERENCE //this means there is nothing more to be coalesced. //return the CHARACTERS event. ! if((fScannerState != SCANNER_STATE_CDATA) && (fScannerState != SCANNER_STATE_REFERENCE) && (fScannerState != SCANNER_STATE_CHARACTER_DATA)){ fLastSectionWasCData = false; fLastSectionWasEntityReference = false; return XMLEvent.CHARACTERS; } } } - - if(DEBUG_NEXT){ - System.out.println("Actual scanner state set by decideSubState is = " + getScannerStateName(fScannerState)); - } - switch(fScannerState){ case XMLEvent.START_DOCUMENT : return XMLEvent.START_DOCUMENT; case SCANNER_STATE_START_ELEMENT_TAG :{ - //xxx this function returns true when element is empty.. can be linked to end element event. //returns true if the element is empty fEmptyElement = scanStartElement() ; //if the element is empty the next event is "end element" if(fEmptyElement){ setScannerState(SCANNER_STATE_END_ELEMENT_TAG); --- 2635,2709 ---- */ public int next() throws IOException, XNIException { while (true) { try { //decide the actual sub state of the scanner.For more information refer to the javadoc of //decideSubState. ! if (fScannerState == SCANNER_STATE_CONTENT) { final int ch = fEntityScanner.peekChar(); if (ch == '<') { fEntityScanner.scanChar(null); setScannerState(SCANNER_STATE_START_OF_MARKUP); } else if (ch == '&') { fEntityScanner.scanChar(NameType.REFERENCE); ! setScannerState(SCANNER_STATE_REFERENCE) ; } else { //element content is there.. setScannerState(SCANNER_STATE_CHARACTER_DATA); } } ! if (fScannerState == SCANNER_STATE_START_OF_MARKUP) { startOfMarkup(); ! } //decideSubState() ; //do some special handling if isCoalesce is set to true. ! if (fIsCoalesce) { fUsebuffer = true ; //if the last section was character data ! if (fLastSectionWasCharacterData) { ! //if we dont encounter any CDATA or ENTITY REFERENCE and ! //current state is also not SCANNER_STATE_CHARACTER_DATA //return the last scanned charactrer data. ! if ((fScannerState != SCANNER_STATE_CDATA) ! && (fScannerState != SCANNER_STATE_REFERENCE) ! && (fScannerState != SCANNER_STATE_CHARACTER_DATA)) { fLastSectionWasCharacterData = false; return XMLEvent.CHARACTERS; } }//if last section was CDATA or ENTITY REFERENCE //xxx: there might be another entity reference or CDATA after this //<foo>blah blah &amp;&lt;<![CDATA[[aa]]>blah blah</foo> ! else if ((fLastSectionWasCData || fLastSectionWasEntityReference)) { //and current state is not SCANNER_STATE_CHARACTER_DATA //or SCANNER_STATE_CDATA or SCANNER_STATE_REFERENCE //this means there is nothing more to be coalesced. //return the CHARACTERS event. ! if ((fScannerState != SCANNER_STATE_CDATA) ! && (fScannerState != SCANNER_STATE_REFERENCE) && (fScannerState != SCANNER_STATE_CHARACTER_DATA)){ fLastSectionWasCData = false; fLastSectionWasEntityReference = false; return XMLEvent.CHARACTERS; } } } switch(fScannerState){ case XMLEvent.START_DOCUMENT : return XMLEvent.START_DOCUMENT; case SCANNER_STATE_START_ELEMENT_TAG :{ //returns true if the element is empty fEmptyElement = scanStartElement() ; //if the element is empty the next event is "end element" if(fEmptyElement){ setScannerState(SCANNER_STATE_END_ELEMENT_TAG);
*** 2798,2816 **** } return XMLEvent.START_ELEMENT ; } case SCANNER_STATE_CHARACTER_DATA: { - if(DEBUG_COALESCE){ - System.out.println("fLastSectionWasCData = " + fLastSectionWasCData); - System.out.println("fIsCoalesce = " + fIsCoalesce); - } - //if last section was either entity reference or cdata or character data we should be using buffer - fUsebuffer = fLastSectionWasEntityReference || fLastSectionWasCData || fLastSectionWasCharacterData ; ! //When coalesce is set to true and last state was REFERENCE or CDATA or CHARACTER_DATA, buffer should not be cleared. ! if( fIsCoalesce && (fLastSectionWasEntityReference || fLastSectionWasCData || fLastSectionWasCharacterData) ){ fLastSectionWasEntityReference = false; fLastSectionWasCData = false; fLastSectionWasCharacterData = true ; fUsebuffer = true; }else{ --- 2713,2732 ---- } return XMLEvent.START_ELEMENT ; } case SCANNER_STATE_CHARACTER_DATA: { ! //if last section was either entity reference or cdata or ! //character data we should be using buffer ! fUsebuffer = fLastSectionWasEntityReference || fLastSectionWasCData ! || fLastSectionWasCharacterData ; ! ! //When coalesce is set to true and last state was REFERENCE or ! //CDATA or CHARACTER_DATA, buffer should not be cleared. ! if( fIsCoalesce && (fLastSectionWasEntityReference || ! fLastSectionWasCData || fLastSectionWasCharacterData) ){ fLastSectionWasEntityReference = false; fLastSectionWasCData = false; fLastSectionWasCharacterData = true ; fUsebuffer = true; }else{
*** 2820,2832 **** //set the fTempString length to 0 before passing it on to scanContent //scanContent sets the correct co-ordinates as per the content read fTempString.length = 0; int c = fEntityScanner.scanContent(fTempString); ! if(DEBUG){ ! System.out.println("fTempString = " + fTempString); ! } if(fEntityScanner.skipChar('<', null)){ //check if we have reached end of element if(fEntityScanner.skipChar('/', NameType.ELEMENTEND)){ //increase the mark up depth fMarkupDepth++; --- 2736,2746 ---- //set the fTempString length to 0 before passing it on to scanContent //scanContent sets the correct co-ordinates as per the content read fTempString.length = 0; int c = fEntityScanner.scanContent(fTempString); ! if(fEntityScanner.skipChar('<', null)){ //check if we have reached end of element if(fEntityScanner.skipChar('/', NameType.ELEMENTEND)){ //increase the mark up depth fMarkupDepth++;
*** 2839,2877 **** setScannerState(SCANNER_STATE_START_ELEMENT_TAG); }else{ setScannerState(SCANNER_STATE_START_OF_MARKUP); //there can be cdata ahead if coalesce is true we should call again if(fIsCoalesce){ - fUsebuffer = true; fLastSectionWasCharacterData = true; ! fContentBuffer.append(fTempString); ! fTempString.length = 0; continue; } } ! //in case last section was either entity reference or cdata or character data -- we should be using buffer if(fUsebuffer){ ! fContentBuffer.append(fTempString); ! fTempString.length = 0; ! } ! if(DEBUG){ ! System.out.println("NOT USING THE BUFFER, STRING = " + fTempString.toString()); } if(dtdGrammarUtil!= null && dtdGrammarUtil.isIgnorableWhiteSpace(fContentBuffer)){ if(DEBUG)System.out.println("Return SPACE EVENT"); return XMLEvent.SPACE; }else return XMLEvent.CHARACTERS; } else{ ! fUsebuffer = true ; ! if(DEBUG){ ! System.out.println("fContentBuffer = " + fContentBuffer); ! System.out.println("fTempString = " + fTempString); ! } ! fContentBuffer.append(fTempString); ! fTempString.length = 0; } if (c == '\r') { if(DEBUG){ System.out.println("'\r' character found"); } --- 2753,2781 ---- setScannerState(SCANNER_STATE_START_ELEMENT_TAG); }else{ setScannerState(SCANNER_STATE_START_OF_MARKUP); //there can be cdata ahead if coalesce is true we should call again if(fIsCoalesce){ fLastSectionWasCharacterData = true; ! bufferContent(); continue; } } ! //in case last section was either entity reference or ! //cdata or character data -- we should be using buffer if(fUsebuffer){ ! bufferContent(); } + if(dtdGrammarUtil!= null && dtdGrammarUtil.isIgnorableWhiteSpace(fContentBuffer)){ if(DEBUG)System.out.println("Return SPACE EVENT"); return XMLEvent.SPACE; }else return XMLEvent.CHARACTERS; } else{ ! bufferContent(); } if (c == '\r') { if(DEBUG){ System.out.println("'\r' character found"); }
*** 2967,2977 **** //set it back to false. fEmptyElement = false; setScannerState(SCANNER_STATE_CONTENT); //check the case when there is comment after single element document //<foo/> and some comment after this ! return (fMarkupDepth == 0 && elementDepthIsZeroHook() ) ? XMLEvent.END_ELEMENT : XMLEvent.END_ELEMENT ; } else if(scanEndElement() == 0) { //It is last element of the document if (elementDepthIsZeroHook()) { //if element depth is zero , it indicates the end of the document --- 2871,2882 ---- //set it back to false. fEmptyElement = false; setScannerState(SCANNER_STATE_CONTENT); //check the case when there is comment after single element document //<foo/> and some comment after this ! return (fMarkupDepth == 0 && elementDepthIsZeroHook() ) ? ! XMLEvent.END_ELEMENT : XMLEvent.END_ELEMENT ; } else if(scanEndElement() == 0) { //It is last element of the document if (elementDepthIsZeroHook()) { //if element depth is zero , it indicates the end of the document
*** 3091,3101 **** continue; } if(fScannerState == SCANNER_STATE_REFERENCE){ setScannerState(SCANNER_STATE_CONTENT); ! if (fReplaceEntityReferences && fEntityStore.isDeclaredEntity(fCurrentEntityName)) { // Skip the entity reference, we don't care continue; } return XMLEvent.ENTITY_REFERENCE; } --- 2996,3007 ---- continue; } if(fScannerState == SCANNER_STATE_REFERENCE){ setScannerState(SCANNER_STATE_CONTENT); ! if (fReplaceEntityReferences && ! fEntityStore.isDeclaredEntity(fCurrentEntityName)) { // Skip the entity reference, we don't care continue; } return XMLEvent.ENTITY_REFERENCE; }
*** 3124,3134 **** } else { while (isValidNameChar(fEntityScanner.peekChar())) { fStringBuffer.append((char)fEntityScanner.scanChar(null)); } } ! String target = fSymbolTable.addSymbol(fStringBuffer.ch, fStringBuffer.offset, fStringBuffer.length); fContentBuffer.clear(); scanPIData(target, fContentBuffer); } // standard text declaration --- 3030,3041 ---- } else { while (isValidNameChar(fEntityScanner.peekChar())) { fStringBuffer.append((char)fEntityScanner.scanChar(null)); } } ! String target = fSymbolTable.addSymbol(fStringBuffer.ch, ! fStringBuffer.offset, fStringBuffer.length); fContentBuffer.clear(); scanPIData(target, fContentBuffer); } // standard text declaration
*** 3267,3277 **** * * @return XMLString XMLString used to store an attribute value. */ protected XMLString getString(){ ! if(fAttributeCacheUsedCount < initialCacheCount || fAttributeCacheUsedCount < attributeValueCache.size()){ return attributeValueCache.get(fAttributeCacheUsedCount++); } else{ XMLString str = new XMLString(); fAttributeCacheUsedCount++; attributeValueCache.add(str); --- 3174,3185 ---- * * @return XMLString XMLString used to store an attribute value. */ protected XMLString getString(){ ! if(fAttributeCacheUsedCount < initialCacheCount || ! fAttributeCacheUsedCount < attributeValueCache.size()){ return attributeValueCache.get(fAttributeCacheUsedCount++); } else{ XMLString str = new XMLString(); fAttributeCacheUsedCount++; attributeValueCache.add(str);
*** 3297,3311 **** //cache available attributes. if(fReadingAttributes){ fAttributes.refresh(); } if(fScannerState == SCANNER_STATE_CHARACTER_DATA){ ! //since fTempString directly matches to the underlying main buffer ! //store the data into buffer fContentBuffer.append(fTempString); //clear the XMLString so that data can't be added again. fTempString.length = 0; fUsebuffer = true; } - } - } // class XMLDocumentFragmentScannerImpl --- 3205,3226 ---- //cache available attributes. if(fReadingAttributes){ fAttributes.refresh(); } if(fScannerState == SCANNER_STATE_CHARACTER_DATA){ ! bufferContent(); ! } ! } ! ! /** ! * Since 'TempString' shares the buffer (a char array) with the CurrentEntity, ! * when the cursor position reaches the end, that is, before the buffer is ! * being loaded with new data, the content in the TempString needs to be ! * copied into the ContentBuffer. ! */ ! private void bufferContent() { fContentBuffer.append(fTempString); //clear the XMLString so that data can't be added again. fTempString.length = 0; fUsebuffer = true; } } // class XMLDocumentFragmentScannerImpl
< prev index next >