本文整理汇总了Java中javax.xml.stream.events.ProcessingInstruction.getData方法的典型用法代码示例。如果您正苦于以下问题:Java ProcessingInstruction.getData方法的具体用法?Java ProcessingInstruction.getData怎么用?Java ProcessingInstruction.getData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.xml.stream.events.ProcessingInstruction
的用法示例。
在下文中一共展示了ProcessingInstruction.getData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: 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());
}
}
示例3: add
import javax.xml.stream.events.ProcessingInstruction; //导入方法依赖的package包/类
public void add(XMLEvent event)
throws XMLStreamException
{
QName name;
String uri;
switch (event.getEventType())
{
case XMLStreamConstants.START_ELEMENT:
StartElement startElement = event.asStartElement();
name = startElement.getName();
uri = name.getNamespaceURI();
if (uri != null && !"".equals(uri))
writer.writeStartElement(name.getPrefix(), name.getLocalPart(), uri);
else
writer.writeStartElement(name.getLocalPart());
break;
case XMLStreamConstants.END_ELEMENT:
writer.writeEndElement();
break;
case XMLStreamConstants.ATTRIBUTE:
Attribute attribute = (Attribute) event;
name = attribute.getName();
uri = name.getNamespaceURI();
if (uri != null && !"".equals(uri))
writer.writeAttribute(name.getPrefix(), uri, name.getLocalPart(),
attribute.getValue());
else
writer.writeAttribute(name.getLocalPart(), attribute.getValue());
break;
case XMLStreamConstants.NAMESPACE:
Namespace namespace = (Namespace) event;
uri = namespace.getNamespaceURI();
writer.writeNamespace(namespace.getPrefix(), uri);
break;
case XMLStreamConstants.PROCESSING_INSTRUCTION:
ProcessingInstruction pi = (ProcessingInstruction) event;
String data = pi.getData();
if (data == null)
writer.writeProcessingInstruction(pi.getTarget());
else
writer.writeProcessingInstruction(pi.getTarget(), data);
break;
case XMLStreamConstants.COMMENT:
Comment comment = (Comment) event;
writer.writeComment(comment.getText());
break;
case XMLStreamConstants.START_DOCUMENT:
StartDocument startDocument = (StartDocument) event;
writer.writeStartDocument(startDocument.getVersion());
break;
case XMLStreamConstants.END_DOCUMENT:
writer.writeEndDocument();
break;
case XMLStreamConstants.DTD:
DTD dtd = (DTD) event;
writer.writeDTD(dtd.getDocumentTypeDeclaration());
break;
case XMLStreamConstants.CHARACTERS:
case XMLStreamConstants.SPACE:
Characters characters = event.asCharacters();
writer.writeCharacters(characters.getData());
break;
case XMLStreamConstants.CDATA:
Characters cdata = event.asCharacters();
writer.writeCData(cdata.getData());
break;
}
}