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


Java StAXOMBuilder类代码示例

本文整理汇总了Java中org.apache.axiom.om.impl.builder.StAXOMBuilder的典型用法代码示例。如果您正苦于以下问题:Java StAXOMBuilder类的具体用法?Java StAXOMBuilder怎么用?Java StAXOMBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


StAXOMBuilder类属于org.apache.axiom.om.impl.builder包,在下文中一共展示了StAXOMBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getOMElement

import org.apache.axiom.om.impl.builder.StAXOMBuilder; //导入依赖的package包/类
public OMElement getOMElement(String filePath) throws FileNotFoundException,
                                                      XMLStreamException {
    //if file location =null it taking from the test data directory
    OMElement documentElement = null;
    FileInputStream inputStream;
    File file = new File(filePath);
    if (file.exists()) {
        inputStream = new FileInputStream(filePath);
        XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(inputStream);
        //create the builder
        StAXOMBuilder builder = new StAXOMBuilder(parser);
        //get the root element (in this case the envelope)
        documentElement = builder.getDocumentElement();
    }
    return documentElement;
}
 
开发者ID:wso2,项目名称:product-ei,代码行数:17,代码来源:ArtifactReaderUtil.java

示例2: initConfigurationFromFile

import org.apache.axiom.om.impl.builder.StAXOMBuilder; //导入依赖的package包/类
/**
     * Initialize the configuration object from the properties in the BPS Analytics config xml file.
     */
    private void initConfigurationFromFile(File BPMNAnalyticsCoreConfigurationFile) {
        SecretResolver secretResolver = null;
        try (InputStream in = new FileInputStream(BPMNAnalyticsCoreConfigurationFile)) {
            StAXOMBuilder builder = new StAXOMBuilder(in);
            secretResolver = SecretResolverFactory.create(builder.getDocumentElement(), true);
        } catch (Exception e) {
            log.warn("Error occurred while retrieving secured BPS Analytics configuration.", e);
        }
        TBPSAnalytics tBPSAnalytics = bpsAnalyticsDocument.getBPSAnalytics();
        if (tBPSAnalytics == null) {
            return;
        }

        if (tBPSAnalytics.getBPMN() != null) {
            initBPMNAnalytics(tBPSAnalytics.getBPMN());
        }

        if (tBPSAnalytics.getAnalyticServer() != null) {
            initAnalytics(secretResolver, tBPSAnalytics.getAnalyticServer());
        }

//        if (tBPSAnalytics.getAnalytics() != null) {
//            initAnalytics(secretResolver, tBPSAnalytics.getAnalytics());
//        }
    }
 
开发者ID:wso2,项目名称:product-ei,代码行数:29,代码来源:BPMNAnalyticsCoreConfiguration.java

示例3: parse_xml_string

import org.apache.axiom.om.impl.builder.StAXOMBuilder; //导入依赖的package包/类
OMElement parse_xml_string(String input_string) {
		byte[] ba = input_string.getBytes();

//		create the parser
		XMLStreamReader parser=null;

		try {
			parser = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(ba));
		} catch (XMLStreamException e) {
			assertTrue("Could not create XMLStreamReader from " + "input stream", false);
		}
//		create the builder
		StAXOMBuilder builder = new StAXOMBuilder(parser);

//		get the root element (in this case the envelope)
		OMElement documentElement =  builder.getDocumentElement();

		return documentElement;
	}
 
开发者ID:jembi,项目名称:openxds,代码行数:20,代码来源:XdsTest.java

示例4: parse_xml_string

import org.apache.axiom.om.impl.builder.StAXOMBuilder; //导入依赖的package包/类
static public OMElement parse_xml_string(String input_string) throws XMLParserException {
		byte[] ba = input_string.getBytes();

//		create the parser
		XMLStreamReader parser=null;

		try {
			parser = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(ba));
		} catch (XMLStreamException e) {
			throw new XMLParserException("gov.nist.registry.common2.xml.Parse: Could not create XMLStreamReader from " + "input stream");
		}
//		create the builder
		StAXOMBuilder builder = new StAXOMBuilder(parser);

//		get the root element (in this case the envelope)
		OMElement documentElement =  builder.getDocumentElement();

		return documentElement;
	}
 
开发者ID:jembi,项目名称:openxds,代码行数:20,代码来源:Parse.java

示例5: parse_xml

