Java Code Examples for javax.xml.stream.events.XMLEvent#START_DOCUMENT

The following examples show how to use javax.xml.stream.events.XMLEvent#START_DOCUMENT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XMLDocumentScannerImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public int next() throws IOException, XNIException {

            // next driver is prolog regardless of whether there
            // is an XMLDecl in this document
            setScannerState(SCANNER_STATE_PROLOG);
            setDriver(fPrologDriver);

            //System.out.println("fEntityScanner = " + fEntityScanner);
            // scan XMLDecl
            try {
                if (fEntityScanner.skipString(XMLDECL)) {
                    if (XMLChar.isSpace(fEntityScanner.peekChar())) {
                        fMarkupDepth++;
                        scanXMLDeclOrTextDecl(false);
                    } else {
                        // PI, reset position
                        fEntityManager.fCurrentEntity.position = 0;
                    }
                }

                //START_OF_THE_DOCUMENT
                fEntityManager.fCurrentEntity.mayReadChunks = true;
                return XMLEvent.START_DOCUMENT;

            }

            // premature end of file
            catch (EOFException e) {
                reportFatalError("PrematureEOF", null);
                return -1;
                //throw e;
            }

        }
 
Example 2
Source File: XMLStreamReaderImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
final static String getEventTypeString(int eventType) {
    switch (eventType){
        case XMLEvent.START_ELEMENT:
            return "START_ELEMENT";
        case XMLEvent.END_ELEMENT:
            return "END_ELEMENT";
        case XMLEvent.PROCESSING_INSTRUCTION:
            return "PROCESSING_INSTRUCTION";
        case XMLEvent.CHARACTERS:
            return "CHARACTERS";
        case XMLEvent.COMMENT:
            return "COMMENT";
        case XMLEvent.START_DOCUMENT:
            return "START_DOCUMENT";
        case XMLEvent.END_DOCUMENT:
            return "END_DOCUMENT";
        case XMLEvent.ENTITY_REFERENCE:
            return "ENTITY_REFERENCE";
        case XMLEvent.ATTRIBUTE:
            return "ATTRIBUTE";
        case XMLEvent.DTD:
            return "DTD";
        case XMLEvent.CDATA:
            return "CDATA";
        case XMLEvent.SPACE:
            return "SPACE";
    }
    return "UNKNOWN_EVENT_TYPE, " + String.valueOf(eventType);
}
 
Example 3
Source File: XMLStreamReaderImpl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
final static String getEventTypeString(int eventType) {
    switch (eventType){
        case XMLEvent.START_ELEMENT:
            return "START_ELEMENT";
        case XMLEvent.END_ELEMENT:
            return "END_ELEMENT";
        case XMLEvent.PROCESSING_INSTRUCTION:
            return "PROCESSING_INSTRUCTION";
        case XMLEvent.CHARACTERS:
            return "CHARACTERS";
        case XMLEvent.COMMENT:
            return "COMMENT";
        case XMLEvent.START_DOCUMENT:
            return "START_DOCUMENT";
        case XMLEvent.END_DOCUMENT:
            return "END_DOCUMENT";
        case XMLEvent.ENTITY_REFERENCE:
            return "ENTITY_REFERENCE";
        case XMLEvent.ATTRIBUTE:
            return "ATTRIBUTE";
        case XMLEvent.DTD:
            return "DTD";
        case XMLEvent.CDATA:
            return "CDATA";
        case XMLEvent.SPACE:
            return "SPACE";
    }
    return "UNKNOWN_EVENT_TYPE, " + String.valueOf(eventType);
}
 
Example 4
Source File: XMLStreamReaderImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
final static String getEventTypeString(int eventType) {
    switch (eventType){
        case XMLEvent.START_ELEMENT:
            return "START_ELEMENT";
        case XMLEvent.END_ELEMENT:
            return "END_ELEMENT";
        case XMLEvent.PROCESSING_INSTRUCTION:
            return "PROCESSING_INSTRUCTION";
        case XMLEvent.CHARACTERS:
            return "CHARACTERS";
        case XMLEvent.COMMENT:
            return "COMMENT";
        case XMLEvent.START_DOCUMENT:
            return "START_DOCUMENT";
        case XMLEvent.END_DOCUMENT:
            return "END_DOCUMENT";
        case XMLEvent.ENTITY_REFERENCE:
            return "ENTITY_REFERENCE";
        case XMLEvent.ATTRIBUTE:
            return "ATTRIBUTE";
        case XMLEvent.DTD:
            return "DTD";
        case XMLEvent.CDATA:
            return "CDATA";
        case XMLEvent.SPACE:
            return "SPACE";
    }
    return "UNKNOWN_EVENT_TYPE, " + String.valueOf(eventType);
}
 
