Java 类org.dom4j.DocumentException 实例源码

项目:iBase4J    文件:XmlUtil.java   
/**
 * 解析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;
}
项目:fcrepo3-security-jaas    文件:DrupalMultisiteAuthModuleTest.java   
@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"));
    }
}
项目:phoenix.webui.framework    文件:Phoenix.java   
/**
 * 从操作系统路径中加载配置文件
 * @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);
    }
}
项目:phoenix.webui.framework    文件:SettingUtilTest.java   
/**
 * 测试简单流程,数据在数据源(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();
}
项目:bulbasaur    文件:TaskTest.java   
@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);
}
项目:liteFlow    文件:Dom4JReader.java   
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;
}
项目:iBase4J-Common    文件:XmlUtil.java   
/**
 * 解析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;
}
项目:JAVA-    文件:XmlUtil.java   
/**
 * 解析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;
}
项目:alfresco-repository    文件:QueryRegisterComponentImpl.java   
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);
    }
}
项目:bulbasaur    文件:PersistDefinationTest.java   
@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);
}
项目:xpath-to-xml    文件:XmlBuilderTest.java   
@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);
}
项目:joai-project    文件:DCSServiceTester.java   
/**
 *  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));
}
项目:atlas    文件:BundleInfoUtils.java   
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);
        }
    }
项目:liteFlow    文件:Dom4JReader.java   
public static Document getDocument(InputStream inputStream) throws DocumentException, IOException {
    SAXReader saxReader = new SAXReader();

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

    return document;
}
项目:parabuild-ci    文件:CheckMessages.java   
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!");
}
项目:atlas    文件:ManifestFileUtils.java   
/**
 * 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;
}
项目:atlas    文件:ManifestFileUtils.java   
/**
 * 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;
}
项目:atlas    文件:ManifestFileUtils.java   
public static String getVersionCode(File androidManifestFile) throws IOException, DocumentException {
    SAXReader reader = new SAXReader();
    String versionCode = "";
    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(), "versionCode")) {
                    versionCode = attr.getValue();
                }
            }
        }
    }
    return versionCode;
}
项目:jwx    文件:InMessageFactory.java   
/**
 * 生成请求消息
 * @param xmlText
 * @return
 * @throws DocumentException
 * @throws WeixinInMsgHandleException 
 */
public InMessage creator(String xmlText) throws DocumentException, WeixinInMsgHandleException{
    // 获取xml文本document对象
    Document document = DocumentHelper.parseText(xmlText);
    // 得到 xml 根元素
    Element root = document.getRootElement();
    String msgType = root.element("MsgType").getTextTrim();

    InMessage in = null;

    if(REQUEST_EVENT_MESSAGE_TYPE.equals(msgType)){
        in = creatEventMsg(root);
    } else {
        in = creatPlainMsg(root, msgType);
    }

    if(in == null){
        throw new WeixinInMsgHandleException("无法识别的消息请求类型");
    }

    return in;
}
项目:phoenix.webui.suite.runner    文件:SuiteUtils.java   
/**
 * 判断是否为suite的xml配置
 * @param content
 * @return
 */
public static boolean isSuiteXml(byte[] content)
{
    SAXReader reader = new SAXReader();
    try
    {
        Document doc = reader.read(new ByteArrayInputStream(content));
        Element rootEle = doc.getRootElement();

        String rootEleName = rootEle.getName();

        return "suite".equals(rootEleName);
    }
    catch (DocumentException e)
    {
        e.printStackTrace();
    }

    return false;
}
项目:PackagePlugin    文件:FileUtil.java   
/**
 * 摸查项目输出目录
 * <p>
 * @param projectPath
 * @param kind        output 或 src
 * @return
 */
public static String readXML(String projectPath, String kind) {
    try {
        SAXReader saxReader = new SAXReader();
        File classpath = new File(projectPath + "/.classpath");
        if (classpath.exists()) {
            Document document = saxReader.read(classpath);
            List<Element> out = (List<Element>) document.selectNodes("/classpath/classpathentry[@kind='" + kind + "']");
            String tmp = "";
            for (Element out1 : out) {
                String combineaccessrules = out1.attributeValue("combineaccessrules");
                if ("false".equals(combineaccessrules) && "src".equals(kind)) {
                    continue;
                }
                tmp += out1.attributeValue("path") + ",";
            }
            return tmp.isEmpty() ? tmp : tmp.substring(0, tmp.length() - 1);
        }
    } catch (DocumentException ex) {
        MainFrame.LOGGER.log(Level.SEVERE, null, ex);
        JOptionPane.showMessageDialog(null, ex.getLocalizedMessage());
    }
    return "";
}
项目:unitimes    文件:DoubleVarcharSizes.java   
public void generate() throws IOException, DocumentException {
    Document document = read(iConfig);
    Element root = document.getRootElement();
    Element sessionFactoryElement = root.element("session-factory");
    for (Iterator<Element> i = sessionFactoryElement.elementIterator("mapping"); i.hasNext(); ) {
        Element m = i.next();
        String resource = m.attributeValue("resource");
        if (resource == null) continue;
        generate(read(resource).getRootElement(), null);
    }
}
项目:GraphicsViewJambi    文件:ImportSumoNetwork.java   
/**
 * Read all Node in the XML File
 * 
 * @param node
 *      Node to Manage
 */
