--- old/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java 2015-09-30 14:27:40.696438489 -0700 +++ new/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java 2015-09-30 14:27:40.544430930 -0700 @@ -1,13 +1,14 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. */ /* - * Copyright 2005 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -18,7 +19,6 @@ * limitations under the License. */ - package com.sun.org.apache.xerces.internal.impl; import com.sun.xml.internal.stream.XMLBufferListener; @@ -403,6 +403,9 @@ protected boolean fAdd = false ; protected boolean fSkip = false; + //indicates whether the parsing process should be stopped + private boolean stopProcess = false; + /** Reusable Augmentations. */ private Augmentations fTempAugmentations = null; // @@ -507,9 +510,11 @@ throw new InternalError("processing event: " + event); } - //System.out.println("here in before calling next"); + + if (stopProcess) { + break; + } event = next(); - //System.out.println("here in after calling next"); } while (event!=XMLStreamConstants.END_DOCUMENT && complete); if(event == XMLStreamConstants.END_DOCUMENT) { @@ -521,7 +526,31 @@ } // scanDocument(boolean):boolean + /** + * Stops the parsing process. + */ + @Override + public boolean stop() { + return stopProcess = true; + } + /** + * Resumes parsing after it was stopped by calling the stop method. + */ + @Override + public boolean resume() { + //resume only if the process was stopped. + if (stopProcess) { + stopProcess = false; + try { + scanDocument(true); + return true; + } catch (IOException | XNIException ex) { + //can not resume the parsing process, do nothing. + } + } + return false; + } public com.sun.org.apache.xerces.internal.xni.QName getElementQName(){ if(fScannerLastState == XMLEvent.END_ELEMENT){ @@ -655,6 +684,7 @@ fShouldSkip = false; fAdd = false; fSkip = false; + stopProcess = false; fEntityStore = fEntityManager.getEntityStore(); dtdGrammarUtil = null;