javax.xml.stream.events.ProcessingInstruction Java Examples
The following examples show how to use
javax.xml.stream.events.ProcessingInstruction.
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: XMLEventStreamReader.java From java-technology-stack with MIT License | 5 votes |
@Override public String getPIData() { if (this.event.isProcessingInstruction()) { return ((ProcessingInstruction) this.event).getData(); } else { throw new IllegalStateException(); } }
Example #2
Source File: StAXEvent2SAX.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private void handlePI(ProcessingInstruction event) throws XMLStreamException { try { _sax.processingInstruction( event.getTarget(), event.getData()); } catch (SAXException e) { throw new XMLStreamException(e); } }
Example #3
Source File: XMLEventStreamReader.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public String getPIData() { if (this.event.isProcessingInstruction()) { return ((ProcessingInstruction) this.event).getData(); } else { throw new IllegalStateException(); } }
Example #4
Source File: XMLEventStreamReader.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public String getPITarget() { if (this.event.isProcessingInstruction()) { return ((ProcessingInstruction) this.event).getTarget(); } else { throw new IllegalStateException(); } }
Example #5
Source File: StAXEvent2SAX.java From hottub with GNU General Public License v2.0 | 5 votes |
private void handlePI(ProcessingInstruction event) throws XMLStreamException { try { _sax.processingInstruction( event.getTarget(), event.getData()); } catch (SAXException e) { throw new XMLStreamException(e); } }
Example #6
Source File: StAXEvent2SAX.java From Bytecoder with Apache License 2.0 | 5 votes |
private void handlePI(ProcessingInstruction event) throws XMLStreamException { try { _sax.processingInstruction( event.getTarget(), event.getData()); } catch (SAXException e) { throw new XMLStreamException(e); } }
Example #7
Source File: StAXEvent2SAX.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private void handlePI(ProcessingInstruction event) throws XMLStreamException { try { _sax.processingInstruction( event.getTarget(), event.getData()); } catch (SAXException e) { throw new XMLStreamException(e); } }
Example #8
Source File: StAXEvent2SAX.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private void handlePI(ProcessingInstruction event) throws XMLStreamException { try { _sax.processingInstruction( event.getTarget(), event.getData()); } catch (SAXException e) { throw new XMLStreamException(e); } }
Example #9
Source File: StAXEvent2SAX.java From JDKSourceCode1.8 with MIT License | 5 votes |
private void handlePI(ProcessingInstruction event) throws XMLStreamException { try { _sax.processingInstruction( event.getTarget(), event.getData()); } catch (SAXException e) { throw new XMLStreamException(e); } }
Example #10
Source File: StAXEvent2SAX.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private void handlePI(ProcessingInstruction event) throws XMLStreamException { try { _sax.processingInstruction( event.getTarget(), event.getData()); } catch (SAXException e) { throw new XMLStreamException(e); } }
Example #11
Source File: XMLEventStreamReader.java From java-technology-stack with MIT License | 5 votes |
@Override public String getPITarget() { if (this.event.isProcessingInstruction()) { return ((ProcessingInstruction) this.event).getTarget(); } else { throw new IllegalStateException(); } }
Example #12
Source File: StAXEvent2SAX.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private void handlePI(ProcessingInstruction event) throws XMLStreamException { try { _sax.processingInstruction( event.getTarget(), event.getData()); } catch (SAXException e) { throw new XMLStreamException(e); } }
Example #13
Source File: XMLEventStreamReader.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override public String getPITarget() { if (this.event.isProcessingInstruction()) { return ((ProcessingInstruction) this.event).getTarget(); } else { throw new IllegalStateException(); } }
Example #14
Source File: XMLEventStreamReader.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override public String getPIData() { if (this.event.isProcessingInstruction()) { return ((ProcessingInstruction) this.event).getData(); } else { throw new IllegalStateException(); } }
Example #15
Source File: StAXEvent2SAX.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private void handlePI(ProcessingInstruction event) throws XMLStreamException { try { _sax.processingInstruction( event.getTarget(), event.getData()); } catch (SAXException e) { throw new XMLStreamException(e); } }
Example #16
Source File: StAXEvent2SAX.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private void handlePI(ProcessingInstruction event) throws XMLStreamException { try { _sax.processingInstruction( event.getTarget(), event.getData()); } catch (SAXException e) { throw new XMLStreamException(e); } }
Example #17
Source File: StAXEvent2SAX.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
private void handlePI(ProcessingInstruction event) throws XMLStreamException { try { _sax.processingInstruction( event.getTarget(), event.getData()); } catch (SAXException e) { throw new XMLStreamException(e); } }
Example #18
Source File: XMLEventStreamReader.java From spring-analysis-note with MIT License | 5 votes |
@Override public String getPIData() { if (this.event.isProcessingInstruction()) { return ((ProcessingInstruction) this.event).getData(); } else { throw new IllegalStateException(); } }
Example #19
Source File: XMLEventStreamReader.java From spring-analysis-note with MIT License | 5 votes |
@Override public String getPITarget() { if (this.event.isProcessingInstruction()) { return ((ProcessingInstruction) this.event).getTarget(); } else { throw new IllegalStateException(); } }
Example #20
Source File: XMLEventFactoryImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Override public ProcessingInstruction createProcessingInstruction(String target, String data) { ProcessingInstructionEvent event = new ProcessingInstructionEvent(target, data); if(location != null)event.setLocation(location); return event; }
Example #21
Source File: Issue41Test.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Test public void testEvents() { XMLEventFactory f = XMLEventFactory.newInstance(); final String contents = "test <some> text & more! [[]] --"; final String prefix = "prefix"; final String uri = "http://foo"; final String localName = "elem"; try { StartDocument sd = f.createStartDocument(); writeAsEncodedUnicode(sd); Comment c = f.createComment("some comments"); writeAsEncodedUnicode(c); StartElement se = f.createStartElement(prefix, uri, localName); ProcessingInstruction pi = f.createProcessingInstruction("target", "data"); writeAsEncodedUnicode(pi); Namespace ns = f.createNamespace(prefix, uri); writeAsEncodedUnicode(ns); Characters characters = f.createCharacters(contents); writeAsEncodedUnicode(characters); // CData Characters cdata = f.createCData(contents); writeAsEncodedUnicode(cdata); // Attribute QName attrName = new QName("http://test.com", "attr", "ns"); Attribute attr = f.createAttribute(attrName, "value"); writeAsEncodedUnicode(attr); // prefix, uri, localName EndElement ee = f.createEndElement(prefix, uri, localName); writeAsEncodedUnicode(ee); EndDocument ed = f.createEndDocument(); writeAsEncodedUnicode(ed); } catch (Exception e) { Assert.fail(e.getMessage()); } }
Example #22
Source File: XMLEventFactoryWrapper.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Override public ProcessingInstruction createProcessingInstruction(String target, String data) { return defaultImpl.createProcessingInstruction(target, data); }
Example #23
Source File: StaxEventXMLReader.java From spring-analysis-note with MIT License | 4 votes |
private void handleProcessingInstruction(ProcessingInstruction pi) throws SAXException { if (getContentHandler() != null) { getContentHandler().processingInstruction(pi.getTarget(), pi.getData()); } }
Example #24
Source File: XMLEventFactoryImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Override public ProcessingInstruction createProcessingInstruction(String target, String data) { return null; }
Example #25
Source File: StAXSchemaParser.java From hottub with GNU General Public License v2.0 | 4 votes |
public void parse(XMLEventReader input) throws XMLStreamException, XNIException { XMLEvent currentEvent = input.peek(); if (currentEvent != null) { int eventType = currentEvent.getEventType(); if (eventType != XMLStreamConstants.START_DOCUMENT && eventType != XMLStreamConstants.START_ELEMENT) { throw new XMLStreamException(); } fLocationWrapper.setLocation(currentEvent.getLocation()); fSchemaDOMParser.startDocument(fLocationWrapper, null, fNamespaceContext, null); loop: while (input.hasNext()) { currentEvent = input.nextEvent(); eventType = currentEvent.getEventType(); switch (eventType) { case XMLStreamConstants.START_ELEMENT: ++fDepth; StartElement start = currentEvent.asStartElement(); fillQName(fElementQName, start.getName()); fLocationWrapper.setLocation(start.getLocation()); fNamespaceContext.setNamespaceContext(start.getNamespaceContext()); fillXMLAttributes(start); fillDeclaredPrefixes(start); addNamespaceDeclarations(); fNamespaceContext.pushContext(); fSchemaDOMParser.startElement(fElementQName, fAttributes, null); break; case XMLStreamConstants.END_ELEMENT: EndElement end = currentEvent.asEndElement(); fillQName(fElementQName, end.getName()); fillDeclaredPrefixes(end); fLocationWrapper.setLocation(end.getLocation()); fSchemaDOMParser.endElement(fElementQName, null); fNamespaceContext.popContext(); --fDepth; if (fDepth <= 0) { break loop; } break; case XMLStreamConstants.CHARACTERS: sendCharactersToSchemaParser(currentEvent.asCharacters().getData(), false); break; case XMLStreamConstants.SPACE: sendCharactersToSchemaParser(currentEvent.asCharacters().getData(), true); break; case XMLStreamConstants.CDATA: fSchemaDOMParser.startCDATA(null); sendCharactersToSchemaParser(currentEvent.asCharacters().getData(), false); fSchemaDOMParser.endCDATA(null); break; case XMLStreamConstants.PROCESSING_INSTRUCTION: ProcessingInstruction pi = (ProcessingInstruction)currentEvent; fillProcessingInstruction(pi.getData()); fSchemaDOMParser.processingInstruction(pi.getTarget(), fTempString, null); break; case XMLStreamConstants.DTD: /* There shouldn't be a DTD in the schema */ break; case XMLStreamConstants.ENTITY_REFERENCE: /* Not needed for schemas */ break; case XMLStreamConstants.COMMENT: /* No point in sending comments */ break; case XMLStreamConstants.START_DOCUMENT: fDepth++; /* We automatically call startDocument before the loop */ break; case XMLStreamConstants.END_DOCUMENT: /* We automatically call endDocument after the loop */ break; } } fLocationWrapper.setLocation(null); fNamespaceContext.setNamespaceContext(null); fSchemaDOMParser.endDocument(null); } }
Example #26
Source File: StAXSchemaParser.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
public void parse(XMLEventReader input) throws XMLStreamException, XNIException { XMLEvent currentEvent = input.peek(); if (currentEvent != null) { int eventType = currentEvent.getEventType(); if (eventType != XMLStreamConstants.START_DOCUMENT && eventType != XMLStreamConstants.START_ELEMENT) { throw new XMLStreamException(); } fLocationWrapper.setLocation(currentEvent.getLocation()); fSchemaDOMParser.startDocument(fLocationWrapper, null, fNamespaceContext, null); loop: while (input.hasNext()) { currentEvent = input.nextEvent(); eventType = currentEvent.getEventType(); switch (eventType) { case XMLStreamConstants.START_ELEMENT: ++fDepth; StartElement start = currentEvent.asStartElement(); fillQName(fElementQName, start.getName()); fLocationWrapper.setLocation(start.getLocation()); fNamespaceContext.setNamespaceContext(start.getNamespaceContext()); fillXMLAttributes(start); fillDeclaredPrefixes(start); addNamespaceDeclarations(); fNamespaceContext.pushContext(); fSchemaDOMParser.startElement(fElementQName, fAttributes, null); break; case XMLStreamConstants.END_ELEMENT: EndElement end = currentEvent.asEndElement(); fillQName(fElementQName, end.getName()); fillDeclaredPrefixes(end); fLocationWrapper.setLocation(end.getLocation()); fSchemaDOMParser.endElement(fElementQName, null); fNamespaceContext.popContext(); --fDepth; if (fDepth <= 0) { break loop; } break; case XMLStreamConstants.CHARACTERS: sendCharactersToSchemaParser(currentEvent.asCharacters().getData(), false); break; case XMLStreamConstants.SPACE: sendCharactersToSchemaParser(currentEvent.asCharacters().getData(), true); break; case XMLStreamConstants.CDATA: fSchemaDOMParser.startCDATA(null); sendCharactersToSchemaParser(currentEvent.asCharacters().getData(), false); fSchemaDOMParser.endCDATA(null); break; case XMLStreamConstants.PROCESSING_INSTRUCTION: ProcessingInstruction pi = (ProcessingInstruction)currentEvent; fillProcessingInstruction(pi.getData()); fSchemaDOMParser.processingInstruction(pi.getTarget(), fTempString, null); break; case XMLStreamConstants.DTD: /* There shouldn't be a DTD in the schema */ break; case XMLStreamConstants.ENTITY_REFERENCE: /* Not needed for schemas */ break; case XMLStreamConstants.COMMENT: /* No point in sending comments */ break; case XMLStreamConstants.START_DOCUMENT: fDepth++; /* We automatically call startDocument before the loop */ break; case XMLStreamConstants.END_DOCUMENT: /* We automatically call endDocument after the loop */ break; } } fLocationWrapper.setLocation(null); fNamespaceContext.setNamespaceContext(null); fSchemaDOMParser.endDocument(null); } }
Example #27
Source File: StaxEventXMLReader.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Override protected void parseInternal() throws SAXException, XMLStreamException { boolean documentStarted = false; boolean documentEnded = false; int elementDepth = 0; while (this.reader.hasNext() && elementDepth >= 0) { XMLEvent event = this.reader.nextEvent(); if (!event.isStartDocument() && !event.isEndDocument() && !documentStarted) { handleStartDocument(event); documentStarted = true; } switch (event.getEventType()) { case XMLStreamConstants.START_DOCUMENT: handleStartDocument(event); documentStarted = true; break; case XMLStreamConstants.START_ELEMENT: elementDepth++; handleStartElement(event.asStartElement()); break; case XMLStreamConstants.END_ELEMENT: elementDepth--; if (elementDepth >= 0) { handleEndElement(event.asEndElement()); } break; case XMLStreamConstants.PROCESSING_INSTRUCTION: handleProcessingInstruction((ProcessingInstruction) event); break; case XMLStreamConstants.CHARACTERS: case XMLStreamConstants.SPACE: case XMLStreamConstants.CDATA: handleCharacters(event.asCharacters()); break; case XMLStreamConstants.END_DOCUMENT: handleEndDocument(); documentEnded = true; break; case XMLStreamConstants.NOTATION_DECLARATION: handleNotationDeclaration((NotationDeclaration) event); break; case XMLStreamConstants.ENTITY_DECLARATION: handleEntityDeclaration((EntityDeclaration) event); break; case XMLStreamConstants.COMMENT: handleComment((Comment) event); break; case XMLStreamConstants.DTD: handleDtd((DTD) event); break; case XMLStreamConstants.ENTITY_REFERENCE: handleEntityReference((EntityReference) event); break; } } if (documentStarted && !documentEnded) { handleEndDocument(); } }
Example #28
Source File: StaxEventXMLReader.java From spring4-understanding with Apache License 2.0 | 4 votes |
private void handleProcessingInstruction(ProcessingInstruction pi) throws SAXException { if (getContentHandler() != null) { getContentHandler().processingInstruction(pi.getTarget(), pi.getData()); } }
Example #29
Source File: StAXSchemaParser.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
public void parse(XMLEventReader input) throws XMLStreamException, XNIException { XMLEvent currentEvent = input.peek(); if (currentEvent != null) { int eventType = currentEvent.getEventType(); if (eventType != XMLStreamConstants.START_DOCUMENT && eventType != XMLStreamConstants.START_ELEMENT) { throw new XMLStreamException(); } fLocationWrapper.setLocation(currentEvent.getLocation()); fSchemaDOMParser.startDocument(fLocationWrapper, null, fNamespaceContext, null); loop: while (input.hasNext()) { currentEvent = input.nextEvent(); eventType = currentEvent.getEventType(); switch (eventType) { case XMLStreamConstants.START_ELEMENT: ++fDepth; StartElement start = currentEvent.asStartElement(); fillQName(fElementQName, start.getName()); fLocationWrapper.setLocation(start.getLocation()); fNamespaceContext.setNamespaceContext(start.getNamespaceContext()); fillXMLAttributes(start); fillDeclaredPrefixes(start); addNamespaceDeclarations(); fNamespaceContext.pushContext(); fSchemaDOMParser.startElement(fElementQName, fAttributes, null); break; case XMLStreamConstants.END_ELEMENT: EndElement end = currentEvent.asEndElement(); fillQName(fElementQName, end.getName()); fillDeclaredPrefixes(end); fLocationWrapper.setLocation(end.getLocation()); fSchemaDOMParser.endElement(fElementQName, null); fNamespaceContext.popContext(); --fDepth; if (fDepth <= 0) { break loop; } break; case XMLStreamConstants.CHARACTERS: sendCharactersToSchemaParser(currentEvent.asCharacters().getData(), false); break; case XMLStreamConstants.SPACE: sendCharactersToSchemaParser(currentEvent.asCharacters().getData(), true); break; case XMLStreamConstants.CDATA: fSchemaDOMParser.startCDATA(null); sendCharactersToSchemaParser(currentEvent.asCharacters().getData(), false); fSchemaDOMParser.endCDATA(null); break; case XMLStreamConstants.PROCESSING_INSTRUCTION: ProcessingInstruction pi = (ProcessingInstruction)currentEvent; fillProcessingInstruction(pi.getData()); fSchemaDOMParser.processingInstruction(pi.getTarget(), fTempString, null); break; case XMLStreamConstants.DTD: /* There shouldn't be a DTD in the schema */ break; case XMLStreamConstants.ENTITY_REFERENCE: /* Not needed for schemas */ break; case XMLStreamConstants.COMMENT: /* No point in sending comments */ break; case XMLStreamConstants.START_DOCUMENT: fDepth++; /* We automatically call startDocument before the loop */ break; case XMLStreamConstants.END_DOCUMENT: /* We automatically call endDocument after the loop */ break; } } fLocationWrapper.setLocation(null); fNamespaceContext.setNamespaceContext(null); fSchemaDOMParser.endDocument(null); } }
Example #30
Source File: StAXSchemaParser.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public void parse(XMLEventReader input) throws XMLStreamException, XNIException { XMLEvent currentEvent = input.peek(); if (currentEvent != null) { int eventType = currentEvent.getEventType(); if (eventType != XMLStreamConstants.START_DOCUMENT && eventType != XMLStreamConstants.START_ELEMENT) { throw new XMLStreamException(); } fLocationWrapper.setLocation(currentEvent.getLocation()); fSchemaDOMParser.startDocument(fLocationWrapper, null, fNamespaceContext, null); loop: while (input.hasNext()) { currentEvent = input.nextEvent(); eventType = currentEvent.getEventType(); switch (eventType) { case XMLStreamConstants.START_ELEMENT: ++fDepth; StartElement start = currentEvent.asStartElement(); fillQName(fElementQName, start.getName()); fLocationWrapper.setLocation(start.getLocation()); fNamespaceContext.setNamespaceContext(start.getNamespaceContext()); fillXMLAttributes(start); fillDeclaredPrefixes(start); addNamespaceDeclarations(); fNamespaceContext.pushContext(); fSchemaDOMParser.startElement(fElementQName, fAttributes, null); break; case XMLStreamConstants.END_ELEMENT: EndElement end = currentEvent.asEndElement(); fillQName(fElementQName, end.getName()); fillDeclaredPrefixes(end); fLocationWrapper.setLocation(end.getLocation()); fSchemaDOMParser.endElement(fElementQName, null); fNamespaceContext.popContext(); --fDepth; if (fDepth <= 0) { break loop; } break; case XMLStreamConstants.CHARACTERS: sendCharactersToSchemaParser(currentEvent.asCharacters().getData(), false); break; case XMLStreamConstants.SPACE: sendCharactersToSchemaParser(currentEvent.asCharacters().getData(), true); break; case XMLStreamConstants.CDATA: fSchemaDOMParser.startCDATA(null); sendCharactersToSchemaParser(currentEvent.asCharacters().getData(), false); fSchemaDOMParser.endCDATA(null); break; case XMLStreamConstants.PROCESSING_INSTRUCTION: ProcessingInstruction pi = (ProcessingInstruction)currentEvent; fillProcessingInstruction(pi.getData()); fSchemaDOMParser.processingInstruction(pi.getTarget(), fTempString, null); break; case XMLStreamConstants.DTD: /* There shouldn't be a DTD in the schema */ break; case XMLStreamConstants.ENTITY_REFERENCE: /* Not needed for schemas */ break; case XMLStreamConstants.COMMENT: /* No point in sending comments */ break; case XMLStreamConstants.START_DOCUMENT: fDepth++; /* We automatically call startDocument before the loop */ break; case XMLStreamConstants.END_DOCUMENT: /* We automatically call endDocument after the loop */ break; } } fLocationWrapper.setLocation(null); fNamespaceContext.setNamespaceContext(null); fSchemaDOMParser.endDocument(null); } }