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


Java DocumentException类代码示例

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


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

示例1: readFromSystemPath

import org.dom4j.DocumentException; //导入依赖的package包/类
/**
 * 从操作系统路径中加载配置文件
 * @param filePath filePath
 * @throws IOException  IOException
 * @throws FileNotFoundException  FileNotFoundException
 * @throws DocumentException  DocumentException
 * @throws SAXException SAXException
 */
public void readFromSystemPath(String filePath) throws FileNotFoundException, 
	IOException, DocumentException, SAXException
{
	configFile = new File(filePath);
	if(!configFile.isFile())
	{
		throw new ConfigException(String.format("Target file [%s] is not a file.", filePath), "");
	}
	else if(!filePath.endsWith(".xml"))
	{
		logger.warn("Target file [%s] is not end with .xml", filePath);
	}
	
	try(InputStream configInput = new FileInputStream(configFile))
	{
		read(configInput);
	}
}
 
开发者ID:LinuxSuRen,项目名称:phoenix.webui.framework,代码行数:27,代码来源:Phoenix.java

示例2: parseXml2Map

import org.dom4j.DocumentException; //导入依赖的package包/类
/**
 * 解析XML并将其节点元素压入Dto返回(基于节点值形式的XML格式)
 * 
 * @param pStrXml 待解析的XML字符串
 * @return outDto 返回Dto
 */
public static final Map parseXml2Map(String pStrXml) {
	Map map = new HashMap();
	String strTitle = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
	Document document = null;
	try {
		if (pStrXml.indexOf("<?xml") < 0)
			pStrXml = strTitle + pStrXml;
		document = DocumentHelper.parseText(pStrXml);

	} catch (DocumentException e) {
		log.error("==开发人员请注意:==\n将XML格式的字符串转换为XML DOM对象时发生错误啦!" + "\n详细错误信息如下:", e);
	}
	// 获取根节点
	Element elNode = document.getRootElement();
	// 遍历节点属性值将其压入Dto
	for (Iterator it = elNode.elementIterator(); it.hasNext();) {
		Element leaf = (Element) it.next();
		map.put(leaf.getName().toLowerCase(), leaf.getData());
	}
	return map;
}
 
开发者ID:tb544731152,项目名称:iBase4J,代码行数:28,代码来源:XmlUtil.java

示例3: testFindUserAuthenticatedUser

import org.dom4j.DocumentException; //导入依赖的package包/类
@Test
@SuppressWarnings({
    "rawtypes", "unchecked"
})
public void testFindUserAuthenticatedUser() throws IOException, DocumentException {
    Map<String, String> users = new HashMap<String, String>();
    users.put("alpha", "first");
    users.put("bravo", "second");
    users.put("charlie", "third");

    for (String key : users.keySet()) {
        mockInstance = new DrupalMultisiteAuthModuleMock();
        Set<String> roles = findRoles(key, users.get(key));
        assertTrue(roles.contains("authenticated user"));
    }
}
 
开发者ID:discoverygarden,项目名称:fcrepo3-security-jaas,代码行数:17,代码来源:DrupalMultisiteAuthModuleTest.java

示例4: dataSource

import org.dom4j.DocumentException; //导入依赖的package包/类
/**
 * 测试简单流程,数据在数据源(xml格式)中
 * @throws SAXException 
 * @throws DocumentException 
 * @throws IOException 
 */
@Test
public void dataSource() throws IOException, DocumentException, SAXException
{
	util.readFromClassPath("elements/xml/maimai.xml");
	util.initData();
	
	HomePage homePage = util.getPage(HomePage.class);
	Assert.assertNotNull(homePage);

	Assert.assertNotNull(homePage.getUrl());
	Assert.assertTrue("起始页地址不合法",
			homePage.paramTranslate(homePage.getUrl()).startsWith("http"));
	homePage.open();
	Button toLoginBut = homePage.getToLoginBut();
	Assert.assertNotNull(toLoginBut);
	toLoginBut.click();
	
	LoginPage loginPage = util.getPage(LoginPage.class);
	Assert.assertNotNull(loginPage);
	
	Text phone = loginPage.getPhone();
	Assert.assertNotNull(phone);
	Assert.assertNotNull("数据未从数据源中加载", phone.getValue());
	phone.fillNotBlankValue();
}
 
开发者ID:LinuxSuRen,项目名称:phoenix.webui.framework,代码行数:32,代码来源:SettingUtilTest.java

示例5: testdeployDefinition

