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


Java Digester.setNamespaceAware方法代码示例

本文整理汇总了Java中org.apache.commons.digester3.Digester.setNamespaceAware方法的典型用法代码示例。如果您正苦于以下问题:Java Digester.setNamespaceAware方法的具体用法?Java Digester.setNamespaceAware怎么用?Java Digester.setNamespaceAware使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.digester3.Digester的用法示例。


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

示例1: getDigester

import org.apache.commons.digester3.Digester; //导入方法依赖的package包/类
/**
 * <p>Return the <code>Digester</code> instance to be used for
 * parsing, creating one if necessary.</p>
 * @return A Digester instance.
 */
public Digester getDigester() {
    Digester digester = new Digester();
    RuleSet ruleSet = getRuleSet();
    digester.setNamespaceAware(ruleSet.getNamespaceURI() != null);
    digester.setUseContextClassLoader(getUseContextClassLoader());
    digester.setValidating(false);
    digester.addRuleSet(ruleSet);
    return digester;
}
 
开发者ID:Dotosoft,项目名称:dot4command-core,代码行数:15,代码来源:XmlConfigParser.java

示例2: build

import org.apache.commons.digester3.Digester; //导入方法依赖的package包/类
/**
 * Builds a Vocabulary from the supplied input stream
 *
 * @param is For the XML
 * @return The extension
 * @throws SAXException
 * @throws IOException
 * @throws ParserConfigurationException
 */
public Vocabulary build(InputStream is) throws IOException, SAXException, ParserConfigurationException {
  Digester digester = new Digester(saxf.newSAXParser());
  digester.setNamespaceAware(true);
  digester.setXIncludeAware(false);
  digester.setRuleNamespaceURI(VOCABULARY_NAMESPACE);

  Vocabulary tv = new Vocabulary();
  digester.push(tv);

  // build the thesaurus
  digester.addCallMethod("*/thesaurus", "setTitle", 1);
  digester.addRule("*/thesaurus", new CallParamNoNSRule(0, "title"));

  digester.addCallMethod("*/thesaurus", "setDescription", 1);
  digester.addRule("*/thesaurus", new CallParamNoNSRule(0, "description"));

  digester.addCallMethod("*/thesaurus", "setLink", 1);
  digester.addRule("*/thesaurus", new CallParamNoNSRule(0, "relation"));

  digester.addCallMethod("*/thesaurus", "setUri", 1);
  digester.addRule("*/thesaurus", new CallParamNoNSRule(0, "URI"));

  // build the concept
  digester.addObjectCreate("*/concept", VocabularyConcept.class);

  digester.addCallMethod("*/concept", "setLink", 1);
  digester.addRule("*/concept", new CallParamNoNSRule(0, "relation"));

  digester.addCallMethod("*/concept", "setDescription", 1);
  digester.addRule("*/concept", new CallParamNoNSRule(0, "description"));

  digester.addCallMethod("*/concept", "setUri", 1);
  digester.addRule("*/concept", new CallParamNoNSRule(0, "URI"));

  digester.addCallMethod("*/concept", "setIdentifier", 1);
  digester.addRule("*/concept", new CallParamNoNSRule(0, "identifier"));

  // build the terms
  digester.addObjectCreate("*/preferred/term", VocabularyTerm.class);
  VocabularyTerm t = new VocabularyTerm();

  digester.addCallMethod("*/preferred/term", "setLang", 1);
  digester.addRule("*/preferred/term", new CallParamNoNSRule(0, "lang"));

  digester.addCallMethod("*/preferred/term", "setTitle", 1);
  digester.addRule("*/preferred/term", new CallParamNoNSRule(0, "title"));

  digester.addSetNext("*/preferred/term", "addPreferredTerm");

  // build alternative terms
  digester.addObjectCreate("*/alternative/term", VocabularyTerm.class);
  VocabularyTerm talt = new VocabularyTerm();

  digester.addCallMethod("*/alternative/term", "setLang", 1);
  digester.addRule("*/alternative/term", new CallParamNoNSRule(0, "lang"));

  digester.addCallMethod("*/alternative/term", "setTitle", 1);
  digester.addRule("*/alternative/term", new CallParamNoNSRule(0, "title"));

  digester.addSetNext("*/alternative/term", "addAlternativeTerm");

  // add concept
  digester.addSetNext("*/concept", "addConcept");

  digester.parse(is);
  return tv;
}
 
开发者ID:gbif,项目名称:dwca-io,代码行数:77,代码来源:VocabularyFactory.java


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