Example 5
Source File: XMLStreamReaderImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
final static String getEventTypeString(int eventType) {
    switch (eventType){
        case XMLEvent.START_ELEMENT:
            return "START_ELEMENT";
        case XMLEvent.END_ELEMENT:
            return "END_ELEMENT";
        case XMLEvent.PROCESSING_INSTRUCTION:
            return "PROCESSING_INSTRUCTION";
        case XMLEvent.CHARACTERS:
            return "CHARACTERS";
        case XMLEvent.COMMENT:
            return "COMMENT";
        case XMLEvent.START_DOCUMENT:
            return "START_DOCUMENT";
        case XMLEvent.END_DOCUMENT:
            return "END_DOCUMENT";
        case XMLEvent.ENTITY_REFERENCE:
            return "ENTITY_REFERENCE";
        case XMLEvent.ATTRIBUTE:
            return "ATTRIBUTE";
        case XMLEvent.DTD:
            return "DTD";
        case XMLEvent.CDATA:
            return "CDATA";
        case XMLEvent.SPACE:
            return "SPACE";
    }
    return "UNKNOWN_EVENT_TYPE, " + String.valueOf(eventType);
}
 
Example 6
Source File: XMLStreamReaderImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
final static String getEventTypeString(int eventType) {
    switch (eventType){
        case XMLEvent.START_ELEMENT:
            return "START_ELEMENT";
        case XMLEvent.END_ELEMENT:
            return "END_ELEMENT";
        case XMLEvent.PROCESSING_INSTRUCTION:
            return "PROCESSING_INSTRUCTION";
        case XMLEvent.CHARACTERS:
            return "CHARACTERS";
        case XMLEvent.COMMENT:
            return "COMMENT";
        case XMLEvent.START_DOCUMENT:
            return "START_DOCUMENT";
        case XMLEvent.END_DOCUMENT:
            return "END_DOCUMENT";
        case XMLEvent.ENTITY_REFERENCE:
            return "ENTITY_REFERENCE";
        case XMLEvent.ATTRIBUTE:
            return "ATTRIBUTE";
        case XMLEvent.DTD:
            return "DTD";
        case XMLEvent.CDATA:
            return "CDATA";
        case XMLEvent.SPACE:
            return "SPACE";
    }
    return "UNKNOWN_EVENT_TYPE, " + String.valueOf(eventType);
}
 
Example 7
Source File: XMLStreamReaderImpl.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
final static String getEventTypeString(int eventType) {
    switch (eventType){
        case XMLEvent.START_ELEMENT:
            return "START_ELEMENT";
        case XMLEvent.END_ELEMENT:
            return "END_ELEMENT";
        case XMLEvent.PROCESSING_INSTRUCTION:
            return "PROCESSING_INSTRUCTION";
        case XMLEvent.CHARACTERS:
            return "CHARACTERS";
        case XMLEvent.COMMENT:
            return "COMMENT";
        case XMLEvent.START_DOCUMENT:
            return "START_DOCUMENT";
        case XMLEvent.END_DOCUMENT:
            return "END_DOCUMENT";
        case XMLEvent.ENTITY_REFERENCE:
            return "ENTITY_REFERENCE";
        case XMLEvent.ATTRIBUTE:
            return "ATTRIBUTE";
        case XMLEvent.DTD:
            return "DTD";
        case XMLEvent.CDATA:
            return "CDATA";
        case XMLEvent.SPACE:
            return "SPACE";
    }
    return "UNKNOWN_EVENT_TYPE, " + String.valueOf(eventType);
}
 