import org.apache.axiom.om.impl.builder.StAXOMBuilder; //导入依赖的package包/类
public static OMElement parse_xml(InputStream is) throws FactoryConfigurationError, XdsInternalException {

		//		create the parser
		XMLStreamReader parser=null;

		try {
			parser = XMLInputFactory.newInstance().createXMLStreamReader(is);
		} catch (XMLStreamException e) {
			throw new XdsInternalException("Could not create XMLStreamReader from InputStream");
		} 

		//		create the builder
		StAXOMBuilder builder = new StAXOMBuilder(parser);

		//		get the root element (in this case the envelope)
		OMElement documentElement =  builder.getDocumentElement();	
		if (documentElement == null)
			throw new XdsInternalException("No document element");
		return documentElement;
	}
 
开发者ID:jembi,项目名称:openxds,代码行数:21,代码来源:Util.java

示例6: activate

import org.apache.axiom.om.impl.builder.StAXOMBuilder; //导入依赖的package包/类
protected void activate(ComponentContext ctxt) {
    try {
        //register bpel deployer as an OSGi Service
        BPELAppDeployer bpelDeployer = new BPELAppDeployer();
        appHandlerRegistration = ctxt.getBundleContext().registerService(
                AppDeploymentHandler.class.getName(), bpelDeployer, null);

        // read required-features.xml
        URL reqFeaturesResource = ctxt.getBundleContext().getBundle()
                .getResource(AppDeployerConstants.REQ_FEATURES_XML);
        if (reqFeaturesResource != null) {
            InputStream xmlStream = reqFeaturesResource.openStream();
            requiredFeatures = AppDeployerUtils
                    .readRequiredFeaturs(new StAXOMBuilder(xmlStream).getDocumentElement());
        }
    } catch (Throwable e) {
        log.error("Failed to activate BPEL Application Deployer", e);
    }
}
 
开发者ID:wso2,项目名称:carbon-business-process,代码行数:20,代码来源:BPELAppDeployerDSComponent.java

示例7: activate

import org.apache.axiom.om.impl.builder.StAXOMBuilder; //导入依赖的package包/类
protected void activate(ComponentContext ctxt) {
    try {
        //register bpmn deployer as an OSGi Service
        BPMNAppDeployer BPMNAppDeployer = new BPMNAppDeployer();
        appHandlerRegistration = ctxt.getBundleContext().registerService(
                AppDeploymentHandler.class.getName(), BPMNAppDeployer, null);

        // read required-features.xml
        URL reqFeaturesResource = ctxt.getBundleContext().getBundle()
                .getResource(AppDeployerConstants.REQ_FEATURES_XML);
        if (reqFeaturesResource != null) {
            InputStream xmlStream = reqFeaturesResource.openStream();
            requiredFeatures = AppDeployerUtils
                    .readRequiredFeaturs(new StAXOMBuilder(xmlStream).getDocumentElement());
        }
    } catch (Throwable e) {
        log.error("Failed to activate BPMN Application Deployer", e);
    }
}
 
开发者ID:wso2,项目名称:carbon-business-process,代码行数:20,代码来源:BPMNAppDeployerDSComponent.java

示例8: activate

import org.apache.axiom.om.impl.builder.StAXOMBuilder; //导入依赖的package包/类
protected void activate(ComponentContext ctxt) {
    try {
        //register humantask deployer as an OSGi Service
        HumanTaskAppDeployer humanTaskAppDeployer = new HumanTaskAppDeployer();
        appHandlerRegistration = ctxt.getBundleContext().registerService(
                AppDeploymentHandler.class.getName(), humanTaskAppDeployer, null);

        // read required-features.xml
        URL reqFeaturesResource = ctxt.getBundleContext().getBundle()
                .getResource(AppDeployerConstants.REQ_FEATURES_XML);
        if (reqFeaturesResource != null) {
            InputStream xmlStream = reqFeaturesResource.openStream();
            requiredFeatures = AppDeployerUtils
                    .readRequiredFeaturs(new StAXOMBuilder(xmlStream).getDocumentElement());
        }
    } catch (Throwable e) {
        log.error("Failed to activate HumanTask Application Deployer", e);
    }
}
 
开发者ID:wso2,项目名称:carbon-business-process,代码行数:20,代码来源:HumanTaskAppDeployerDSComponent.java

示例9: load

import org.apache.axiom.om.impl.builder.StAXOMBuilder; //导入依赖的package包/类
/**
 * Converts the bpel process definition to an omElement which is how the AXIS2 Object Model (AXIOM) represents an
 * XML
 * element
 *
 * @param bpelStr bpel process definition needed to create the SVG
 * @return omElement
 */
