org.apache.axiom.om.OMXMLParserWrapper.getDocument()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(9.5k)|赞(0)|评价(0)|浏览(53)

本文整理了Java中org.apache.axiom.om.OMXMLParserWrapper.getDocument()方法的一些代码示例,展示了OMXMLParserWrapper.getDocument()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OMXMLParserWrapper.getDocument()方法的具体详情如下:
包路径:org.apache.axiom.om.OMXMLParserWrapper
类名称:OMXMLParserWrapper
方法名:getDocument

OMXMLParserWrapper.getDocument介绍

[英]Get the document being built by this builder.
[中]获取此生成器正在生成的文档。

代码示例

代码示例来源:origin: org.paxml/PaxmlCore

/**
 * Parse input stream to get document.
 * @param in input stream
 * @return the document
 */
public static OMDocument getDocument(InputStream in) {
  // create the builder
  OMXMLParserWrapper builder = OMXMLBuilderFactory.createOMBuilder(in);
  // get the root element
  OMDocument doc = builder.getDocument();
  return doc;
}
/**

代码示例来源:origin: apache/axis2-java

public OMElement processDocument(InputStream inputStream, String contentType,
                 MessageContext messageContext) throws AxisFault {
  try {
    String charSetEncoding = (String) messageContext
        .getProperty(Constants.Configuration.CHARACTER_SET_ENCODING);
    
    // createSOAPModelBuilder takes care of configuring the underlying parser to
    // avoid the security issue described in CVE-2010-1632
    OMXMLParserWrapper builder = OMXMLBuilderFactory.createSOAPModelBuilder(inputStream,
        charSetEncoding);
    messageContext.setProperty(Constants.BUILDER, builder);
    SOAPEnvelope envelope = (SOAPEnvelope) builder.getDocumentElement();
    BuilderUtil
        .validateSOAPVersion(BuilderUtil.getEnvelopeNamespace(contentType), envelope);
    BuilderUtil.validateCharSetEncoding(charSetEncoding, builder.getDocument()
        .getCharsetEncoding(), envelope.getNamespace().getNamespaceURI());
    return envelope;
  } catch (IOException e) {
    throw AxisFault.makeFault(e);
  }
}

代码示例来源:origin: org.apache.axis2/axis2-kernel

public OMElement processDocument(InputStream inputStream, String contentType,
                 MessageContext messageContext) throws AxisFault {
  try {
    String charSetEncoding = (String) messageContext
        .getProperty(Constants.Configuration.CHARACTER_SET_ENCODING);
    
    // Apply a detachable inputstream.  This can be used later
    // to (a) get the length of the incoming message or (b)
    // free transport resources.
    DetachableInputStream is = new DetachableInputStream(inputStream);
    messageContext.setProperty(Constants.DETACHABLE_INPUT_STREAM, is);
    
    // createSOAPModelBuilder takes care of configuring the underlying parser to
    // avoid the security issue described in CVE-2010-1632
    OMXMLParserWrapper builder = OMXMLBuilderFactory.createSOAPModelBuilder(is,
        charSetEncoding);
    SOAPEnvelope envelope = (SOAPEnvelope) builder.getDocumentElement();
    BuilderUtil
        .validateSOAPVersion(BuilderUtil.getEnvelopeNamespace(contentType), envelope);
    BuilderUtil.validateCharSetEncoding(charSetEncoding, builder.getDocument()
        .getCharsetEncoding(), envelope.getNamespace().getNamespaceURI());
    return envelope;
  } catch (IOException e) {
    throw AxisFault.makeFault(e);
  }
}

代码示例来源:origin: org.paxml/paxml-core

/**
 * Parse input stream to get document.
 * 
 * @param in
 *            input stream
 * @return the document
 */
public static OMDocument getDocument(final InputStream in) {
  // create the builder
  OMXMLParserWrapper builder = OMXMLBuilderFactory.createOMBuilder(new StAXParserConfiguration() {
    @Override
    public XMLInputFactory configure(XMLInputFactory factory, StAXDialect dialect) {
      return factory;
    }
  }, in);
  // get the root element
  OMDocument doc = builder.getDocument();
  return doc;
}

代码示例来源:origin: org.apache.ws.commons.axiom/axiom-api