Example 8
Source File: PubmedParser.java    From act with GNU General Public License v3.0 4 votes vote down vote up
private void getNextTagData() throws XMLStreamException {
  int eventType = this.xml.next();
  switch (eventType) {
    case XMLEvent.START_ELEMENT:
      System.out.println("START_ELEMENT: " + this.xml.getLocalName());
      return;
    case XMLEvent.END_ELEMENT:
      System.out.println("END_ELEMENT: " + this.xml.getLocalName());
      return;
    case XMLEvent.PROCESSING_INSTRUCTION:
      System.out.println("PROCESSING_INSTRUCTION: " + this.xml.getLocalName());
      return;
    case XMLEvent.CHARACTERS:
      System.out.println("CHARACTERS: " + this.xml.getText());
      return;
    case XMLEvent.COMMENT:
      System.out.println("COMMENT: " + this.xml.getText());
      return;
    case XMLEvent.START_DOCUMENT:
      System.out.println("START_DOCUMENT: " + this.xml.getLocalName());
      return;
    case XMLEvent.END_DOCUMENT:
      System.out.println("END_DOCUMENT: " + this.xml.getLocalName());
      return;
    case XMLEvent.ENTITY_REFERENCE:
      System.out.println("ENTITY_REFERENCE: " + this.xml.getLocalName());
      return;
    case XMLEvent.ATTRIBUTE:
      System.out.println("ATTRIBUTE: " + this.xml.getLocalName());
      return;
    case XMLEvent.DTD:
      System.out.println("DTD");
      return;
    case XMLEvent.CDATA:
      System.out.println("CDATA");
      return;
    case XMLEvent.SPACE:
      System.out.println("SPACE");
      return;
  }
  System.out.println("Something else...");
}
 
Example 9
Source File: StAXEventAllocatorBase.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
XMLEvent getXMLEvent(XMLStreamReader reader){
    XMLEvent event = null;
    //returns the current event
    int eventType = reader.getEventType();
    //this needs to be set before creating events
    factory.setLocation(reader.getLocation());
    switch(eventType){

        case XMLEvent.START_ELEMENT:
        {
            StartElementEvent startElement = (StartElementEvent)factory.createStartElement(reader.getPrefix(),
                                reader.getNamespaceURI(), reader.getLocalName());

            addAttributes(startElement,reader);
            addNamespaces(startElement, reader);
            //need to fix it along with the Reader
            //setNamespaceContext(startElement,reader);
            event = startElement;
            break;
        }
        case XMLEvent.END_ELEMENT:
        {
            EndElementEvent endElement = (EndElementEvent)factory.createEndElement(
                    reader.getPrefix(), reader.getNamespaceURI(), reader.getLocalName());
            addNamespaces(endElement,reader);
            event = endElement ;
            break;
        }
        case XMLEvent.PROCESSING_INSTRUCTION:
        {
            event = factory.createProcessingInstruction(reader.getPITarget(),reader.getPIData());
            break;
        }
        case XMLEvent.CHARACTERS:
        {
            if (reader.isWhiteSpace())
              event = factory.createSpace(reader.getText());
            else
              event = factory.createCharacters(reader.getText());

            break;
        }
        case XMLEvent.COMMENT:
        {
            event = factory.createComment(reader.getText());
            break;
        }
        case XMLEvent.START_DOCUMENT:
        {
            StartDocumentEvent docEvent = (StartDocumentEvent)factory.createStartDocument(
                    reader.getVersion(), reader.getEncoding(), reader.isStandalone());
            if(reader.getCharacterEncodingScheme() != null){
                docEvent.setDeclaredEncoding(true);
            }else{
                docEvent.setDeclaredEncoding(false);
            }
            event = docEvent ;
            break;
        }
        case XMLEvent.END_DOCUMENT:{
            EndDocumentEvent endDocumentEvent = new EndDocumentEvent() ;
            event = endDocumentEvent ;
            break;
        }
        case XMLEvent.ENTITY_REFERENCE:{
            event = factory.createEntityReference(reader.getLocalName(),
                    new EntityDeclarationImpl(reader.getLocalName(),reader.getText()));
            break;

        }
        case XMLEvent.ATTRIBUTE:{
            event = null ;
            break;
        }
        case XMLEvent.DTD:{
            event = factory.createDTD(reader.getText());
            break;
        }
        case XMLEvent.CDATA:{
            event = factory.createCData(reader.getText());
            break;
        }
        case XMLEvent.SPACE:{
            event = factory.createSpace(reader.getText());
            break;
        }
    }
    return event ;
}
 
