本文整理汇总了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;
}
示例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;
}