/**
 * Loads a document from the given URI.
 *
 * @param uri the URI of the document to load
 * @return Returns the document.
 * @throws FunctionCallException if the document could not be loaded
 */
public Object getDocument(String uri)
    throws FunctionCallException {
  InputStream in = null;
  try {
    if (uri.indexOf(':') == -1) {
      in = new FileInputStream(uri);
    } else {
      URL url = new URL(uri);
      in = url.openStream();
    }
    return OMXMLBuilderFactory.createOMBuilder(in).getDocument();
  } catch (Exception e) {
    if (in != null) {
      try {
        in.close();
      } catch (IOException ex) {
        // Ignore
      }
    }
    throw new FunctionCallException(e);
  }
}

代码示例来源:origin: tst-labs/esocial

private static org.apache.neethi.Policy getPolicy (java.lang.String policyString) {
  return org.apache.neethi.PolicyEngine.getPolicy(org.apache.axiom.om.OMXMLBuilderFactory.createOMBuilder(
      new java.io.StringReader(policyString)).getDocument().getXMLStreamReader(false));
}

代码示例来源:origin: tst-labs/esocial

private static org.apache.neethi.Policy getPolicy (java.lang.String policyString) {
  return org.apache.neethi.PolicyEngine.getPolicy(org.apache.axiom.om.OMXMLBuilderFactory.createOMBuilder(
      new java.io.StringReader(policyString)).getDocument().getXMLStreamReader(false));
}

代码示例来源:origin: tst-labs/esocial

private static org.apache.neethi.Policy getPolicy (java.lang.String policyString) {
  return org.apache.neethi.PolicyEngine.getPolicy(org.apache.axiom.om.OMXMLBuilderFactory.createOMBuilder(
      new java.io.StringReader(policyString)).getDocument().getXMLStreamReader(false));
}

代码示例来源:origin: tst-labs/esocial

private static org.apache.neethi.Policy getPolicy (java.lang.String policyString) {
  return org.apache.neethi.PolicyEngine.getPolicy(org.apache.axiom.om.OMXMLBuilderFactory.createOMBuilder(
      new java.io.StringReader(policyString)).getDocument().getXMLStreamReader(false));
}

代码示例来源:origin: org.apache.ws.commons.axiom/axiom-api

/**
   * Simple utility that takes an XMLStreamReader and writes it
   * to an XMLStreamWriter
   * @param reader
   * @param writer
   * @throws XMLStreamException
   */
  public static void reader2writer(XMLStreamReader reader, 
                   XMLStreamWriter writer)
  throws XMLStreamException {
    OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXOMBuilder(reader);
    try {
      OMDocument omDocument = builder.getDocument();
      Iterator it = omDocument.getChildren();
      while (it.hasNext()) {
        OMNode omNode = (OMNode) it.next();
        omNode.serializeAndConsume(writer);
      }
    } finally {
      builder.close();
    }
  }
}

代码示例来源:origin: apache/axis2-java

public static OMElement extractElement(XMLStreamReader reader, boolean proceedToNext) {
    OMDocument document = OMXMLBuilderFactory.createStAXOMBuilder(
        new XMLFragmentStreamReader(reader, proceedToNext)).getDocument();
    document.build();
    return document.getOMDocumentElement();
  }
}

代码示例来源:origin: org.apache.axis2/axis2-adb

/**
 * Gets the DOOM implementation of org.w3c.dom.Document  
 *
 * @param omElement the OMelement
 * @return the DOOM document
 */
public static OMDocument convertOMtoDOM(OMContainer omElement) {
  // use an Axiom meta factory with feature "dom" to get org.w3c.dom.Document
  OMFactory doomFactory = OMAbstractFactory.getMetaFactory(
      OMAbstractFactory.FEATURE_DOM).getOMFactory();
  OMXMLParserWrapper doomBuilder = OMXMLBuilderFactory.createStAXOMBuilder(doomFactory,
      omElement.getXMLStreamReader());
  OMDocument domElement = doomBuilder.getDocument();
  return domElement;
}

代码示例来源:origin: apache/axis2-java

/**
 * Gets the DOOM implementation of org.w3c.dom.Document  
 *
 * @param omElement the OMelement
 * @return the DOOM document
 */
