本文整理汇总了Java中com.mycila.xmltool.XMLDoc.from方法的典型用法代码示例。如果您正苦于以下问题:Java XMLDoc.from方法的具体用法?Java XMLDoc.from怎么用?Java XMLDoc.from使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.mycila.xmltool.XMLDoc
的用法示例。
在下文中一共展示了XMLDoc.from方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processConfigFile
import com.mycila.xmltool.XMLDoc; //导入方法依赖的package包/类
public void processConfigFile(Engine engine, File configFile) throws ValidatorConfigurationException {
XMLTag doc = XMLDoc.from(configFile, true);
int ruleCounter = 0;
for (Element childEl : doc.getChildElement()) {
String elementName = childEl.getTagName();
switch (elementName) {
case "pattern-def":
processNamedPatternDefinition(engine, childEl);
break;
case "value-def":
processNamedValueDefinition(engine, childEl);
break;
case "rules-section":
processRulesSectionDefinition(engine, childEl, ruleCounter++);
break;
case "namespaces":
processNamespaces(engine, childEl);
default:
//nothing
//System.out.println(String.format("ignoring element %s", elementName));
}
}
}
示例2: canPull
import com.mycila.xmltool.XMLDoc; //导入方法依赖的package包/类
@Test
public void canPull() throws InterruptedException {
stubFor(post(urlEqualTo("/wsman"))
.willReturn(aResponse()
.withHeader("Content-Type", "Content-Type: application/soap+xml; charset=utf-8")
.withBodyFile("pull-response.xml")));
List<Node> nodes = Lists.newArrayList();
client.pull("c6595ee1-2664-1664-801f-c115cfb5fe14", WSManConstants.CIM_ALL_AVAILABLE_CLASSES, nodes, false);
dumpRequestsToStdout();
assertEquals(1, nodes.size());
XMLTag tag = XMLDoc.from(nodes.get(0), true);
int inputVoltage = Integer.valueOf(tag.gotoChild("n1:InputVoltage").getText());
assertEquals(120, inputVoltage);
}
示例3: canGet
import com.mycila.xmltool.XMLDoc; //导入方法依赖的package包/类
@Test
public void canGet() throws FileNotFoundException, IOException {
stubFor(post(urlEqualTo("/wsman"))
.willReturn(aResponse()
.withHeader("Content-Type", "Content-Type: application/soap+xml; charset=utf-8")
.withBodyFile("get-response.xml")));
Map<String, String> selectors = Maps.newHashMap();
selectors.put("CreationClassName", "DCIM_ComputerSystem");
selectors.put("Name", "srv:system");
Node node = client.get("http://schemas.dell.com/wbem/wscim/1/cim-schema/2/DCIM_ComputerSystem", selectors);
dumpRequestsToStdout();
assertNotNull(node);
XMLTag tag = XMLDoc.from(node, true);
int primaryStatus = Integer.valueOf(tag.gotoChild("n1:PrimaryStatus").getText());
assertEquals(1, primaryStatus);
}
示例4: canGetSystemPrimaryStatus
import com.mycila.xmltool.XMLDoc; //导入方法依赖的package包/类
@Test
public void canGetSystemPrimaryStatus() throws FileNotFoundException, IOException {
Map<String, String> selectors = Maps.newHashMap();
selectors.put("CreationClassName", "DCIM_ComputerSystem");
selectors.put("Name", "srv:system");
Node node = client.get("http://schemas.dell.com/wbem/wscim/1/cim-schema/2/DCIM_ComputerSystem", selectors);
assertNotNull(node);
assertEquals("DCIM_ComputerSystem", node.getLocalName());
assertEquals("http://schemas.dell.com/wbem/wscim/1/cim-schema/2/DCIM_ComputerSystem", node.getNamespaceURI());
XMLTag tag = XMLDoc.from(node, true);
System.err.println(tag.getCurrentTagName());
System.err.println(tag);
int primaryStatus = Integer.valueOf(tag.gotoChild("n1:PrimaryStatus").getText());
assertEquals(1, primaryStatus);
}
示例5: parseProfile
import com.mycila.xmltool.XMLDoc; //导入方法依赖的package包/类
public MetadataProfile parseProfile(File profileXmlFile) throws ValidatorConfigurationException {
//LOG.info(String.format("parsing %s", templateXml.getAbsolutePath()));
MetadataProfile metadataProfile = new MetadataProfile();
XMLTag doc = XMLDoc.from(profileXmlFile, true); //ignoring namespaces
metadataProfile.setValidatorVersion(doc.getAttribute("validatorVersion"));
metadataProfile.setDmf(doc.getAttribute("dmf"));
checkValidatorVersionCorrect(metadataProfile.getValidatorVersion(), profileXmlFile);
//TODO: podobne testovat dmf
for (Element childEl : doc.getChildElement()) {
String elementName = childEl.getTagName();
switch (elementName) {
case "info": //won't be machine processed
break;
case "namespaces":
metadataProfile.setNamespaces(parseNamespaces(childEl));
break;
case "dictionaries":
metadataProfile.setDeclaredDictionaries(parseDeclaredDictionaries(childEl, profileXmlFile));
break;
case "rootElement":
ExpectedElementDefinition rootElementDef = parseElementDefinition(metadataProfile, null, childEl, profileXmlFile);
rootElementDef.setRepeatable(false); //quick fix
metadataProfile.setRootElementDefinition(rootElementDef);
break;
default:
//nothing
}
}
return metadataProfile;
}
示例6: canPullRecursively
import com.mycila.xmltool.XMLDoc; //导入方法依赖的package包/类
@Test
public void canPullRecursively() throws InterruptedException {
stubFor(post(urlEqualTo("/wsman")).inScenario("Recursive pull")
.whenScenarioStateIs(Scenario.STARTED)
.willReturn(aResponse()
.withHeader("Content-Type", "Content-Type: application/soap+xml; charset=utf-8")
.withBodyFile("recursive-pull-response-1.xml"))
.willSetStateTo("Pull #2"));
stubFor(post(urlEqualTo("/wsman")).inScenario("Recursive pull")
.whenScenarioStateIs("Pull #2")
.willReturn(aResponse()
.withHeader("Content-Type", "Content-Type: application/soap+xml; charset=utf-8")
.withBodyFile("recursive-pull-response-2.xml")));
List<Node> nodes = Lists.newArrayList();
client.pull("c6595ee1-2664-1664-801f-c115cfb5fe14", WSManConstants.CIM_ALL_AVAILABLE_CLASSES, nodes, true);
dumpRequestsToStdout();
assertEquals(2, nodes.size());
XMLTag tag = XMLDoc.from(nodes.get(0), true);
int inputVoltage = Integer.valueOf(tag.gotoChild("n1:InputVoltage").getText());
assertEquals(120, inputVoltage);
tag = XMLDoc.from(nodes.get(1), true);
inputVoltage = Integer.valueOf(tag.gotoChild("n1:InputVoltage").getText());
assertEquals(121, inputVoltage);
}
示例7: canGetInputVoltage
import com.mycila.xmltool.XMLDoc; //导入方法依赖的package包/类
@Test
public void canGetInputVoltage() {
List<Node> powerSupplies = Lists.newLinkedList();
client.enumerateAndPullUsingFilter(
WSManConstants.CIM_ALL_AVAILABLE_CLASSES,
WSManConstants.XML_NS_WQL_DIALECT,
"select DeviceDescription,PrimaryStatus,TotalOutputPower,InputVoltage,Range1MaxInputPower,FirmwareVersion,RedundancyStatus from DCIM_PowerSupplyView where DetailedState != 'Absent' and PrimaryStatus != 0",
powerSupplies,
true);
assertEquals(1, powerSupplies.size());
XMLTag tag = XMLDoc.from(powerSupplies.get(0), true);
int inputVoltage = Integer.valueOf(tag.gotoChild("n1:InputVoltage").getText());
assertEquals(120, inputVoltage);
}
示例8: processProfile
import com.mycila.xmltool.XMLDoc; //导入方法依赖的package包/类
private void processProfile(ImageUtil util, File profileDefinitionFile, Map<ImageUtil, J2kProfile> profiles) throws ValidatorConfigurationException {
XMLTag doc = XMLDoc.from(profileDefinitionFile, true);
J2kProfile profile = buildProfile(util, doc.getCurrentTag());
profiles.put(util, profile);
}