@SuppressWarnings("unchecked")
public void listNodes(final Element node) throws DocumentException
{
    manageAttributeInfo(node, false);

    //start next node if has
    final Iterator<Element> it = node.elementIterator();
    while (it.hasNext())
    {
        final Element e = it.next();
        listNodes(e);
    }
}
项目:parabuild-ci    文件:CheckMessages.java   
public XMLFile(String filename) throws DocumentException, MalformedURLException {
    this.filename = filename;

    File file = new File(filename);
    SAXReader saxReader = new SAXReader();
    this.document = saxReader.read(file);
}
项目:phoenix.webui.framework    文件:XmlDataSource.java   
/**
 * 解析xml文档
 * @param inputStream
 * @param row 
 * @throws DocumentException 
 */
private void parse(InputStream inputStream, int row) throws DocumentException
{
    Document document = new SAXReader().read(inputStream);

    parse(document, row);
}
项目:banana    文件:MessageUtil.java   
public static Map<String, String> xmlToMap(HttpServletRequest request) throws IOException, DocumentException {
    Map<String, String> rtnMap = new HashMap<>();

    SAXReader reader = new SAXReader();

    try (ServletInputStream in = request.getInputStream()) {
        Document root = reader.read(in);
        Element rootElement = root.getRootElement();

        List<Element> elements = rootElement.elements();
        elements.forEach(e -> rtnMap.put(e.getName(), e.getText()));
    }

    return rtnMap;
}
项目:minlia-iot-xapi    文件:SignUtils.java   
public static Element readerXml(String body,String encode) throws DocumentException {
    SAXReader reader = new SAXReader(false);
    InputSource source = new InputSource(new StringReader(body));
    source.setEncoding(encode);
    Document doc = reader.read(source);
    Element element = doc.getRootElement();
    return element;
}
项目:unitimes    文件:XmlApiHelper.java   
@Override
public Document getRequest(Type requestType) throws IOException {
    Reader reader = iRequest.getReader();
    try {
        return new SAXReader().read(reader);
    } catch (DocumentException e) {
        throw new IOException(e.getMessage(), e);
    } finally {
        reader.close();
    }
}
项目:unitimes    文件:LowercaseTableNames.java   
protected Document read(String resource) throws IOException, DocumentException {
    if (iSource == null) {
        info("  -- reading " + resource + " ...");
        return iSAXReader.read(getClass().getClassLoader().getResourceAsStream(resource));
    } else {
        info("  -- reading " + iSource + File.separator + resource + " ...");
        return iSAXReader.read(new File(iSource + File.separator + resource));
    }
}
项目:sbc-qsystem    文件:Executer.java   
@Override
synchronized public AJsonRPC20 process(CmdParams cmdParams, String ipAdress, byte[] IP) {
    QLog.l().logQUser().debug("saveBoardConfig");
    super.process(cmdParams, ipAdress, IP);
    try {
        MainBoard.getInstance()
            .saveConfig(DocumentHelper.parseText(cmdParams.textData).getRootElement());
    } catch (DocumentException ex) {
        QLog.l().logger().error("Не сохранилась конфигурация табло.", ex);
    }
    return new JsonRPC20OK();
}
项目:iBase4J-Common    文件:XmlUtil.java   
/**
 * 将XML规范的字符串转为List对象(XML基于节点属性值的方式)
 * 
 * @param pStrXml 传入的符合XML格式规范的字符串
 * @return list 返回List对象
 */
