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


Java SAXBuilder类代码示例

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


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

示例1: parseSearchResult

import org.jdom.input.SAXBuilder; //导入依赖的package包/类
private LyricsInfo parseSearchResult(String xml) throws Exception {
    SAXBuilder builder = new SAXBuilder();
    Document document = builder.build(new StringReader(xml));

    Element root = document.getRootElement();
    Namespace ns = root.getNamespace();

    String lyric = StringUtils.trimToNull(root.getChildText("Lyric", ns));
    String song =  root.getChildText("LyricSong", ns);
    String artist =  root.getChildText("LyricArtist", ns);

    return new LyricsInfo(lyric, artist, song);
}
 
开发者ID:airsonic,项目名称:airsonic,代码行数:14,代码来源:LyricsService.java

示例2: buildDOM

import org.jdom.input.SAXBuilder; //导入依赖的package包/类
public org.jdom.Document buildDOM(String fileName) throws DAOException {
    if (fileName == null || "".equals(fileName)) {
        throw new DAOException("Unable to load file. Null or empty path requested");
    }
    SAXBuilder builder = new SAXBuilder();
    builder.setValidation(false);
    org.jdom.Document document = null;
    try {
        fileName = checkFilePath(fileName);
        document = builder.build(fileName);
        return document;
    } catch (org.jdom.JDOMException jde) {
        logger.error(jde);
        throw new DAOException(jde.getMessage());
    } catch (java.io.IOException ioe) {
        logger.error(ioe);
        throw new DAOException(ioe.getMessage());
    }
}
 
开发者ID:dbunibas,项目名称:spicy,代码行数:20,代码来源:DAOXmlUtility.java

示例3: testCanReadFromElementOfLargerDocument

import org.jdom.input.SAXBuilder; //导入依赖的package包/类
public void testCanReadFromElementOfLargerDocument() throws Exception {
    String xml ="" +
            "<big>" +
            "  <small>" +
            "    <tiny/>" +
            "  </small>" +
            "  <small-two>" +
            "  </small-two>" +
            "</big>";
    Document document = new SAXBuilder().build(new StringReader(xml));
    Element element = document.getRootElement().getChild("small");

    HierarchicalStreamReader xmlReader = new JDomReader(element);
    assertEquals("small", xmlReader.getNodeName());
    xmlReader.moveDown();
    assertEquals("tiny", xmlReader.getNodeName());
}
 
开发者ID:x-stream,项目名称:xstream,代码行数:18,代码来源:JDomReaderTest.java

示例4: constructDocumentFromXml

import org.jdom.input.SAXBuilder; //导入依赖的package包/类
/**
 * Construct document from xml string.
 *
 * @param xmlString the xml string
 * @return the document
 */
