本文整理汇总了Java中javax.xml.stream.events.ProcessingInstruction类的典型用法代码示例。如果您正苦于以下问题:Java ProcessingInstruction类的具体用法?Java ProcessingInstruction怎么用?Java ProcessingInstruction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProcessingInstruction类属于javax.xml.stream.events包,在下文中一共展示了ProcessingInstruction类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: parse
import javax.xml.stream.events.ProcessingInstruction; //导入依赖的package包/类
/**
* Parses an {@link ProcessingInstruction XML event} of a
* processing instruction.
* @param pi the event to parse
* @return the data from the processing instruction or <code>null</code>
* if the event is {@link #isIgnoredPI(ProcessingInstruction) ignored}
* by this parser
*/
public TocPIData parse(ProcessingInstruction pi) throws JAXBException
{
if (isIgnoredPI(pi))
return null;
String rawData = pi.getData();
rawData = null == rawData ? "" : rawData.trim();
boolean closing = rawData.endsWith("/");
if (closing)
rawData = rawData.substring(0, rawData.length() - 1).trim();
TocPIData data;
if (0 < rawData.length())
data = parseAttrs(rawData);
else if (closing)
data = new TocPIData();
else
throw new JAXBException("Processing instruction contains no data");
data.setClosing(closing);
return data;
}
开发者ID:StanLivitski,项目名称:HTMLtoc,代码行数:28,代码来源:TocPIParser.java
示例2: handlePI
import javax.xml.stream.events.ProcessingInstruction; //导入依赖的package包/类
private void handlePI(ProcessingInstruction event)
throws XMLStreamException {
try {
_sax.processingInstruction(
event.getTarget(),
event.getData());
} catch (SAXException e) {
throw new XMLStreamException(e);
}
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:11,代码来源:StAXEvent2SAX.java
示例3: getPITarget
import javax.xml.stream.events.ProcessingInstruction; //导入依赖的package包/类
@Override
public String getPITarget() {
if (this.event.isProcessingInstruction()) {
return ((ProcessingInstruction) this.event).getTarget();
}
else {
throw new IllegalStateException();
}
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:10,代码来源:XMLEventStreamReader.java
示例4: getPIData
import javax.xml.stream.events.ProcessingInstruction; //导入依赖的package包/类
@Override
public String getPIData() {
if (this.event.isProcessingInstruction()) {
return ((ProcessingInstruction) this.event).getData();
}
else {
throw new IllegalStateException();
}
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:10,代码来源:XMLEventStreamReader.java
示例5: getPITarget
import javax.xml.stream.events.ProcessingInstruction; //导入依赖的package包/类
@Override
public String getPITarget() {
XMLSecEvent xmlSecEvent = getCurrentEvent();
if (xmlSecEvent.getEventType() != PROCESSING_INSTRUCTION) {
throw new IllegalStateException(ERR_STATE_NOT_PI);
}
return ((ProcessingInstruction) xmlSecEvent).getTarget();
}
开发者ID:Legostaev,项目名称:xmlsec-gost,代码行数:9,代码来源:XMLSecurityStreamReader.java
示例6: getPIData
import javax.xml.stream.events.ProcessingInstruction; //导入依赖的package包/类
@Override
public String getPIData() {
XMLSecEvent xmlSecEvent = getCurrentEvent();
if (xmlSecEvent.getEventType() != PROCESSING_INSTRUCTION) {
throw new IllegalStateException(ERR_STATE_NOT_PI);
}
return ((ProcessingInstruction) xmlSecEvent).getData();
}
开发者ID:Legostaev,项目名称:xmlsec-gost,代码行数:9,代码来源:XMLSecurityStreamReader.java
示例7: getPITarget
import javax.xml.stream.events.ProcessingInstruction; //导入依赖的package包/类
public String getPITarget() {
if (event.isProcessingInstruction()) {
return ((ProcessingInstruction) event).getTarget();
}
else {
throw new IllegalStateException();
}
}
开发者ID:kenweezy,项目名称:teiid,代码行数:9,代码来源:XMLEventStreamReader.java
示例8: getPIData
import javax.xml.stream.events.ProcessingInstruction; //导入依赖的package包/类
public String getPIData() {
if (event.isProcessingInstruction()) {
return ((ProcessingInstruction) event).getData();
}
else {
throw new IllegalStateException();
}
}
开发者ID:kenweezy,项目名称:teiid,代码行数:9,代码来源:XMLEventStreamReader.java
示例9: processEvent
import javax.xml.stream.events.ProcessingInstruction; //导入依赖的package包/类
private void processEvent(XmlParserContext ctx, XMLEvent xmlEvent) throws BagriException {
if (ctx.getDocRoot() == null) {
ctx.firstEvents.add(xmlEvent);
if (xmlEvent.getEventType() == XMLStreamConstants.START_ELEMENT) {
String root = "/" + xmlEvent.asStartElement().getName();
ctx.addDocument(root);
for (XMLEvent event: ctx.firstEvents) {
processEvent(ctx, event);
}
}
} else {
switch (xmlEvent.getEventType()) {
case XMLStreamConstants.START_ELEMENT:
startElement(ctx, xmlEvent.asStartElement());
break;
case XMLStreamConstants.CHARACTERS:
if (!xmlEvent.asCharacters().isWhiteSpace()) {
ctx.addCharacters(xmlEvent.asCharacters().getData());
}
break;
case XMLStreamConstants.END_ELEMENT:
ctx.endElement();
break;
case XMLStreamConstants.ATTRIBUTE:
ctx.addAttribute(((Attribute) xmlEvent).getName(), ((Attribute) xmlEvent).getValue());
break;
case XMLStreamConstants.COMMENT:
ctx.addComment(((Comment) xmlEvent).getText());
break;
case XMLStreamConstants.PROCESSING_INSTRUCTION:
ctx.addProcessingInstruction(((ProcessingInstruction) xmlEvent).getTarget(), ((ProcessingInstruction) xmlEvent).getData());
break;
default:
break;
}
}
}
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:39,代码来源:XmlStaxParser.java
示例10: getPITarget
import javax.xml.stream.events.ProcessingInstruction; //导入依赖的package包/类
public String getPITarget() {
if (this.event.isProcessingInstruction()) {
return ((ProcessingInstruction) this.event).getTarget();
}
else {
throw new IllegalStateException();
}
}
开发者ID:deathspeeder,项目名称:class-guard,代码行数:9,代码来源:XMLEventStreamReader.java
示例11: getPIData
import javax.xml.stream.events.ProcessingInstruction; //导入依赖的package包/类
public String getPIData() {
if (this.event.isProcessingInstruction()) {
return ((ProcessingInstruction) this.event).getData();
}
else {
throw new IllegalStateException();
}
}
开发者ID:deathspeeder,项目名称:class-guard,代码行数:9,代码来源:XMLEventStreamReader.java
示例12: processingInstruction
import javax.xml.stream.events.ProcessingInstruction; //导入依赖的package包/类
public void processingInstruction(ProcessingInstruction event)
throws XMLStreamException {
String data = event.getData();
if (data != null && data.length() > 0) {
fStreamWriter.writeProcessingInstruction(event.getTarget(), data);
}
else {
fStreamWriter.writeProcessingInstruction(event.getTarget());
}
}
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:11,代码来源:StAXStreamResultBuilder.java
示例13: add
import javax.xml.stream.events.ProcessingInstruction; //导入依赖的package包/类
@Override
public void add(XMLEvent event) throws XMLStreamException
{
if (event instanceof ProcessingInstruction)
{
if (null == piData)
piData = parsePIEvent((ProcessingInstruction)event);
}
else
piData = null;
if (null != piData)
{
if (piData.isOpening())
{
formatter = TocFormatter.forPI(piData, event.getLocation());
formatter.setXMLEventFactory(getXMLEventFactory());
}
if (piData.isClosing())
super.add(getXMLEventFactory().createCharacters("\n"));
}
else if (state == State.INDEXED)
index(event);
else if (state == State.ROOT)
{
addDTD((StartElement)event);
super.add(event);
state = State.PASSTHROUGH;
}
}
开发者ID:StanLivitski,项目名称:HTMLtoc,代码行数:30,代码来源:Transformer.java
示例14: trackContext
import javax.xml.stream.events.ProcessingInstruction; //导入依赖的package包/类
protected void trackContext(XMLEvent event)
{
switch (event.getEventType())
{
case START_ELEMENT:
context.add(0, (StartElement)event);
break;
case END_DOCUMENT:
case END_ELEMENT:
if (!context.isEmpty())
{
StartElement open = context.remove(0);
EndElement close = event instanceof EndElement ? (EndElement)event : null;
if (null == close || !open.getName().equals(close.getName()))
throw new IllegalStateException("Unclosed " + describeEvent(open) + ' '
+ describeLocation(open.getLocation()));
}
else
throw new IllegalStateException("Unclosed " + describeEvent(origin) + ' '
+ describeLocation(origin.getLocation()));
break;
case PROCESSING_INSTRUCTION:
if (!TocPIParser.isIgnoredPI((ProcessingInstruction)event))
throw new IllegalStateException("Processing instructions <?" + TocPIParser.PI_TARGET
+ "?> are not allowed within the context of " + describeEvent(origin));
break;
}
}
开发者ID:StanLivitski,项目名称:HTMLtoc,代码行数:29,代码来源:Transformer.java
示例15: parsePIEvent
import javax.xml.stream.events.ProcessingInstruction; //导入依赖的package包/类
protected TocPIData parsePIEvent(ProcessingInstruction event)
throws XMLStreamException
{
try
{
return piParser().parse(event);
}
catch (JAXBException pierr)
{
throw new XMLStreamException("Error parsing " + describeEvent(event),
event.getLocation(), pierr);
}
}
开发者ID:StanLivitski,项目名称:HTMLtoc,代码行数:14,代码来源:Transformer.java
示例16: filterPIEvent
import javax.xml.stream.events.ProcessingInstruction; //导入依赖的package包/类
protected TocPIData filterPIEvent(ProcessingInstruction event)
{
try
{
return piParser().parse(event);
}
catch (JAXBException pierr)
{
throw new IllegalArgumentException("Error parsing " + describeEvent(event), pierr);
}
}
开发者ID:StanLivitski,项目名称:HTMLtoc,代码行数:12,代码来源:Transformer.java
示例17: processProcessingInstruction
import javax.xml.stream.events.ProcessingInstruction; //导入依赖的package包/类
private void processProcessingInstruction(final ProcessingInstruction processingInstruction,
final NodeLocation location) {
// Create and append ProcessingInstruction node
final org.w3c.dom.ProcessingInstruction processingInstructionNode = doc.createProcessingInstruction(
processingInstruction.getTarget(), processingInstruction.getData());
state.getCurrentParentNode().appendChild(processingInstructionNode);
state.createdNode();
}
开发者ID:whummer,项目名称:scaleDOM,代码行数:9,代码来源:LoadProcess.java
示例18: parse
import javax.xml.stream.events.ProcessingInstruction; //导入依赖的package包/类
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);
}
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:78,代码来源:StAXSchemaParser.java
示例19: createProcessingInstruction
import javax.xml.stream.events.ProcessingInstruction; //导入依赖的package包/类
@Override
public ProcessingInstruction createProcessingInstruction(String target, String data) {
ProcessingInstructionEvent event = new ProcessingInstructionEvent(target, data);
if(location != null)event.setLocation(location);
return event;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:XMLEventFactoryImpl.java
示例20: testEvents
import javax.xml.stream.events.ProcessingInstruction; //导入依赖的package包/类
@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());
}
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:46,代码来源:Issue41Test.java
注:本文中的javax.xml.stream.events.ProcessingInstruction类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论