public static OMDocument convertOMtoDOM(OMContainer omElement) {
  // use an Axiom meta factory with feature "dom" to get org.w3c.dom.Document
  OMFactory doomFactory = OMAbstractFactory.getMetaFactory(
      OMAbstractFactory.FEATURE_DOM).getOMFactory();
  OMXMLParserWrapper doomBuilder = OMXMLBuilderFactory.createStAXOMBuilder(doomFactory,
      omElement.getXMLStreamReader());
  OMDocument domElement = doomBuilder.getDocument();
  return domElement;
}

代码示例来源:origin: org.ballerinalang/ballerina-core

/**
 * Create a XML sequence from string inputstream with a given charset.
 *
 * @param xmlStream XML imput stream
 * @param charset   Charset to be used for parsing
 * @return XML Sequence
 */
@SuppressWarnings("unchecked")
public static BXML<?> parse(InputStream xmlStream, String charset) {
  BValueArray elementsSeq = new BValueArray();
  OMDocument doc;
  try {
    doc = OMXMLBuilderFactory.createOMBuilder(STAX_PARSER_CONFIGURATION, xmlStream, charset).getDocument();
    Iterator<OMNode> docChildItr = doc.getChildren();
    int index = 0;
    while (docChildItr.hasNext()) {
      elementsSeq.add(index++, new BXMLItem(docChildItr.next()));
    }
  } catch (DeferredParsingException e) {
    throw new BallerinaException(e.getCause().getMessage());
  } catch (Throwable e) {
    throw new BallerinaException("failed to create xml: " + e.getMessage());
  }
  return new BXMLSequence(elementsSeq);
}

代码示例来源:origin: org.ballerinalang/ballerina-core

/**
 * Create a XML sequence from string reader.
 *
 * @param reader XML reader
 * @return XML Sequence
 */
@SuppressWarnings("unchecked")
public static BXML<?> parse(Reader reader) {
  BValueArray elementsSeq = new BValueArray();
  OMDocument doc;
  try {
    doc = OMXMLBuilderFactory.createOMBuilder(STAX_PARSER_CONFIGURATION, reader).getDocument();
    Iterator<OMNode> docChildItr = doc.getChildren();
    int i = 0;
    while (docChildItr.hasNext()) {
      elementsSeq.add(i++, new BXMLItem(docChildItr.next()));
    }
  } catch (DeferredParsingException e) {
    throw new BallerinaException(e.getCause().getMessage());
  } catch (Throwable e) {
    throw new BallerinaException("failed to create xml: " + e.getMessage());
  }
  return new BXMLSequence(elementsSeq);
}

代码示例来源:origin: org.ballerinalang/ballerina-core

/**
 * Create a XML sequence from string inputstream.
 *
 * @param xmlStream XML input stream
 * @return  XML Sequence
 */
@SuppressWarnings("unchecked")
public static BXML<?> parse(InputStream xmlStream) {
  BValueArray elementsSeq = new BValueArray();
  OMDocument doc;
  try {
    doc = OMXMLBuilderFactory.createOMBuilder(STAX_PARSER_CONFIGURATION, xmlStream).getDocument();
    Iterator<OMNode> docChildItr = doc.getChildren();
    int i = 0;
    while (docChildItr.hasNext()) {
      elementsSeq.add(i++, new BXMLItem(docChildItr.next()));
    }
  } catch (DeferredParsingException e) {
    throw new BallerinaException(e.getCause().getMessage());
  } catch (Throwable e) {
    throw new BallerinaException("failed to create xml: " + e.getMessage());
  }
  return new BXMLSequence(elementsSeq);
}

代码示例来源:origin: apache/axis2-java

InputStream in = new FileInputStream(servicesFile);
try {
  OMDocument doc = OMXMLBuilderFactory.createOMBuilder(in).getDocument();
  OMElement serviceElement;
  OMDocument axis2xmlDoc = OMXMLBuilderFactory.createOMBuilder(in).getDocument();
  OMElement root = axis2xmlDoc.getOMDocumentElement();
  for (Iterator<OMNode> it = root.getDescendants(false); it.hasNext(); ) {

相关文章