public static Document constructDocumentFromXml(final String xmlString) {
    try {
        final SAXBuilder builder = new SAXBuilder();
        builder.setFeature("http://xml.org/sax/features/external-general-entities", false);
        builder.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
        return builder
                .build(new ByteArrayInputStream(xmlString.getBytes(Charset.defaultCharset())));
    } catch (final Exception e) {
        return null;
    }
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:18,代码来源:AbstractSamlObjectBuilder.java

示例5: addImagePlanning

import org.jdom.input.SAXBuilder; //导入依赖的package包/类
public static void addImagePlanning(String dbname, File planningFile) throws Exception {
    // create xml reader
    SAXBuilder builder = new SAXBuilder();
    Document doc;
    doc = builder.build(planningFile);
    Element atts = doc.getRootElement();
    // check format first
    if (atts.getName().equalsIgnoreCase("imageplanning")) {
        // connect to database
        Connection conn = DriverManager.getConnection("jdbc:h2:~/.sumo/" + dbname + ";AUTO_SERVER=TRUE", "sa", "");
        Statement stat = conn.createStatement();
        String sql = "create table if not exists IMAGEPLAN (IMAGE VARCHAR(255), URL VARCHAR(1024), STARTDATE VARCHAR(255), ENDDATE VARCHAR(255), AREA VARCHAR(1024), ACTION VARCHAR(2048))";
        stat.execute(sql);
        // clear table before filling it in
        stat.execute("DELETE FROM IMAGEPLAN");
        // scan through images
        for (Object o : atts.getChildren("Image")) {
            Element element = (Element) o;
            // create sql statement
            sql = "INSERT INTO IMAGEPLAN VALUES('" + element.getChildText("name") + "', '" + element.getChildText("url") + "', '" + element.getChildText("startDate") + "', '" + element.getChildText("endDate") + "', '" + element.getChildText("area") + "', '" + element.getChildText("action") + "');";
            stat.execute(sql);
        }
        stat.close();
        conn.close();
    } else {
        SwingUtilities.invokeLater(new Runnable() {

            public void run() {
                JOptionPane.showMessageDialog(null, "Format not supported", "Error", JOptionPane.ERROR_MESSAGE);
            }
        });
    }

}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:35,代码来源:H2Fetcher.java

示例6: initialise

import org.jdom.input.SAXBuilder; //导入依赖的package包/类
@Override
public boolean initialise() {
	try {
		super.imgName=manifestFile.getParentFile().getName();

		SAXBuilder builder = new SAXBuilder();
		setFile(manifestFile);
		doc = builder.build(productxml);
		tiffImages = getImages();
		if(tiffImages==null) return false;

		IReader image = tiffImages.values().iterator().next();

        this.displayName=super.imgName;//+ "  " +image.getImageFile().getName();

        parseProductXML(productxml);

        bounds = new Rectangle(0, 0, image.getxSize(), image.getySize());
        readPixel(0,0,0);
    } catch (Exception ex) {
        dispose();
        logger.error(ex.getMessage(),ex);
        return false;
    }
    return true;
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:27,代码来源:Radarsat2Image.java

示例7: initialise

import org.jdom.input.SAXBuilder; //导入依赖的package包/类
@Override
public boolean initialise() {
	try {
		super.imgName=manifestFile.getParentFile().getName();

		SAXBuilder builder = new SAXBuilder();
		setFile(manifestFile);
		doc = builder.build(productxml);
		tiffImages = getImages();
		if(tiffImages==null) return false;

		IReader image = tiffImages.values().iterator().next();

        this.displayName=super.imgName;//+ "  " +image.getImageFile().getName();

        super.parseProductXML(productxml);

        bounds = new Rectangle(0, 0, image.getxSize(), image.getySize());
        readPixel(0,0,0);
    } catch (Exception ex) {
        dispose();
        logger.error(ex.getMessage(),ex);
        return false;
    }
    return true;
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:27,代码来源:Radarsat2ImageGDAL.java

示例8: fromXSchema

import org.jdom.input.SAXBuilder; //导入依赖的package包/类
/** Creates an AnnotationSchema object from an XSchema file
  * @param anXSchemaURL the URL where to find the XSchema file
  */
public void fromXSchema(URL anXSchemaURL)
            throws ResourceInstantiationException {
  org.jdom.Document jDom = null;
  SAXBuilder saxBuilder = new SAXBuilder(false);
  try {
  try{
    jDom = saxBuilder.build(anXSchemaURL);
  }catch(JDOMException je){
    throw new ResourceInstantiationException(je);
  }
  } catch (java.io.IOException ex) {
    throw new ResourceInstantiationException(ex);
  }
  workWithJDom(jDom);
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:19,代码来源:AnnotationSchema.java

示例9: CreoleRegisterImpl

import org.jdom.input.SAXBuilder; //导入依赖的package包/类
/**
 * Default constructor. Sets up directory files parser. <B>NOTE:</B> only
 * Factory should call this method.
 */
public CreoleRegisterImpl() throws GateException {

  // initialise the various maps

  lrTypes = new HashSet<String>();
  prTypes = new HashSet<String>();
  vrTypes = new LinkedList<String>();
  toolTypes = new HashSet<String>();
  applicationTypes = new HashSet<String>();

  plugins = new LinkedHashSet<Plugin>();

  // construct a SAX parser for parsing the CREOLE directory files
  jdomBuilder = new SAXBuilder(false);
  jdomBuilder.setXMLFilter(new CreoleXmlUpperCaseFilter());

  // read plugin name mappings file
  readPluginNamesMappings();

}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:25,代码来源:CreoleRegisterImpl.java

示例10: main

import org.jdom.input.SAXBuilder; //导入依赖的package包/类
public static void main(String[] args) throws Exception {

    URL input = (new File(
        "/home/mark/gate-top/externals/gate-svn/plugins/Lang_French/french.gapp"))
            .toURI().toURL();

    SAXBuilder builder = new SAXBuilder(false);
    Document doc = builder.build(input);
    List<UpgradePath> upgrades = suggest(doc);
    for(UpgradePath upgrade : upgrades) {
      System.out.println(upgrade);
    }

    upgrade(doc, upgrades);

    outputter.output(doc, System.out);
  }
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:18,代码来源:UpgradeXGAPP.java

示例11: test_WebookConfig

import org.jdom.input.SAXBuilder; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void test_WebookConfig() throws JDOMException, IOException{
	SAXBuilder builder = new SAXBuilder();
	List<MsTeamsNotificationConfig> configs = new ArrayList<MsTeamsNotificationConfig>();
	builder.setIgnoringElementContentWhitespace(true);
		Document doc = builder.build("src/test/resources/testdoc2.xml");
		Element root = doc.getRootElement();
		if(root.getChild("msteamsNotifications") != null){
			Element child = root.getChild("msteamsNotifications");
			if ((child.getAttribute("enabled") != null) && (child.getAttribute("enabled").equals("true"))){
				List<Element> namedChildren = child.getChildren("msteamsNotification");
				for(Iterator<Element> i = namedChildren.iterator(); i.hasNext();)
	            {
					Element e = i.next();
					MsTeamsNotificationConfig whConfig = new MsTeamsNotificationConfig(e);
					configs.add(whConfig);
	            }
			}
		}

	
	for (MsTeamsNotificationConfig c : configs){
		MsTeamsNotification wh = new MsTeamsNotificationImpl();
		wh.setEnabled(c.getEnabled());
		//msteamsNotification.addParams(c.getParams());
		System.out.println(wh.isEnabled().toString());

	}
}
 
开发者ID:spyder007,项目名称:teamcity-msteams-notifier,代码行数:31,代码来源:MsTeamsNotificationSettingsTest.java

示例12: test_ReadXml

import org.jdom.input.SAXBuilder; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void test_ReadXml() throws JDOMException, IOException {
	SAXBuilder builder = new SAXBuilder();
	//builder.setValidation(true);
	builder.setIgnoringElementContentWhitespace(true);
	
		Document doc = builder.build("src/test/resources/testdoc1.xml");
		Element root = doc.getRootElement();
		System.out.println(root.toString());
		if(root.getChild("msteamsNotifications") != null){
			Element child = root.getChild("msteamsNotifications");
			if ((child.getAttribute("enabled") != null) && (child.getAttribute("enabled").equals("true"))){
				List<Element> namedChildren = child.getChildren("msteamsNotification");
				for(Iterator<Element> i = namedChildren.iterator(); i.hasNext();)
	            {
					Element e = i.next();
					System.out.println(e.toString() + e.getAttributeValue("url"));
					//assertTrue(e.getAttributeValue("url").equals("http://something"));
					if(e.getChild("parameters") != null){
						Element eParams = e.getChild("parameters");
						List<Element> paramsList = eParams.getChildren("param");
						for(Iterator<Element> j = paramsList.iterator(); j.hasNext();)
						{
							Element eParam = j.next();
							System.out.println(eParam.toString() + eParam.getAttributeValue("name"));
							System.out.println(eParam.toString() + eParam.getAttributeValue("value"));
						}
					}
	            }
			}
		}

}
 
开发者ID:spyder007,项目名称:teamcity-msteams-notifier,代码行数:35,代码来源:MsTeamsNotificationSettingsTest.java

示例13: readComponent

import org.jdom.input.SAXBuilder; //导入依赖的package包/类
@Nullable
private static Element readComponent(@NotNull SAXBuilder parser, @NotNull String projectPath) {
  Element component = null;
  try {
    String studyProjectXML = projectPath + STUDY_PROJECT_XML_PATH;
    Document xmlDoc = parser.build(new File(studyProjectXML));
    Element root = xmlDoc.getRootElement();
    component = root.getChild("component");
  }
  catch (JDOMException | IOException ignored) {
  }

  return component;
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:15,代码来源:EduBuiltInServerUtils.java

示例14: parseXML

import org.jdom.input.SAXBuilder; //导入依赖的package包/类
/**
 * Parse the parameters of an markovmodel.xml file for an HMM object as HMMParams object.
 *
 * @param hmmFile the string to the markovmodel file
 * @return a HMMParams object containing all relevant parameters for the HMM
 */
public static HMMParams parseXML(java.lang.String hmmFile)
{
    HMMParams params = HMMParams.newInstance();
    SAXBuilder builder = new SAXBuilder();
    Document document;
    try
    {
        _LOGGER.info("Parsing markovmodel xml.");
        document = builder.build(hmmFile);
        setStandardParams(document, params);
        setTrainingParams(document, params);
    }
    catch (IOException | JDOMException e)
    {
        _LOGGER.error("Could not open file: " + e.getMessage());
    }
    return params;
}
 
开发者ID:dirmeier,项目名称:lvm4j,代码行数:25,代码来源:File.java

示例15: parseReturn

import org.jdom.input.SAXBuilder; //导入依赖的package包/类
private Hashtable parseReturn(InputStream is){
    Hashtable h = null;
    try {
        
       
        SAXBuilder parser = new SAXBuilder();
        Document doc = parser.build(is);
        Element root = doc.getRootElement();
         h  = new Hashtable();
        String jsessionID =g(root.getDescendants(new ElementFilter("jsessionID")));
        String ptLoginToken =g(root.getDescendants(new ElementFilter("ptLoginToken")));
        String returnCode =g(root.getDescendants(new ElementFilter("returnCode")));
                    
        h.put("returnCode",returnCode);
        h.put("ptLoginToken",ptLoginToken);
        h.put("jsessionID",jsessionID);
        
    }catch(Exception e){
        MiscUtils.getLogger().error("Error", e);
    }
    return h;
}
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:23,代码来源:OntarioMD.java


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