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


Java DOMUtil.getChildElements方法代码示例

本文整理汇总了Java中com.evolveum.midpoint.util.DOMUtil.getChildElements方法的典型用法代码示例。如果您正苦于以下问题:Java DOMUtil.getChildElements方法的具体用法?Java DOMUtil.getChildElements怎么用?Java DOMUtil.getChildElements使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.evolveum.midpoint.util.DOMUtil的用法示例。


在下文中一共展示了DOMUtil.getChildElements方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processWsdl

import com.evolveum.midpoint.util.DOMUtil; //导入方法依赖的package包/类
private void processWsdl(Path filePath, File workDir, File outDir) throws MojoExecutionException, MojoFailureException {
	Document dom = DOMUtil.parseFile(filePath.toFile());
	
	if (translateSchemaLocation) {
		Element rootElement = DOMUtil.getFirstChildElement(dom);
		List<Element> importElements = DOMUtil.getChildElements(rootElement, DOMUtil.WSDL_IMPORT_ELEMENT);
		for(Element importElement: importElements) {
			String namespace = DOMUtil.getAttribute(importElement, DOMUtil.WSDL_ATTR_NAMESPACE);
			String schemaLocation;
			try {
				schemaLocation = resolveSchemaLocation(namespace, filePath, workDir);
			} catch (IOException e) {
				throw new MojoExecutionException("Error resolving namespace "+namespace+" in file "+filePath+": "+ e.getMessage(), e);
			}
			importElement.setAttribute(DOMUtil.WSDL_ATTR_LOCATION.getLocalPart(),
					schemaLocation);
		}
		
		List<Element> typesElements = DOMUtil.getChildElements(rootElement, DOMUtil.WSDL_TYPES_ELEMENT);
		for(Element typesElement: typesElements) {
			processXsdElement(DOMUtil.getFirstChildElement(typesElement),filePath,workDir,outDir);
		}
	}
	
	serializeXml(dom, filePath, workDir, outDir);
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:27,代码来源:SchemaDistMojo.java

示例2: parseWsdlResource

import com.evolveum.midpoint.util.DOMUtil; //导入方法依赖的package包/类
public static List<SchemaDescription> parseWsdlResource(final String resourcePath) throws SchemaException {
    List<SchemaDescription> schemaDescriptions = new ArrayList<>();

    InputStream inputStream = SchemaRegistry.class.getClassLoader().getResourceAsStream(resourcePath);
    if (inputStream == null) {
        throw new IllegalStateException("Cannot fetch system resource for schema " + resourcePath);
    }
    Node node;
    try {
        node = DOMUtil.parse(inputStream);
    } catch (IOException e) {
        throw new SchemaException("Cannot parse schema from system resource " + resourcePath, e);
    }
    Element rootElement = node instanceof Element ? (Element)node : DOMUtil.getFirstChildElement(node);
    QName rootElementQName = DOMUtil.getQName(rootElement);
    if (WSDLConstants.QNAME_DEFINITIONS.equals(rootElementQName)) {
        Element types = DOMUtil.getChildElement(rootElement, WSDLConstants.QNAME_TYPES);
        if (types == null) {
            LOGGER.warn("No <types> section in WSDL document in system resource " + resourcePath);
            return schemaDescriptions;
        }
        List<Element> schemaElements = DOMUtil.getChildElements(types, DOMUtil.XSD_SCHEMA_ELEMENT);
        if (schemaElements.isEmpty()) {
            LOGGER.warn("No schemas in <types> section in WSDL document in system resource " + resourcePath);
            return schemaDescriptions;
        }
        int number = 1;
        for (Element schemaElement : schemaElements) {
            SchemaDescription desc = new SchemaDescription("schema #" + (number++) + " in system resource " + resourcePath);
            desc.node = schemaElement;
            desc.fetchBasicInfoFromSchema();
            schemaDescriptions.add(desc);
            LOGGER.trace("Schema registered from {}", desc.getSourceDescription());
        }
        return schemaDescriptions;
    } else {
        throw new SchemaException("WSDL system resource "+resourcePath+" does not start with wsdl:definitions element");
    }
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:40,代码来源:SchemaDescription.java


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