Example 10
Source File: XMLDocumentScannerImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public int next() throws IOException, XNIException {
    if(DEBUG_NEXT){
        System.out.println("NOW IN XMLDeclDriver");
    }

    // next driver is prolog regardless of whether there
    // is an XMLDecl in this document
    setScannerState(SCANNER_STATE_PROLOG);
    setDriver(fPrologDriver);

    //System.out.println("fEntityScanner = " + fEntityScanner);
    // scan XMLDecl
    try {
        if (fEntityScanner.skipString(xmlDecl)) {
            fMarkupDepth++;
            // NOTE: special case where document starts with a PI
            //       whose name starts with "xml" (e.g. "xmlfoo")
            if (XMLChar.isName(fEntityScanner.peekChar())) {
                fStringBuffer.clear();
                fStringBuffer.append("xml");
                while (XMLChar.isName(fEntityScanner.peekChar())) {
                    fStringBuffer.append((char)fEntityScanner.scanChar(null));
                }
                String target = fSymbolTable.addSymbol(fStringBuffer.ch, fStringBuffer.offset, fStringBuffer.length);
                //this function should fill the data.. and set the fEvent object to this event.
                fContentBuffer.clear() ;
                scanPIData(target, fContentBuffer);
                //REVISIT:where else we can set this value to 'true'
                fEntityManager.fCurrentEntity.mayReadChunks = true;
                //return PI event since PI was encountered
                return XMLEvent.PROCESSING_INSTRUCTION ;
            }
            // standard XML declaration
            else {
                scanXMLDeclOrTextDecl(false);
                //REVISIT:where else we can set this value to 'true'
                fEntityManager.fCurrentEntity.mayReadChunks = true;
                return XMLEvent.START_DOCUMENT;
            }
        } else{
            //REVISIT:where else we can set this value to 'true'
            fEntityManager.fCurrentEntity.mayReadChunks = true;
            //In both case return the START_DOCUMENT. ony difference is that first block will
            //cosume the XML declaration if any.
            return XMLEvent.START_DOCUMENT;
        }


        //START_OF_THE_DOCUMENT


    }

    // premature end of file
    catch (EOFException e) {
        reportFatalError("PrematureEOF", null);
        return -1;
        //throw e;
    }

}
 
Example 11
Source File: DummyEvent.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public boolean isStartDocument() {
    return fEventType == XMLEvent.START_DOCUMENT;
}
 
Example 12
Source File: XMLDocumentScannerImpl.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public int next() throws IOException, XNIException {
    if(DEBUG_NEXT){
        System.out.println("NOW IN XMLDeclDriver");
    }

    // next driver is prolog regardless of whether there
    // is an XMLDecl in this document
    setScannerState(SCANNER_STATE_PROLOG);
    setDriver(fPrologDriver);

    //System.out.println("fEntityScanner = " + fEntityScanner);
    // scan XMLDecl
    try {
        if (fEntityScanner.skipString(xmlDecl)) {
            fMarkupDepth++;
            // NOTE: special case where document starts with a PI
            //       whose name starts with "xml" (e.g. "xmlfoo")
            if (XMLChar.isName(fEntityScanner.peekChar())) {
                fStringBuffer.clear();
                fStringBuffer.append("xml");
                while (XMLChar.isName(fEntityScanner.peekChar())) {
                    fStringBuffer.append((char)fEntityScanner.scanChar());
                }
                String target = fSymbolTable.addSymbol(fStringBuffer.ch, fStringBuffer.offset, fStringBuffer.length);
                //this function should fill the data.. and set the fEvent object to this event.
                fContentBuffer.clear() ;
                scanPIData(target, fContentBuffer);
                //REVISIT:where else we can set this value to 'true'
                fEntityManager.fCurrentEntity.mayReadChunks = true;
                //return PI event since PI was encountered
                return XMLEvent.PROCESSING_INSTRUCTION ;
            }
            // standard XML declaration
            else {
                scanXMLDeclOrTextDecl(false);
                //REVISIT:where else we can set this value to 'true'
                fEntityManager.fCurrentEntity.mayReadChunks = true;
                return XMLEvent.START_DOCUMENT;
            }
        } else{
            //REVISIT:where else we can set this value to 'true'
            fEntityManager.fCurrentEntity.mayReadChunks = true;
            //In both case return the START_DOCUMENT. ony difference is that first block will
            //cosume the XML declaration if any.
            return XMLEvent.START_DOCUMENT;
        }


        //START_OF_THE_DOCUMENT


    }

    // premature end of file
    catch (EOFException e) {
        reportFatalError("PrematureEOF", null);
        return -1;
        //throw e;
    }

}
 
