gov.nist.toolkit.utilities.xml.Util.parse_xml()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(175)

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

Util.parse_xml介绍

暂无

代码示例

代码示例来源:origin: usnistgov/iheos-toolkit2

  1. public OMFormatter(String xml) throws XdsInternalException, FactoryConfigurationError {
  2. if (xml == null || xml.equals(""))
  3. ele = null;
  4. else
  5. ele = Util.parse_xml(xml);
  6. }

代码示例来源:origin: usnistgov/iheos-toolkit2

  1. public static OMElement parse_xml(Object o) throws FactoryConfigurationError, XdsInternalException {
  2. if (o instanceof String)
  3. return parse_xml((String) o);
  4. if (o instanceof InputStream)
  5. return parse_xml((InputStream) o);
  6. if (o instanceof File)
  7. return parse_xml((File) o);
  8. if (o instanceof OMElement)
  9. return (OMElement) o;
  10. throw new XdsInternalException("Util.parse_xml(): do not understand input format " + o.getClass().getName());
  11. }

代码示例来源:origin: usnistgov/iheos-toolkit2

  1. static public Metadata parse(String metadata) throws XdsInternalException, MetadataException {
  2. OMElement ele = Util.parse_xml(metadata);
  3. return parse(ele);
  4. }
  5. }

代码示例来源:origin: usnistgov/iheos-toolkit2

  1. public Metadata(File metadata_file) throws XdsInternalException,
  2. MetadataException, MetadataValidationException {
  3. metadata = Util.parse_xml(metadata_file);
  4. runParser();
  5. }

代码示例来源:origin: usnistgov/iheos-toolkit2

  1. public LogFileContentDTO build(OMElement testresults, boolean incompleteOk) throws Exception {
  2. log = Util.parse_xml(testresults);
  3. init(incompleteOk);
  4. return c;
  5. }

代码示例来源:origin: usnistgov/iheos-toolkit2

  1. public LogFileContentDTO build(File logfile, boolean incompleteOk) throws Exception {
  2. // c.setInputFile(logfile);
  3. FileInputStream fis = new FileInputStream(logfile);
  4. if (fis != null) {
  5. log = Util.parse_xml(fis);
  6. init(false);
  7. fis.close();
  8. }
  9. return c;
  10. }

代码示例来源:origin: usnistgov/iheos-toolkit2

  1. /**
  2. * get parsed log.xml file for desired test step.
  3. * @param test_dir String path of test step we want log from, relative to
  4. * this test step. For example, "../12029/submit".
  5. * @return parsed log.xml file root element.
  6. * @throws FactoryConfigurationError if your xml parser is really messed up.
  7. * @throws XdsInternalException if the log.xml file is missing or messed up.
  8. */
  9. public OMElement getLogContents(String test_dir) throws FactoryConfigurationError, XdsInternalException {
  10. if (debug) logger.info("Load LogFile " + getLogFileName(test_dir));
  11. return Util.parse_xml(new File(getLogFileName(test_dir)));
  12. }

代码示例来源:origin: usnistgov/iheos-toolkit2

  1. public SectionDefinitionDAO getSection(String sectionName) throws XdsInternalException {
  2. if (sectionName == null) {
  3. return parseTestPlan(Util.parse_xml(new File(testDir, "testplan.xml")), sectionName);
  4. }
  5. try {
  6. return parseTestPlan(Util.parse_xml(new File(new File(testDir, sectionName), "testplan.xml")), sectionName);
  7. } catch (Exception e) {
  8. throw new XdsInternalException("Unable to load test definition for test " + getId() + " section " + sectionName, e);
  9. }
  10. }

代码示例来源:origin: usnistgov/iheos-toolkit2

  1. public AllCodes load(File codesFile) {
  2. try {
  3. OMElement rawCodes = Util.parse_xml(codesFile);
  4. return new CodesParser().parse(rawCodes);
  5. } catch (Exception e) {
  6. throw new RuntimeException("Cannot load codes file <" + codesFile + ">.");
  7. }
  8. }

代码示例来源:origin: usnistgov/iheos-toolkit2

  1. static public void main(String[] args) {
  2. OMElement ele;
  3. try {
  4. ele = Util.parse_xml(new File(args[0]));
  5. System.out.println(new OMFormatter(ele).toString());
  6. } catch (Exception e) {
  7. System.out.println(ExceptionUtil.exception_details(e));
  8. }
  9. }
  10. }

代码示例来源:origin: usnistgov/iheos-toolkit2

  1. public XdstestLog(File logfile) throws XdsInternalException, FactoryConfigurationError {
  2. OMElement log = Util.parse_xml(logfile);
  3. List<OMElement> stepLst = XmlUtil.childrenWithLocalName(log, "TestStep");
  4. for (OMElement stp : stepLst) {
  5. String id = stp.getAttributeValue(MetadataSupport.id_qname);
  6. steps.put(id, stp);
  7. }
  8. status = "Pass".equals((log.getAttributeValue(new QName("status"))));
  9. }