public static final List parseXml2List(String pStrXml) {
    List lst = new ArrayList();
    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 elRoot = document.getRootElement();
    // 获取根节点的所有子节点元素
    Iterator elIt = elRoot.elementIterator();
    while (elIt.hasNext()) {
        Element el = (Element)elIt.next();
        Iterator attrIt = el.attributeIterator();
        Map map = new HashMap();
        while (attrIt.hasNext()) {
            Attribute attribute = (Attribute)attrIt.next();
            map.put(attribute.getName().toLowerCase(), attribute.getData());
        }
        lst.add(map);
    }
    return lst;
}
项目:parabuild-ci    文件:PluginLoader.java   
private void addCollection(List<Document> messageCollectionList, String filename)
        throws DocumentException {
    URL messageURL = findResource(filename);
    if (messageURL != null) {
        SAXReader reader = new SAXReader();
        Document messageCollection = reader.read(messageURL);
        messageCollectionList.add(messageCollection);
    }
}
项目:aliyun-maxcompute-data-collectors    文件:DatahubHandlerTest.java   
@BeforeMethod
public void reInit() throws DocumentException {
    configure = ConfigureReader.reader("src/test/resources/configure.xml");

    datahubHandler.setConfigure(configure);

    DataHubWriter.reInit(configure);
}
项目:sucok-framework    文件:XMLParse.java   
public static Map<String, Object> xml2Map(String xml){
      SAXReader saxReader = new SAXReader();
        Document doc;
try {
    doc = saxReader.read(new StringReader(xml));
     return document2Map(doc);
} catch (DocumentException e) {
    e.printStackTrace();
    return null;
}

  }
项目:bulbasaur    文件:PersistParserTest.java   
@Test
public void testMachineRunWithPersistParser() {

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

    String definitionContent = document.asXML();
    int definitionVersion = DefinitionHelper.getInstance().deployDefinition("persist_definition","测试", definitionContent,
        true).getDefinitionVersion();

    PersistMachine p = persistMachineFactory.newInstance(String.valueOf(System.currentTimeMillis()),
        "persist_definition");
    Assert.assertEquals(definitionVersion, p.getProcessVersion());
    Map m = new HashMap();
    m.put("goto", 2);
    m.put("_i", 3);
    p.addContext(m);
    p.run();
    Assert.assertEquals(6, p.getContext("_a"));
}
项目:bulbasaur    文件:PersistParserTest.java   
@Test
public void testPersistParser() {

    // deploy 2 version of definition first

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

    String definitionContent = document.asXML();

    DefinitionHelper.getInstance().deployDefinition("persist_definition", "测试", definitionContent, true);
    DefinitionHelper.getInstance().deployDefinition("persist_definition", "测试", definitionContent, true);

    Definition definition = persistParser.parse("persist_definition", 0);
    Assert.assertEquals("persist_definition", definition.getName());
    Assert.assertEquals(2, definition.getVersion());
    Assert.assertNotNull(definition.getState("i'm start"));
    Definition definition1 = persistParser.parse("persist_definition", 1);
    Assert.assertEquals(1, definition1.getVersion());
}
项目:sbc-qsystem    文件:FClient.java   
private static void initIndicatorBoardFX(String cfgFile) throws DocumentException {
    File f = new File(cfgFile);
    if (!clientboardFX && f.exists()) {
        // todo
        //todo    board.showBoard(f);
        clientboardFX = true;
    }
}
项目:automat    文件:XmlUtil.java   
/**
 * 将XML规范的字符串转为List对象(XML基于节点属性值的方式)
 * 
 * @param pStrXml 传入的符合XML格式规范的字符串
 * @return list 返回List对象
 */
public static final List parseXml2List(String pStrXml) {
    List lst = new ArrayList();
    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 elRoot = document.getRootElement();
    // 获取根节点的所有子节点元素
    Iterator elIt = elRoot.elementIterator();
    while (elIt.hasNext()) {
        Element el = (Element) elIt.next();
        Iterator attrIt = el.attributeIterator();
        Map map = new HashMap();
        while (attrIt.hasNext()) {
            Attribute attribute = (Attribute) attrIt.next();
            map.put(attribute.getName().toLowerCase(), attribute.getData());
        }
        lst.add(map);
    }
    return lst;
}
项目:push-server    文件:XMLBeanFactory.java   
/**
 * 构造方法.
 * @param xmlName xmlName.
 */
public XMLBeanFactory(String xmlName) { // 在构造方法中
    try {
        this.xmlName = xmlName;
        reader = new SAXReader();
        document = reader.read(this.getClass().getClassLoader().getResourceAsStream(xmlName));
    } catch (DocumentException e) {
        e.printStackTrace();
    }
}
项目:ats-framework    文件:XmlText.java   
private void init(
                   String xmlText ) throws XMLException {

    Document document = null;
    try {
        document = new SAXReader().read(new StringReader(xmlText));
    } catch (DocumentException e) {
        throw new XMLException("Error parsing XML text:\n" + xmlText, e);
    }

    this.root = document.getRootElement();
}