Example 13
Source File: StAXEventAllocatorBase.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
XMLEvent getXMLEvent(XMLStreamReader reader){
    XMLEvent event = null;
    //returns the current event
    int eventType = reader.getEventType();
    //this needs to be set before creating events
    factory.setLocation(reader.getLocation());
    switch(eventType){

        case XMLEvent.START_ELEMENT:
        {
            StartElementEvent startElement = (StartElementEvent)factory.createStartElement(reader.getPrefix(),
                                reader.getNamespaceURI(), reader.getLocalName());

            addAttributes(startElement,reader);
            addNamespaces(startElement, reader);
            //need to fix it along with the Reader
            //setNamespaceContext(startElement,reader);
            event = startElement;
            break;
        }
        case XMLEvent.END_ELEMENT:
        {
            EndElementEvent endElement = (EndElementEvent)factory.createEndElement(
                    reader.getPrefix(), reader.getNamespaceURI(), reader.getLocalName());
            addNamespaces(endElement,reader);
            event = endElement ;
            break;
        }
        case XMLEvent.PROCESSING_INSTRUCTION:
        {
            event = factory.createProcessingInstruction(reader.getPITarget(),reader.getPIData());
            break;
        }
        case XMLEvent.CHARACTERS:
        {
            if (reader.isWhiteSpace())
              event = factory.createSpace(reader.getText());
            else
              event = factory.createCharacters(reader.getText());

            break;
        }
        case XMLEvent.COMMENT:
        {
            event = factory.createComment(reader.getText());
            break;
        }
        case XMLEvent.START_DOCUMENT:
        {
            StartDocumentEvent docEvent = (StartDocumentEvent)factory.createStartDocument(
                    reader.getVersion(), reader.getEncoding(), reader.isStandalone());
            if(reader.getCharacterEncodingScheme() != null){
                docEvent.setDeclaredEncoding(true);
            }else{
                docEvent.setDeclaredEncoding(false);
            }
            event = docEvent ;
            break;
        }
        case XMLEvent.END_DOCUMENT:{
            EndDocumentEvent endDocumentEvent = new EndDocumentEvent() ;
            event = endDocumentEvent ;
            break;
        }
        case XMLEvent.ENTITY_REFERENCE:{
            event = factory.createEntityReference(reader.getLocalName(),
                    new EntityDeclarationImpl(reader.getLocalName(),reader.getText()));
            break;

        }
        case XMLEvent.ATTRIBUTE:{
            event = null ;
            break;
        }
        case XMLEvent.DTD:{
            event = factory.createDTD(reader.getText());
            break;
        }
        case XMLEvent.CDATA:{
            event = factory.createCData(reader.getText());
            break;
        }
        case XMLEvent.SPACE:{
            event = factory.createSpace(reader.getText());
            break;
        }
    }
    return event ;
}
 
Example 14
Source File: XMLDocumentScannerImpl.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
public int next() throws IOException, XNIException {
    if(DEBUG_NEXT){
        System.out.println("NOW IN XMLDeclDriver");
    }

    // next driver is prolog regardless of whether there
    // is an XMLDecl in this document
    setScannerState(SCANNER_STATE_PROLOG);
    setDriver(fPrologDriver);

    //System.out.println("fEntityScanner = " + fEntityScanner);
    // scan XMLDecl
    try {
        if (fEntityScanner.skipString(xmlDecl)) {
            fMarkupDepth++;
            // NOTE: special case where document starts with a PI
            //       whose name starts with "xml" (e.g. "xmlfoo")
            if (XMLChar.isName(fEntityScanner.peekChar())) {
                fStringBuffer.clear();
                fStringBuffer.append("xml");
                while (XMLChar.isName(fEntityScanner.peekChar())) {
                    fStringBuffer.append((char)fEntityScanner.scanChar(null));
                }
                String target = fSymbolTable.addSymbol(fStringBuffer.ch, fStringBuffer.offset, fStringBuffer.length);
                //this function should fill the data.. and set the fEvent object to this event.
                fContentBuffer.clear() ;
                scanPIData(target, fContentBuffer);
                //REVISIT:where else we can set this value to 'true'
                fEntityManager.fCurrentEntity.mayReadChunks = true;
                //return PI event since PI was encountered
                return XMLEvent.PROCESSING_INSTRUCTION ;
            }
            // standard XML declaration
            else {
                scanXMLDeclOrTextDecl(false);
                //REVISIT:where else we can set this value to 'true'
                fEntityManager.fCurrentEntity.mayReadChunks = true;
                return XMLEvent.START_DOCUMENT;
            }
        } else{
            //REVISIT:where else we can set this value to 'true'
            fEntityManager.fCurrentEntity.mayReadChunks = true;
            //In both case return the START_DOCUMENT. ony difference is that first block will
            //cosume the XML declaration if any.
            return XMLEvent.START_DOCUMENT;
        }


        //START_OF_THE_DOCUMENT


    }

    // premature end of file
    catch (EOFException e) {
        reportFatalError("PrematureEOF", null);
        return -1;
        //throw e;
    }

}
 