import org.dom4j.DocumentException; //导入依赖的package包/类
@Test
public void testdeployDefinition() {
    // 初始化

    SAXReader reader = new SAXReader();
    // 拿不到信息
    //URL url = this.getClass().getResource("/multipleTask.xml");
    URL url = this.getClass().getResource("/singleTask.xml");
    Document document = null;
    try {
        document = reader.read(url);
    } catch (DocumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    String definitionContent = document.asXML();
    // deploy first time
    DefinitionHelper.getInstance().deployDefinition("singleTask", "测试单人任务流程", definitionContent, true);
    //DefinitionHelper.getInstance().deployDefinition("multipleTask", "测试多人任务流程", definitionContent, true);
}
 
开发者ID:alibaba,项目名称:bulbasaur,代码行数:22,代码来源:TaskTest.java

示例6: getDocument

import org.dom4j.DocumentException; //导入依赖的package包/类
public static Document getDocument(Reader reader) throws DocumentException, IOException {
    SAXReader saxReader = new SAXReader();

    Document document = null;
    try {
        document = saxReader.read(reader);
    } catch (DocumentException e) {
        throw e;
    } finally {
        if (reader != null) {
            reader.close();
        }
    }

    return document;
}
 
开发者ID:thebeastshop,项目名称:liteFlow,代码行数:17,代码来源:Dom4JReader.java

示例7: parseXml2Map

import org.dom4j.DocumentException; //导入依赖的package包/类
/**
 * 解析XML并将其节点元素压入Dto返回(基于节点值形式的XML格式)
 * 
 * @param pStrXml 待解析的XML字符串
 * @param pXPath 节点路径(例如:"//paralist/row" 则表示根节点paralist下的row节点的xPath路径)
 * @return outDto 返回Dto
 */
public static final Map parseXml2Map(String pStrXml, String pXPath) {
    Map map = new HashMap();
    String strTitle = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
    Document document = null;
    try {
        if (pStrXml.indexOf("<?xml") < 0) pStrXml = strTitle + pStrXml;
        document = DocumentHelper.parseText(pStrXml);
    } catch (DocumentException e) {
        logger.error("==开发人员请注意:==\n将XML格式的字符串转换为XML DOM对象时发生错误啦!" + "\n详细错误信息如下:", e);
    }
    // 获取根节点
    Element elNode = document.getRootElement();
    // 遍历节点属性值将其压入Dto
    for (Iterator it = elNode.elementIterator(); it.hasNext();) {
        Element leaf = (Element)it.next();
        map.put(leaf.getName().toLowerCase(), leaf.getData());
    }
    return map;
}
 
开发者ID:iBase4J,项目名称:iBase4J-Common,代码行数:27,代码来源:XmlUtil.java

示例8: loadQueryCollection

import org.dom4j.DocumentException; //导入依赖的package包/类
public void loadQueryCollection(String location)
{
    try
    {
        InputStream is = this.getClass().getClassLoader().getResourceAsStream(location);
        SAXReader reader = new SAXReader();
        Document document = reader.read(is);
        is.close();
        QueryCollection collection = QueryCollectionImpl.createQueryCollection(document.getRootElement(), dictionaryService, namespaceService);
        collections.put(location, collection);
    }
    catch (DocumentException de)
    {
        throw new AlfrescoRuntimeException("Error reading XML", de);
    }
    catch (IOException e)
    {
        throw new AlfrescoRuntimeException("IO Error reading XML", e);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:21,代码来源:QueryRegisterComponentImpl.java

示例9: testdeployDefinition

import org.dom4j.DocumentException; //导入依赖的package包/类
@Test
public void testdeployDefinition() {
    // 初始化

    SAXReader reader = new SAXReader();
    // 拿不到信息
    URL url = this.getClass().getResource("/process12.xml");
    Document document = null;
    try {
        document = reader.read(url);
    } catch (DocumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    String definitionContent = document.asXML();
    // deploy first time
    DefinitionHelper.getInstance().deployDefinition("process", "测试流程", definitionContent, true);
}
 
开发者ID:alibaba,项目名称:bulbasaur,代码行数:20,代码来源:PersistDefinationTest.java

示例10: shouldNotModifyDocumentWhenAllXPathsTraversable

import org.dom4j.DocumentException; //导入依赖的package包/类
@Test
public void shouldNotModifyDocumentWhenAllXPathsTraversable()
        throws XPathExpressionException, DocumentException, IOException {
    Map<String, Object> xmlProperties = fixtureAccessor.getXmlProperties();
    String xml = fixtureAccessor.getPutValueXml();
    Document oldDocument = stringToXml(xml);
    Document builtDocument = new XmlBuilder(namespaceContext)
            .putAll(xmlProperties)
            .build(oldDocument);

    assertThat(xmlToString(builtDocument)).isEqualTo(xml);

    builtDocument = new XmlBuilder(namespaceContext)
            .putAll(xmlProperties.keySet())
            .build(oldDocument);

    assertThat(xmlToString(builtDocument)).isEqualTo(xml);
}
 
开发者ID:SimY4,项目名称:xpath-to-xml,代码行数:19,代码来源:XmlBuilderTest.java

示例11: getIdDirect

import org.dom4j.DocumentException; //导入依赖的package包/类
/**
 *  Perform GetId by directly issuing request URL
 *
 *@param  collection  Description of the Parameter
 */
private void getIdDirect(String collection) {
	String qs = "verb=" + verb;
	qs += "&collection=" + collection;
	URL url;
	Document doc;
	try {
		url = new URL(baseUrl + "?" + qs);
		doc = Dom4jUtils.getXmlDocument(url);
	} catch (MalformedURLException mue) {
		prtln("URL error: " + mue.getCause());
		return;
	} catch (org.dom4j.DocumentException de) {
		prtln(de.getMessage());
		return;
	}

	prtln(Dom4jUtils.prettyPrint(doc));
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:24,代码来源:DCSServiceTester.java

示例12: setupAwbBundleInfos

import org.dom4j.DocumentException; //导入依赖的package包/类
public static void setupAwbBundleInfos(AppVariantContext appVariantContext) throws IOException, DocumentException {

        String apkVersion = appVariantContext.getVariantConfiguration().getVersionName();

        AtlasDependencyTree atlasDependencyTree = AtlasBuildContext.androidDependencyTrees.get(
            appVariantContext.getScope().
                getVariantConfiguration().getFullName());

        /**
         * name Is artifictId
         */
        Map<String, BundleInfo> bundleInfoMap = getBundleInfoMap(appVariantContext);

        String baseVersion = apkVersion;

        if (null != appVariantContext.apContext && null != appVariantContext.apContext.getBaseManifest() && appVariantContext.apContext.getBaseManifest().exists()){
            baseVersion = ManifestFileUtils.getVersionName(appVariantContext.apContext.getBaseManifest());
        }

        for (AwbBundle awbBundle : atlasDependencyTree.getAwbBundles()) {
            update(awbBundle, bundleInfoMap, appVariantContext, apkVersion, baseVersion);
        }
    }
 
开发者ID:alibaba,项目名称:atlas,代码行数:24,代码来源:BundleInfoUtils.java

示例13: main

import org.dom4j.DocumentException; //导入依赖的package包/类
public static void main(String[] argv) throws Exception {
	if (argv.length < 2) {
		System.err.println("Usage: " + CheckMessages.class.getName() +
			" <plugin descriptor xml> <bug description xml> [<bug description xml>...]");
		System.exit(1);
	}

	String pluginDescriptor = argv[0];

	try {
		CheckMessages checkMessages = new CheckMessages(pluginDescriptor);
		for (int i = 1; i < argv.length; ++i) {
			String messagesFile = argv[i];
			System.out.println("Checking messages file " + messagesFile);
			checkMessages.checkMessages(new XMLFile(messagesFile));
		}
	} catch (DocumentException e) {
		System.err.println("Could not verify messages files: " + e.getMessage());
		System.exit(1);
	}

	System.out.println("Messages files look OK!");
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:24,代码来源:CheckMessages.java

示例14: getApplicationId

import org.dom4j.DocumentException; //导入依赖的package包/类
/**
 * Get the packageId for the manifest file
 *
 * @param manifestFile
 * @return
 */
public static String getApplicationId(File manifestFile) {
    SAXReader reader = new SAXReader();
    if (manifestFile.exists()) {
        Document document = null;// Read the XML file
        try {
            document = reader.read(manifestFile);
            Element root = document.getRootElement();// Get the root node
            String packageName = root.attributeValue("package");
            return packageName;
        } catch (DocumentException e) {
            e.printStackTrace();
        }
    }
    return null;
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:22,代码来源:ManifestFileUtils.java

示例15: getVersionName

import org.dom4j.DocumentException; //导入依赖的package包/类
/**
 * Update the plug-in's minSdkVersion and targetSdkVersion
 *
 * @param androidManifestFile
 * @throws IOException
 * @throws DocumentException
 */
public static String getVersionName(File androidManifestFile) throws IOException, DocumentException {
    SAXReader reader = new SAXReader();
    String versionName = "";
    if (androidManifestFile.exists()) {
        Document document = reader.read(androidManifestFile);// Read the XML file
        Element root = document.getRootElement();// Get the root node
        if ("manifest".equalsIgnoreCase(root.getName())) {
            List<Attribute> attributes = root.attributes();
            for (Attribute attr : attributes) {
                if (StringUtils.equalsIgnoreCase(attr.getName(), "versionName")) {
                    versionName = attr.getValue();
                }
            }
        }
    }
    return versionName;
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:25,代码来源:ManifestFileUtils.java


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