代码示例来源:origin: usnistgov/iheos-toolkit2

  1. static void test1() throws XdsInternalException, FactoryConfigurationError {
  2. String x = "<foo/>";
  3. OMElement x_ele = Util.parse_xml(x);
  4. OMElement y_ele = Util.deep_copy(x_ele);
  5. if (!y_ele.getLocalName().equals("foo"))
  6. System.out.println("test1 fails, name is " + y_ele.getLocalName());
  7. OMElement z_ele = Util.parse_xml("<z/>");
  8. z_ele.addChild(y_ele);
  9. System.out.println("test1: " + z_ele.toString());
  10. }

代码示例来源:origin: usnistgov/iheos-toolkit2

  1. static void test2() throws XdsInternalException, FactoryConfigurationError {
  2. String x = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <foo/>";
  3. OMElement x_ele = Util.parse_xml(x);
  4. OMElement y_ele = Util.deep_copy(x_ele);
  5. if (!y_ele.getLocalName().equals("foo"))
  6. System.out.println("test2 fails, name is " + y_ele.getLocalName());
  7. OMElement z_ele = Util.parse_xml("<z/>");
  8. z_ele.addChild(y_ele);
  9. System.out.println("test2: " + z_ele.toString());
  10. }

代码示例来源:origin: usnistgov/iheos-toolkit2

  1. public static OMElement deep_copy(OMElement in) throws XdsInternalException {
  2. String str = new OMFormatter(in).toString();
  3. // String str = in.toString();
  4. OMElement res = parse_xml(str);
  5. return res;
  6. }

代码示例来源:origin: usnistgov/iheos-toolkit2

  1. public Validator(File test_assertion_file, String subset_name) throws XdsInternalException {
  2. test_assertions = Util.parse_xml(test_assertion_file);
  3. if (subset_name != null) {
  4. test_assertions = XmlUtil.firstChildWithLocalName(test_assertions, subset_name);
  5. if ( test_assertions == null)
  6. throw new XdsInternalException("Validator: assertion subset " + subset_name + " not found in file " + test_assertion_file);
  7. }
  8. }

代码示例来源:origin: usnistgov/iheos-toolkit2

  1. void walkTestPlan(File testPlanFile) throws FactoryConfigurationError, Exception {
  2. OMElement testplanEle = Util.parse_xml(testPlanFile);
  3. List<OMElement> steps = XmlUtil.childrenWithLocalName(testplanEle, "TestStep");
  4. for(int i=0; i<steps.size(); i++) {
  5. OMElement stepEle = steps.get(i);
  6. doStep(stepEle.getLocalName());
  7. }
  8. }
  9. protected String join(String[] parts, int first, int last, String separator) {

代码示例来源:origin: usnistgov/iheos-toolkit2

  1. OMElement sign(OMElement element) throws XdsInternalException {
  2. byte[] in = element.toString().getBytes();
  3. XMLDSigProcessor dsig = new XMLDSigProcessor();
  4. try {
  5. byte[] out = dsig.signSAMLAssertionsEnveloped(in);
  6. OMElement outEle = Util.parse_xml(new ByteArrayInputStream(out));
  7. return outEle;
  8. } catch (Exception e) {
  9. throw new XdsInternalException(e.getMessage(), e);
  10. }
  11. }

代码示例来源:origin: usnistgov/iheos-toolkit2

  1. public void findBadCodesTest() throws XdsInternalException, FactoryConfigurationError {
  2. OMElement rawCode = Util.parse_xml(classificationsString);
  3. CodeUpdater engine = new CodeUpdater();
  4. engine.init(codesFile);
  5. List<OMElement> badCodes = engine.nonConformingCodes(rawCode);
  6. assertEquals(1, badCodes.size());
  7. }

代码示例来源:origin: usnistgov/iheos-toolkit2

  1. public void codeFromClassificationTest() throws XdsInternalException, FactoryConfigurationError {
  2. OMElement rawCode = Util.parse_xml(classificationString);
  3. CodeUpdater engine = new CodeUpdater();
  4. Code code = engine.code(rawCode);
  5. assertTrue("DEMO-Procedure".equals(code.getCode()));
  6. assertTrue("Procedure".equals(code.getDisplay()));
  7. assertTrue("1.3.6.1.4.1.21367.100.1".equals(code.getScheme()));
  8. }

代码示例来源:origin: usnistgov/iheos-toolkit2

  1. public void updateCodeTest() throws XdsInternalException, FactoryConfigurationError {
  2. OMElement rawCode = Util.parse_xml(classificationString);
  3. CodeUpdater engine = new CodeUpdater();
  4. Code code = new Code("MyCode", "MyScheme", "MyDisplay");
  5. engine.updateClassification(rawCode, code);
  6. Code code2 = engine.code(rawCode);
  7. assertTrue(code.equals(code2));
  8. }

相关文章