public OMElement load(String bpelStr) {
    try {
        /*Creates a new instance of the XmlStreamReader class for the specified String input i.e. the bpel
        process definition
          using the StringReader class which enables you to turn an ordinary String into a Reader.
          This is useful if you have data as a String but need to pass that String to a component that only
          accepts a Reader.
        */
        parser = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(bpelStr));
        /*The instance of XmlStreamReader created is passed to the StAXOMBuilder which produces a pure XML
        infoset compliant object
         model which conatins the bpel process definition
         */
        builder = new StAXOMBuilder(parser);
        //The XML object created by the StAXOMBuilder is used to build an OMElement that is added to an existing
        // OM tree
        bpelElement = builder.getDocumentElement();
        //OmElement containing the bpel process definition is returned
        return bpelElement;
    } catch (XMLStreamException e) {
        log.error("XMLStreamReader creation failed", e);
        throw new NullPointerException("Document Element is NULL");
    }
}
 
开发者ID:wso2,项目名称:carbon-business-process,代码行数:33,代码来源:BPELImpl.java

示例10: setUp

import org.apache.axiom.om.impl.builder.StAXOMBuilder; //导入依赖的package包/类
@Override
public void setUp() throws Exception {
    AxisConfiguration axisCfg = new AxisConfiguration();
    ConfigurationContext cfgCtx = new ConfigurationContext(axisCfg);
    AxisService service = new AxisService();
    
    InputStream in = ContentTypeRuleTest.class.getResourceAsStream(getName() + ".xml");
    try {
        OMElement element = new StAXOMBuilder(in).getDocumentElement();
        new ServiceBuilder(cfgCtx, service).populateService(element);
    } finally {
        in.close();
    }
    
    ruleSet = ContentTypeRuleFactory.parse(service.getParameter("test"));
}
 
开发者ID:wso2,项目名称:wso2-axis2-transports,代码行数:17,代码来源:ContentTypeRuleTest.java

示例11: fromScript

