当前位置: 首页>>代码示例>>Java>>正文


Java ProcessingInstruction.getData方法代码示例

本文整理汇总了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;
}
 
开发者ID:StanLivitski,项目名称:HTMLtoc,代码行数:28,代码来源:TocPIParser.java

示例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());
    }
}
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:11,代码来源:StAXStreamResultBuilder.java

示例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;
    }
}
 
开发者ID:vilie,项目名称:javify,代码行数:69,代码来源:XMLEventWriterImpl.java


注:本文中的javax.xml.stream.events.ProcessingInstruction.getData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。