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


Java DOMUtil.getFirstChildElement方法代码示例

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


在下文中一共展示了DOMUtil.getFirstChildElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: testParseTaskDom

import com.evolveum.midpoint.util.DOMUtil; //导入方法依赖的package包/类
@Test
public void testParseTaskDom() throws SchemaException {
	System.out.println("===[ testParseTaskDom ]===");

	// GIVEN
	PrismContext prismContext = getPrismContext();
	
	Document document = DOMUtil.parseFile(TASK_FILE);
	Element taskElement = DOMUtil.getFirstChildElement(document);
	
	// WHEN
	PrismObject<TaskType> task = prismContext.parserFor(taskElement).parse();
	
	// THEN
	System.out.println("Parsed task:");
	System.out.println(task.debugDump());
	
	assertTask(task);
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:20,代码来源:TestParseTask.java

示例3: testConvertFromProtectedString

import com.evolveum.midpoint.util.DOMUtil; //导入方法依赖的package包/类
@Test(enabled=false)
public void testConvertFromProtectedString() throws SchemaException {
	Document document = DOMUtil.parseDocument(
			"<password xmlns=\""+FOO_NAMESPACE+"\" "+
			"xmlns:c=\"http://midpoint.evolveum.com/xml/ns/public/common/common-3\" "+
			"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "+
			"xsi:type=\"c:ProtectedStringType\">"+
			"<c:clearValue>3lizab3th</c:clearValue></password>");
	Element element = DOMUtil.getFirstChildElement(document);
	
	Object value = XmlTypeConverter.toJavaValue(element);
	
	System.out.println("XML -> ProtectedStringType: "+value);
	assertNotNull(value);
	assertTrue(value instanceof ProtectedStringType);
	assertEquals("3lizab3th",((ProtectedStringType)value).getClearValue());
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:18,代码来源:XsdTypeConverterTest.java

示例4: testPrismParseDom

import com.evolveum.midpoint.util.DOMUtil; //导入方法依赖的package包/类
@Test
public void testPrismParseDom() throws Exception {
	final String TEST_NAME = "testPrismParseDom";
	PrismInternalTestUtil.displayTestTitle(TEST_NAME);
	
	// GIVEN
	Document document = DOMUtil.parseFile(getFile(USER_JACK_FILE_BASENAME));
	Element userElement = DOMUtil.getFirstChildElement(document);
	
	PrismContext prismContext = constructInitializedPrismContext();
	
	// WHEN
	PrismObject<UserType> user = prismContext.parserFor(userElement).parse();
	
	// THEN
	System.out.println("User:");
	System.out.println(user.debugDump());
	assertNotNull(user);
	
	assertUserJack(user, true);
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:22,代码来源:TestPrismParsingXml.java

示例5: testPrismParseDomAdhoc

import com.evolveum.midpoint.util.DOMUtil; //导入方法依赖的package包/类
@Test
public void testPrismParseDomAdhoc() throws Exception {
	final String TEST_NAME = "testPrismParseDomAdhoc";
	PrismInternalTestUtil.displayTestTitle(TEST_NAME);
	
	// GIVEN
	Document document = DOMUtil.parseFile(getFile(USER_JACK_ADHOC_BASENAME));
	Element userElement = DOMUtil.getFirstChildElement(document);
	
	PrismContext prismContext = constructInitializedPrismContext();
	
	// WHEN
	PrismObject<UserType> user = prismContext.parserFor(userElement).parse();
	
	// THEN
	System.out.println("User:");
	System.out.println(user.debugDump());
	assertNotNull(user);
	
	assertUserAdhoc(user, true);
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:22,代码来源:TestPrismParsingXml.java

示例6: testParseGenericDom

import com.evolveum.midpoint.util.DOMUtil; //导入方法依赖的package包/类
@Test
public void testParseGenericDom() throws SchemaException, DatatypeConfigurationException {
	System.out.println("===[ testParseGenericDom ]===");

	// GIVEN
	PrismContext prismContext = PrismTestUtil.getPrismContext();
	
	Document document = DOMUtil.parseFile(GENERIC_FILE);
	Element resourceElement = DOMUtil.getFirstChildElement(document);
	
	// WHEN
	PrismObject<GenericObjectType> generic = prismContext.parserFor(resourceElement).parse();
	
	// THEN
	System.out.println("Parsed generic object:");
	System.out.println(generic.debugDump());
	
	assertGenericObject(generic);
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:20,代码来源:TestParseGenericObject.java

示例7: testParseResourceDomSimple

import com.evolveum.midpoint.util.DOMUtil; //导入方法依赖的package包/类
@Test
public void testParseResourceDomSimple() throws Exception {
	if (!"xml".equals(language)) {
		return;
	}
	displayTestTitle("testParseResourceDomSimple");

	// GIVEN
	PrismContext prismContext = getPrismContext();

	Document document = DOMUtil.parseFile(getFile(TestConstants.RESOURCE_FILE_SIMPLE_BASENAME));
	Element resourceElement = DOMUtil.getFirstChildElement(document);

	// WHEN
	PrismObject<ResourceType> resource = prismContext.parserFor(resourceElement).parse();

	// THEN
	System.out.println("Parsed resource:");
	System.out.println(resource.debugDump());

	assertResource(resource, true, true, true);
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:23,代码来源:TestParseResource.java

示例8: testResourceSchemaSerializationInResource

import com.evolveum.midpoint.util.DOMUtil; //导入方法依赖的package包/类
@Test
public void testResourceSchemaSerializationInResource() throws SchemaException, JAXBException {
	System.out.println("\n===[ testResourceSchemaSerializationInResource ]=====");
	// GIVEN
	ResourceSchema schema = createResourceSchema();
	
	// WHEN
	Document xsdDocument = schema.serializeToXsd();
	Element xsdElement = DOMUtil.getFirstChildElement(xsdDocument);
	
	PrismObject<ResourceType> resource = wrapInResource(xsdElement);
	String resourceXmlString = PrismTestUtil.getPrismContext().serializeObjectToString(resource, PrismContext.LANG_XML);
	
	System.out.println("Serialized resource");
	System.out.println(resourceXmlString);
	
	PrismObject<ResourceType> reparsedResource = PrismTestUtil.getPrismContext().parseObject(resourceXmlString);
	
	System.out.println("Re-parsed resource");
	System.out.println(reparsedResource.debugDump());
	
	XmlSchemaType reparsedSchemaType = reparsedResource.asObjectable().getSchema();
	Element reparsedXsdElement = ObjectTypeUtil.findXsdElement(reparsedSchemaType);
	
	System.out.println("Reparsed XSD schema");
	System.out.println(DOMUtil.serializeDOMToString(reparsedXsdElement));
	
	assertDomSchema(reparsedXsdElement);
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:30,代码来源:TestResourceSchema.java

示例9: toItemPath

import com.evolveum.midpoint.util.DOMUtil; //导入方法依赖的package包/类
private ItemPath toItemPath(String stringPath) {
	String xml = "<path " +
			"xmlns='"+SchemaConstants.NS_C+"' " +
			"xmlns:t='"+SchemaConstants.NS_TYPES+"'>" + 
			stringPath + "</path>";
	Document doc = DOMUtil.parseDocument(xml);
	Element element = DOMUtil.getFirstChildElement(doc);
	return new ItemPathHolder(element).toItemPath();
	
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:11,代码来源:TestExpressionUtil.java

示例10: serializeInternal

import com.evolveum.midpoint.util.DOMUtil; //导入方法依赖的package包/类
@NotNull
   private Element serializeInternal(@NotNull RootXNode rootxnode, Element parentElement) throws SchemaException {
	QName rootElementName = rootxnode.getRootElementName();
	Element topElement = createElement(rootElementName, parentElement);
	if (parentElement != null) {
		parentElement.appendChild(topElement);
	}
	QName typeQName = rootxnode.getTypeQName();
	if (typeQName != null && rootxnode.isExplicitTypeDeclaration()) {
           DOMUtil.setXsiType(topElement, setQNamePrefixExplicitIfNeeded(typeQName));
	}
	XNode subnode = rootxnode.getSubnode();
	if (subnode instanceof PrimitiveXNode){
		serializePrimitiveElementOrAttribute((PrimitiveXNode) subnode, topElement, rootElementName, false);
		return DOMUtil.getFirstChildElement(topElement);
	}
	if (subnode instanceof MapXNode) {
		// at this point we can put frequently used namespaces (e.g. c, t, q, ri) into the document to eliminate their use
		// on many places inside the doc (MID-2198)
		DOMUtil.setNamespaceDeclarations(topElement, getNamespacePrefixMapper().getNamespacesDeclaredByDefault());
		serializeMap((MapXNode) subnode, topElement);
	} else if (subnode.isHeterogeneousList()) {
		DOMUtil.setNamespaceDeclarations(topElement, getNamespacePrefixMapper().getNamespacesDeclaredByDefault());
		serializeExplicitList((ListXNode) subnode, topElement);
	} else {
		throw new SchemaException("Sub-root xnode is not a map nor an explicit list, cannot serialize to XML (it is "+subnode+")");
	}
	addDefaultNamespaceDeclaration(topElement);
	return topElement;
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:31,代码来源:DomLexicalWriter.java

示例11: readObjects

import com.evolveum.midpoint.util.DOMUtil; //导入方法依赖的package包/类
private List<RootXNode> readObjects(Document document) throws SchemaException{
	Element root = DOMUtil.getFirstChildElement(document);
	QName objectsMarker = schemaRegistry.getPrismContext().getObjectsElementName();
	if (objectsMarker != null && !QNameUtil.match(DOMUtil.getQName(root), objectsMarker)) {
		return Collections.singletonList(read(root));
	} else {
		List<RootXNode> rv = new ArrayList<>();
		for (Element child : DOMUtil.listChildElements(root)) {
			rv.add(read(child));
		}
		return rv;
	}
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:14,代码来源:DomLexicalProcessor.java

示例12: serializeSingleElementMapToElement

import com.evolveum.midpoint.util.DOMUtil; //导入方法依赖的package包/类
public Element serializeSingleElementMapToElement(MapXNode xmap) throws SchemaException {
	if (xmap == null || xmap.isEmpty()) {
		return null;
	}
	Entry<QName, XNode> subEntry = xmap.getSingleSubEntry(xmap.toString());
	Element parent = serializeToElement(xmap, subEntry.getKey());
	return DOMUtil.getFirstChildElement(parent);
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:9,代码来源:DomLexicalProcessor.java

示例13: 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

示例14: processXsd

import com.evolveum.midpoint.util.DOMUtil; //导入方法依赖的package包/类
private void processXsd(Path filePath, File workDir, File outDir) throws MojoExecutionException, MojoFailureException {
	Document dom = DOMUtil.parseFile(filePath.toFile());
	Element rootElement = DOMUtil.getFirstChildElement(dom);
	if (translateSchemaLocation) {
		processXsdElement(rootElement, filePath, workDir, outDir);
	}
	serializeXml(dom, filePath, workDir, outDir);
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:9,代码来源:SchemaDistMojo.java

示例15: readFromStreamAndValidate

import com.evolveum.midpoint.util.DOMUtil; //导入方法依赖的package包/类
private EventResult readFromStreamAndValidate(XMLStreamReader stream, OperationResult objectResult,
		Map<String, String> rootNamespaceDeclarations, OperationResult validatorResult,
		DOMConverter domConverter) {

	objectResult.addContext(START_LINE_NUMBER, stream.getLocation().getLineNumber());

	Document objectDoc;
	try {
		// Parse the object from stream to DOM
		objectDoc = domConverter.buildDocument(stream);
	} catch (XMLStreamException ex) {
		validatorResult.recordFatalError("XML parsing error: " + ex.getMessage(), ex);
		if (handler != null) {
			handler.handleGlobalError(validatorResult);
		}
		objectResult.recordFatalError(ex);
		return EventResult.skipObject(ex.getMessage());
	}

	objectResult.addContext(END_LINE_NUMBER, stream.getLocation().getLineNumber());

	// This element may not have complete namespace definitions for a
	// stand-alone
	// processing, therefore copy namespace definitions from the root
	// element
	Element objectElement = DOMUtil.getFirstChildElement(objectDoc);
	DOMUtil.setNamespaceDeclarations(objectElement, rootNamespaceDeclarations);

	return validateObjectInternal(objectElement, objectResult, validatorResult);
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:31,代码来源:Validator.java


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