import org.apache.axiom.om.impl.builder.StAXOMBuilder; //导入依赖的package包/类
public OMElement fromScript(Object o) {
    if (!(o instanceof XMLObject)) {
        return super.fromScript(o);
    }

    // TODO: E4X Bug? Shouldn't need this copy, but without it the outer element gets lost. See Mozilla bugzilla 361722
    Scriptable jsXML = (Scriptable) ScriptableObject.callMethod((Scriptable) o, "copy", new Object[0]);
    Wrapper wrapper = (Wrapper) ScriptableObject.callMethod((XMLObject)jsXML, "getXmlObject", new Object[0]);
    XmlObject xmlObject = (XmlObject)wrapper.unwrap();
    try {

        StAXOMBuilder builder = new StAXOMBuilder(xmlObject.newInputStream());
        OMElement omElement = builder.getDocumentElement();

        return omElement;

    } catch (XMLStreamException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:21,代码来源:JSOMElementConvertor.java

示例12: buildOMElement

import org.apache.axiom.om.impl.builder.StAXOMBuilder; //导入依赖的package包/类
public OMElement buildOMElement(String content) throws GovernanceException {
    XMLStreamReader parser;
    try {
        XMLInputFactory factory = XMLInputFactory.newInstance();
        factory.setProperty(XMLInputFactory.IS_COALESCING, new Boolean(true));
        parser = factory.createXMLStreamReader(new StringReader(content));
    } catch (XMLStreamException e) {
        String msg = "Error in initializing the parser to build the OMElement.";
        log.error(msg, e);
        throw new GovernanceException(msg, e);
    }

    //create the builder
    StAXOMBuilder builder = new StAXOMBuilder(parser);
    //get the root element (in this case the envelope)

    return builder.getDocumentElement();
}
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:19,代码来源:EndpointImpl.java

示例13: testGsonXMLStreamReader

import org.apache.axiom.om.impl.builder.StAXOMBuilder; //导入依赖的package包/类
@Test
public void testGsonXMLStreamReader() throws Exception {
    String jsonString = "{\"response\":{\"return\":{\"name\":\"kate\",\"age\":\"35\",\"gender\":\"female\"}}}";
    String xmlString = "<response xmlns=\"http://www.w3schools.com\"><return><name>kate</name><age>35</age><gender>female</gender></return></response>";
    InputStream inputStream = new ByteArrayInputStream(jsonString.getBytes());
    JsonReader jsonReader = new JsonReader(new InputStreamReader(inputStream , "UTF-8"));
    String fileName = "test-resources/custom_schema/testSchema_1.xsd";
    InputStream is = new FileInputStream(fileName);
    XmlSchemaCollection schemaCol = new XmlSchemaCollection();
    XmlSchema schema = schemaCol.read(new StreamSource(is), null);
    List<XmlSchema> schemaList = new ArrayList<XmlSchema>();
    schemaList.add(schema);
    QName elementQName = new QName("http://www.w3schools.com", "response");
    ConfigurationContext configCtxt = new ConfigurationContext(new AxisConfiguration());
    GsonXMLStreamReader gsonXMLStreamReader = new GsonXMLStreamReader(jsonReader);
    gsonXMLStreamReader.initXmlStreamReader(elementQName , schemaList , configCtxt);
    StAXOMBuilder stAXOMBuilder = new StAXOMBuilder(gsonXMLStreamReader);
    OMElement omElement = stAXOMBuilder.getDocumentElement();
    String actual = omElement.toString();
    inputStream.close();
    is.close();
    Assert.assertEquals(xmlString , actual);

}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:25,代码来源:GsonXMLStreamReaderTest.java

示例14: testGsonXMLStreamReaderWithDataTypes

import org.apache.axiom.om.impl.builder.StAXOMBuilder; //导入依赖的package包/类
/**
 * This method tests GsonXMLStreamReader for a schema with different data types including binary.
 */
@Test
public void testGsonXMLStreamReaderWithDataTypes() throws Exception {
    String jsonString = "{\"response\":{\"return\":{\"name\":\"kate\",\"homes\":1,\"age\":23,\"height\":5.5,"
            + "\"image\":\"iVBORw0KGg\"}}}";
    String xmlString = "<response xmlns=\"http://www.w3schools.com\"><return><name>kate</name><homes>1</homes>"
            + "<age>23</age><height>5.5</height><image>iVBORw0KGg</image></return></response>";
    InputStream inputStream = new ByteArrayInputStream(jsonString.getBytes());
    JsonReader jsonReader = new JsonReader(new InputStreamReader(inputStream, "UTF-8"));
    String fileName = "test-resources/custom_schema/testSchema_3.xsd";
    InputStream is = new FileInputStream(fileName);
    XmlSchemaCollection schemaCol = new XmlSchemaCollection();
    XmlSchema schema = schemaCol.read(new StreamSource(is), null);
    List<XmlSchema> schemaList = new ArrayList<XmlSchema>();
    schemaList.add(schema);
    QName elementQName = new QName("http://www.w3schools.com", "response");
    ConfigurationContext configCtxt = new ConfigurationContext(new AxisConfiguration());
    GsonXMLStreamReader gsonXMLStreamReader = new GsonXMLStreamReader(jsonReader);
    gsonXMLStreamReader.initXmlStreamReader(elementQName, schemaList, configCtxt);
    StAXOMBuilder stAXOMBuilder = new StAXOMBuilder(gsonXMLStreamReader);
    OMElement omElement = stAXOMBuilder.getDocumentElement();
    String actual = omElement.toString();
    inputStream.close();
    is.close();
    Assert.assertEquals(xmlString, actual);
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:29,代码来源:GsonXMLStreamReaderTest.java

示例15: outputTo

import org.apache.axiom.om.impl.builder.StAXOMBuilder; //导入依赖的package包/类
/**
 * outputTo the writer.
 *
 * @param writer -- the output of the converter
 */
public void outputTo(XMLStreamWriter writer) throws XMLStreamException {
    // Using OM to convert the reader to a writer.  This seems to be
    // the safest way to make the conversion, and it promotes code re-use.
    StAXOMBuilder builder = new StAXOMBuilder(reader);
    OMDocument omDocument = builder.getDocument();
    Iterator it = omDocument.getChildren();
    while (it.hasNext()) {
        OMNode omNode = (OMNode)it.next();
        // TODO Using serialize and consume
        // caused an axiom bug...falling back to serialize
        // (which is less performant due to om caching)
        //omNode.serializeAndConsume(writer);
        omNode.serialize(writer);
    }
    // Close the reader if marked to do so
    if (closeReader) {
        if (log.isDebugEnabled()) {
            log.debug("closing reader, builder: " + JavaUtils.stackToString());
        }
        reader.close();
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:28,代码来源:Reader2Writer.java


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