Example 15
Source File: StAXEventAllocatorBase.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
XMLEvent getXMLEvent(XMLStreamReader reader){
    XMLEvent event = null;
    //returns the current event
    int eventType = reader.getEventType();
    //this needs to be set before creating events
    factory.setLocation(reader.getLocation());
    switch(eventType){

        case XMLEvent.START_ELEMENT:
        {
            StartElementEvent startElement = (StartElementEvent)factory.createStartElement(reader.getPrefix(),
                                reader.getNamespaceURI(), reader.getLocalName());

            addAttributes(startElement,reader);
            addNamespaces(startElement, reader);
            //need to fix it along with the Reader
            //setNamespaceContext(startElement,reader);
            event = startElement;
            break;
        }
        case XMLEvent.END_ELEMENT:
        {
            EndElementEvent endElement = (EndElementEvent)factory.createEndElement(
                    reader.getPrefix(), reader.getNamespaceURI(), reader.getLocalName());
            addNamespaces(endElement,reader);
            event = endElement ;
            break;
        }
        case XMLEvent.PROCESSING_INSTRUCTION:
        {
            event = factory.createProcessingInstruction(reader.getPITarget(),reader.getPIData());
            break;
        }
        case XMLEvent.CHARACTERS:
        {
            if (reader.isWhiteSpace())
              event = factory.createSpace(reader.getText());
            else
              event = factory.createCharacters(reader.getText());

            break;
        }
        case XMLEvent.COMMENT:
        {
            event = factory.createComment(reader.getText());
            break;
        }
        case XMLEvent.START_DOCUMENT:
        {
            StartDocumentEvent docEvent = (StartDocumentEvent)factory.createStartDocument(
                    reader.getVersion(), reader.getEncoding(), reader.isStandalone());
            if(reader.getCharacterEncodingScheme() != null){
                docEvent.setDeclaredEncoding(true);
            }else{
                docEvent.setDeclaredEncoding(false);
            }
            event = docEvent ;
            break;
        }
        case XMLEvent.END_DOCUMENT:{
            EndDocumentEvent endDocumentEvent = new EndDocumentEvent() ;
            event = endDocumentEvent ;
            break;
        }
        case XMLEvent.ENTITY_REFERENCE:{
            event = factory.createEntityReference(reader.getLocalName(),
                    new EntityDeclarationImpl(reader.getLocalName(),reader.getText()));
            break;

        }
        case XMLEvent.ATTRIBUTE:{
            event = null ;
            break;
        }
        case XMLEvent.DTD:{
            event = factory.createDTD(reader.getText());
            break;
        }
        case XMLEvent.CDATA:{
            event = factory.createCData(reader.getText());
            break;
        }
        case XMLEvent.SPACE:{
            event = factory.createSpace(reader.getText());
            break;
        }
    }
    return event ;
}
 
