本文整理汇总了Java中org.jdom.input.DOMBuilder类的典型用法代码示例。如果您正苦于以下问题:Java DOMBuilder类的具体用法?Java DOMBuilder怎么用?Java DOMBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DOMBuilder类属于org.jdom.input包,在下文中一共展示了DOMBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validateXMLwithSchema
import org.jdom.input.DOMBuilder; //导入依赖的package包/类
public Document validateXMLwithSchema(Resource propertiesFileResource,
Resource schemaFileResource) throws AuthenticationConfigurationException {
org.w3c.dom.Document document = null;
DocumentBuilderFactory documentBuilderFactory = XMLUtilities.getDocumentBuilderFactory();
documentBuilderFactory.setNamespaceAware(true);
documentBuilderFactory.setValidating(true);
documentBuilderFactory.setAttribute(
"http://java.sun.com/xml/jaxp/properties/schemaLanguage",
"http://www.w3.org/2001/XMLSchema");
try {
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
documentBuilderFactory.setAttribute(
"http://java.sun.com/xml/jaxp/properties/schemaSource",
schemaFileResource.getInputStream());
documentBuilderFactory.newDocumentBuilder();
document = (org.w3c.dom.Document) documentBuilder.parse(propertiesFileResource.getInputStream());
} catch (Exception e) {
throw new AuthenticationConfigurationException(
"Error in reading the " + propertiesFileResource + " file: " + e.getMessage(), e);
}
DOMBuilder builder = new DOMBuilder();
org.jdom.Document jdomDocument = builder.build(document);
return jdomDocument;
}
示例2: extractTypesSchema
import org.jdom.input.DOMBuilder; //导入依赖的package包/类
public static org.jdom.Element extractTypesSchema(Definition wsdlDefinition) {
org.jdom.Element typesSchemaElm = null;
if (wsdlDefinition != null) {
Types types = wsdlDefinition.getTypes();
if (types != null) {
List extensibilityElements = types.getExtensibilityElements();
for (int i = 0; i < extensibilityElements.size(); i++) {
ExtensibilityElement schemaExtElem = (ExtensibilityElement) extensibilityElements.get(i);
if (schemaExtElem != null) {
QName elementType = schemaExtElem.getElementType();
if (elementType.getLocalPart().equals("schema")
&& (schemaExtElem instanceof UnknownExtensibilityElement)) {
Element element = ((UnknownExtensibilityElement) schemaExtElem).getElement();
DOMBuilder domBuilder = new DOMBuilder();
typesSchemaElm = domBuilder.build(element);
}
}
}
}
}
return typesSchemaElm;
}
示例3: setUp
import org.jdom.input.DOMBuilder; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
super.setUp();
try {
documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
}
catch(ParserConfigurationException e) {
throw new Exception("problem with parser configuration: " + e.getLocalizedMessage(), e);
}
domBuilder = new DOMBuilder();
File testDir = new File(System.getProperty("user.dir"), "test");
paraphrasesFile = new File(testDir, "paraphrases.xml");
outputFile = new File(testDir, "output.xml");
}
示例4: loadScheme
import org.jdom.input.DOMBuilder; //导入依赖的package包/类
private static EditorColorsScheme loadScheme(@NotNull String docText) throws ParserConfigurationException, IOException, SAXException {
DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
InputSource inputSource = new InputSource(new StringReader(docText));
org.w3c.dom.Document doc = docBuilder.parse(inputSource);
Element root = new DOMBuilder().build(doc.getDocumentElement());
EditorColorsScheme defaultScheme = EditorColorsManager.getInstance().getScheme(EditorColorsScheme.DEFAULT_SCHEME_NAME);
EditorColorsScheme targetScheme = new EditorColorsSchemeImpl(defaultScheme);
targetScheme.readExternal(root);
return targetScheme;
}
示例5: outputXML
import org.jdom.input.DOMBuilder; //导入依赖的package包/类
/**
* Save the modified .map file.
*
* @param domDoc .map file's dom tree
* @param outputFileName the target .map file you want save
*/
private void outputXML(Document domDoc, String outputFileName)
throws JDOMException, IOException {
// Create new DOMBuilder, using default parser
DOMBuilder builder = new DOMBuilder();
org.jdom.Document jdomDoc = builder.build(domDoc);
XMLOutputter outputter = new XMLOutputter();
File file = new File(outputFileName);
FileWriter writer = new FileWriter(file);
outputter.output(jdomDoc,writer);
writer.close();
}
示例6: outputXML
import org.jdom.input.DOMBuilder; //导入依赖的package包/类
/**
* Save the modified .map file.
*
* @param domDoc .map file's dom tree
* @param outputFileName the target .map file you want save
*/
private void outputXML(Document domDoc, String outputFileName)
throws JDOMException, IOException {
// Create new DOMBuilder, using default parser
DOMBuilder builder = new DOMBuilder();
org.jdom.Document jdomDoc = builder.build(domDoc);
XMLOutputter outputter = new XMLOutputter();
File file = new File(outputFileName);
FileWriter writer = new FileWriter(file);
outputter.output(jdomDoc,writer);
writer.close();
mappingFileName = file.getAbsolutePath();
}
示例7: toJdom
import org.jdom.input.DOMBuilder; //导入依赖的package包/类
private static Element toJdom(final org.w3c.dom.Element e) {
return new DOMBuilder().build(e);
}
示例8: convertFromDOM
import org.jdom.input.DOMBuilder; //导入依赖的package包/类
@SuppressWarnings("unused")
@Deprecated
public static Element convertFromDOM(org.w3c.dom.Element e) {
return new DOMBuilder().build(e);
}
示例9: postProcessBeanDefinitionRegistry
import org.jdom.input.DOMBuilder; //导入依赖的package包/类
/**
* postProcessBeanDefinitionRegistry:
* @param bdr
* @throws BeansException
*/
@SuppressWarnings("unchecked")
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry bdr) throws BeansException {
// scan the classpath for an optional file generated during the Maven
// build process. This provides automated information on classes that
// are annotated with IRoute
// get the input stream to our file...
InputStream is = ServicesController.class.getResourceAsStream("/META-INF/xsf-reflections.xml");
// if the stream is valid
if (is != null) {
try {
_logger.info("Loading routes from build-generated metadata ...");
// Next lines parse the XML into a DOM doc model object.
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
org.w3c.dom.Document doc = dBuilder.parse(is);
DOMBuilder domBuilder = new DOMBuilder();
Document xmldoc = domBuilder.build(doc);
// get the annotation element
Element annoElement = xmldoc.getRootElement().getChild("TypeAnnotationsScanner");
// if it is found
if (annoElement != null) {
// get the list of entry children.
List<Element> entries = annoElement.getChildren("entry");
// for each child entry
for (Element entry : entries) {
// get the key for the entry
Element key = entry.getChild("key");
// if it is good
if (key != null) {
// extract the annotation text
String anno = key.getText();
// if it is a route annotation
if (anno != null && anno.equals("com.xtivia.xsf.core.annotation.Route")) {
// extract the values from the entry
Element valuesElement =entry.getChild("values");
// if the values were found
if (valuesElement != null) {
// get the value children
List<Element> values = valuesElement.getChildren("value");
// for each value found
for (Element value: values) {
// extract the route class name
String routeClassName = value.getText();
_logger.info("Loading route class="+routeClassName);
loadClass(bdr,routeClassName);
}
}
}
}
}
}
} catch (Exception e) {
_logger.error("Error processing the route annotations: " + e.getMessage(), e);
} finally {
IOUtils.closeQuietly(is);
}
}
}
示例10: importIcons
import org.jdom.input.DOMBuilder; //导入依赖的package包/类
/**
* Import icons from the input stream that contains the xml configuration file
*
* @param inputStream Input stream to the xml configuration
*/
public void importIcons(InputStream inputStream) throws Exception {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder dombuilder = factory.newDocumentBuilder();
org.w3c.dom.Document w3cDocument = dombuilder.parse(inputStream);
DOMBuilder builder = new DOMBuilder();
Document doc = builder.build(w3cDocument);
Element root = doc.getRootElement();
List<Element> icons = root.getChildren("icon");
for (int i = 0; i < icons.size(); i++) {
Element iconElement = (Element) icons.get(i);
String name, path, theme = null;
name = iconElement.getAttribute("name").getValue();
path = iconElement.getAttribute("path").getValue();
if (iconElement.getAttribute("theme") != null) {
theme = iconElement.getAttribute("theme").getValue();
}
// Validate values , throws exception if something is wrong
validateField(name, false, false);
validateField(path, false, true);
validateField(theme, true, false);
// Retrieve the icon with the same name and theme, to check if it exists
WebIcon wi = this.getIcon(name, theme);
/*
* If we should not override existing icons,
* we must first check if the icon already exist, and then ignore
* the new one if there was one
*/
boolean shouldPersist = true;
// If there was an existing icon, we must device if we must override
if (wi != null) {
/*
* If we have to override, we only need to update the path
* because it is the only field that can change. An icon
* is defined by its name and theme
*/
if (autoImportOverride) {
wi.setPath(path);
} else {
shouldPersist = false;
}
}
/*
* If there was no existing icon, we will create a new one
* and persist it.
*/
else {
wi = new WebIcon(name, theme, path);
}
// If nothing wanted us to stop, continue and save
if (shouldPersist) {
this.saveWebIcon(wi);
}
}
}
示例11: convertFromDOM
import org.jdom.input.DOMBuilder; //导入依赖的package包/类
public static Element convertFromDOM(org.w3c.dom.Element e) {
return new DOMBuilder().build(e);
}
示例12: createschemafromtype
import org.jdom.input.DOMBuilder; //导入依赖的package包/类
private Schema createschemafromtype(org.w3c.dom.Element schemaElement,
Definition wsdlDefinition) {
System.out.println("现在的Schema还是一个Dom型的<xsd:schema>元素,属性还不够完全,必须构建命名空间等属性");
System.out.println("使用JDom,先把Dom型的<xsd:schema>元素转换成JDom型...");
System.out.println("开始构建...");
if (schemaElement == null) {
System.err.println("Unable to find schema extensibility element in WSDL");
return null;
}
DOMBuilder domBuilder = new DOMBuilder();
org.jdom.Element jdomSchemaElement = domBuilder.build(schemaElement);
if (jdomSchemaElement == null) {
System.err.println("Unable to read schema defined in WSDL");
return null;
}
Map namespaces = wsdlDefinition.getNamespaces();
if (namespaces != null && !namespaces.isEmpty()) {
System.out.println("WSDL文档Definition的所有命名空间为:");
Iterator nsIter = namespaces.keySet().iterator();
while (nsIter.hasNext()) {
String nsPrefix = (String) nsIter.next();
String nsURI = (String) namespaces.get(nsPrefix);
System.out.println("命名空间:"+nsPrefix+" "+nsURI);
if (nsPrefix!=null&&nsPrefix.length() > 0) {
org.jdom.Namespace nsDecl = org.jdom.Namespace
.getNamespace(nsPrefix, nsURI);
jdomSchemaElement.addNamespaceDeclaration(nsDecl);
}
}
}
jdomSchemaElement.detach();
Schema schema = null;
try {
schema = XMLSupport.convertElementToSchema(jdomSchemaElement);
schema.addNamespace("xsd", "http://www.w3.org/2001/XMLSchema");
}
catch (Exception e) {
System.out.println("a");
System.err.println(e.getMessage());
System.out.println("a");
}
return schema;
}
示例13: fromMessageElement
import org.jdom.input.DOMBuilder; //导入依赖的package包/类
public static Element fromMessageElement(MessageElement me) {
return (Element) ((new DOMBuilder())).build(me).detach();
}
示例14: setUp
import org.jdom.input.DOMBuilder; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
super.setUp();
DocumentBuilder db;
try {
db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
}
catch(ParserConfigurationException e) {
throw new Exception("problem with parser configuration: " + e.getLocalizedMessage(), e);
}
File testFile = new File(new File(new File(System.getProperty("user.dir")), "test"), "testlf.xml");
testLF = Realizer.getLfFromElt(new DOMBuilder().build(db.parse(testFile).getDocumentElement()));
graph = LFGraphFactory.newGraphFrom(testLF);
expected = new LFGraph(LFGraphFactory.DEFAULT_EDGE_FACTORY);
LFVertex w7 = new LFVertex(new NominalAtom("w7"), new Proposition("be"));
w7.setAttribute(new ModeLabel("mood"), new Proposition("dcl"));
w7.setAttribute(new ModeLabel("tense"), new Proposition("past"));
expected.addVertex(w7);
LFVertex w0 = new LFVertex(new NominalAtom("w0"), new Proposition("bank"));
w0.setAttribute(new ModeLabel("det"), new Proposition("nil"));
expected.addVertex(w0);
LFVertex w1 = new LFVertex(new NominalAtom("w1"), new Proposition("of"));
expected.addVertex(w1);
LFVertex w2 = new LFVertex(new NominalAtom("w2"), new Proposition("holland"));
w2.setAttribute(new ModeLabel("det"), new Proposition("nil"));
w2.setAttribute(new ModeLabel("num"), new Proposition("sg"));
expected.addVertex(w2);
LFVertex w5 = new LFVertex(new NominalAtom("w5"), new Proposition("office"));
w5.setAttribute(new ModeLabel("det"), new Proposition("nil"));
w5.setAttribute(new ModeLabel("num"), new Proposition("sg"));
expected.addVertex(w5);
LFVertex w4 = new LFVertex(new NominalAtom("w4"), new Proposition("wuhan"));
w4.setAttribute(new ModeLabel("num"), new Proposition("sg"));
expected.addVertex(w4);
LFVertex w9 = new LFVertex(new NominalAtom("w9"), new Proposition("officially"));
expected.addVertex(w9);
LFVertex w8 = new LFVertex(new NominalAtom("w8"), new Proposition("also"));
expected.addVertex(w8);
LFVertex w10 = new LFVertex(new NominalAtom("w10"), new Proposition("establish"));
w10.setAttribute(new ModeLabel("tense"), new Proposition("past"));
expected.addVertex(w10);
LFVertex w11 = new LFVertex(new NominalAtom("w11"), new Proposition("just"));
expected.addVertex(w11);
LFVertex w12 = new LFVertex(new NominalAtom("w12"), new Proposition("recently"));
expected.addVertex(w12);
expected.addLabeledEdge(w7, w0, LFEdgeLabel.forMode(new ModeLabel("Arg0")));
expected.addLabeledEdge(w0, w1, LFEdgeLabel.forMode(new ModeLabel("Mod")));
expected.addLabeledEdge(w1, w2, LFEdgeLabel.forMode(new ModeLabel("Arg1")));
expected.addLabeledEdge(w2, w5, LFEdgeLabel.forMode(new ModeLabel("ApposRel")));
expected.addLabeledEdge(w5, w4, LFEdgeLabel.forMode(new ModeLabel("Mod")));
expected.addLabeledEdge(w7, w9, LFEdgeLabel.forMode(new ModeLabel("Arg1")));
expected.addLabeledEdge(w9, w0, LFEdgeLabel.forMode(new ModeLabel("Arg0")));
expected.addLabeledEdge(w7, w8, LFEdgeLabel.forMode(new ModeLabel("Mod")));
expected.addLabeledEdge(w7, w10, LFEdgeLabel.forMode(new ModeLabel("GenRel")));
expected.addLabeledEdge(w10, w0, LFEdgeLabel.forMode(new ModeLabel("Arg1")));
expected.addLabeledEdge(w10, w11, LFEdgeLabel.forMode(new ModeLabel("Mod")));
expected.addLabeledEdge(w10, w12, LFEdgeLabel.forMode(new ModeLabel("Mod")));
}
示例15: build
import org.jdom.input.DOMBuilder; //导入依赖的package包/类
/**
* Builds an WireFeed (RSS or Atom) from an W3C DOM document.
* <p>
* NOTE: This method delages to the 'AsbtractFeed WireFeedInput#build(org.jdom.Document)'.
* <p>
* @param document W3C DOM document to read to create the WireFeed.
* @return the WireFeed read from the W3C DOM document.
* @throws IllegalArgumentException thrown if feed type could not be understood by any of the underlying parsers.
* @throws FeedException if the feed could not be parsed
*
*/
public WireFeed build(org.w3c.dom.Document document) throws IllegalArgumentException,FeedException {
DOMBuilder domBuilder = new DOMBuilder();
try {
Document jdomDoc = domBuilder.build(document);
return build(jdomDoc);
}
catch (Exception ex) {
throw new ParsingFeedException("Invalid XML",ex);
}
}