Example 16
Source File: XMLDocumentScannerImpl.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public int next() throws IOException, XNIException {
    if(DEBUG_NEXT){
        System.out.println("NOW IN XMLDeclDriver");
    }

    // next driver is prolog regardless of whether there
    // is an XMLDecl in this document
    setScannerState(SCANNER_STATE_PROLOG);
    setDriver(fPrologDriver);

    //System.out.println("fEntityScanner = " + fEntityScanner);
    // scan XMLDecl
    try {
        if (fEntityScanner.skipString(xmlDecl)) {
            fMarkupDepth++;
            // NOTE: special case where document starts with a PI
            //       whose name starts with "xml" (e.g. "xmlfoo")
            if (XMLChar.isName(fEntityScanner.peekChar())) {
                fStringBuffer.clear();
                fStringBuffer.append("xml");
                while (XMLChar.isName(fEntityScanner.peekChar())) {
                    fStringBuffer.append((char)fEntityScanner.scanChar());
                }
                String target = fSymbolTable.addSymbol(fStringBuffer.ch, fStringBuffer.offset, fStringBuffer.length);
                //this function should fill the data.. and set the fEvent object to this event.
                fContentBuffer.clear() ;
                scanPIData(target, fContentBuffer);
                //REVISIT:where else we can set this value to 'true'
                fEntityManager.fCurrentEntity.mayReadChunks = true;
                //return PI event since PI was encountered
                return XMLEvent.PROCESSING_INSTRUCTION ;
            }
            // standard XML declaration
            else {
                scanXMLDeclOrTextDecl(false);
                //REVISIT:where else we can set this value to 'true'
                fEntityManager.fCurrentEntity.mayReadChunks = true;
                return XMLEvent.START_DOCUMENT;
            }
        } else{
            //REVISIT:where else we can set this value to 'true'
            fEntityManager.fCurrentEntity.mayReadChunks = true;
            //In both case return the START_DOCUMENT. ony difference is that first block will
            //cosume the XML declaration if any.
            return XMLEvent.START_DOCUMENT;
        }


        //START_OF_THE_DOCUMENT


    }

    // premature end of file
    catch (EOFException e) {
        reportFatalError("PrematureEOF", null);
        return -1;
        //throw e;
    }

}
 
Example 17
Source File: DummyEvent.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public boolean isStartDocument() {
    return fEventType == XMLEvent.START_DOCUMENT;
}
 
Example 18
Source File: DummyEvent.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public boolean isStartDocument() {
    return fEventType == XMLEvent.START_DOCUMENT;
}
 
Example 19
Source File: DummyEvent.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public boolean isStartDocument() {
    return fEventType == XMLEvent.START_DOCUMENT;
}
 
Example 20
Source File: XmlUtils.java    From entity-fishing with Apache License 2.0 2 votes vote down vote up
/**
 * Compares two {@link XMLEvent} instances. This method delegates actual
 * matching to the appropriate overloaded method.
 * 
 * @param a
 *            The first event.
 * @param b
 *            The second event.
 * @return <code>true</code> if the events match, <code>false</code>
 *         otherwise.
 */
public static boolean eventsMatch(XMLEvent a, XMLEvent b) {

	if (a == b) {

		return true;

	} else if (a == null || b == null) {

		return false;

	} else if (a.getEventType() == b.getEventType()) {

		switch (a.getEventType()) {

		case XMLEvent.START_ELEMENT:
			return eventsMatch(a.asStartElement(), b.asStartElement());

		case XMLEvent.END_ELEMENT:
			return eventsMatch(a.asEndElement(), b.asEndElement());

		case XMLEvent.CDATA:
		case XMLEvent.SPACE:
		case XMLEvent.CHARACTERS:
			return eventsMatch(a.asCharacters(), b.asCharacters());

		case XMLEvent.COMMENT:
			return eventsMatch((Comment) a, (Comment) b);

		case XMLEvent.ENTITY_REFERENCE:
			return eventsMatch((EntityReference) a, (EntityReference) b);

		case XMLEvent.ATTRIBUTE:
			return eventsMatch((Attribute) a, (Attribute) b);

		case XMLEvent.NAMESPACE:
			return eventsMatch((Namespace) a, (Namespace) b);

		case XMLEvent.START_DOCUMENT:
			return eventsMatch((StartDocument) a, (StartDocument) b);

		case XMLEvent.END_DOCUMENT:
			return eventsMatch((EndDocument) a, (EndDocument) b);

		case XMLEvent.PROCESSING_INSTRUCTION:
			return eventsMatch((ProcessingInstruction) a, (ProcessingInstruction) b);

		case XMLEvent.DTD:
			return eventsMatch((DTD) a, (DTD) b);

		case XMLEvent.ENTITY_DECLARATION:
			return eventsMatch((EntityDeclaration) a, (EntityDeclaration) b);

		case XMLEvent.NOTATION_DECLARATION:
			return eventsMatch((NotationDeclaration) a, (NotationDeclaration) b);

		}

	}

	return false;

}