Java 类org.jdom.input.DOMBuilder 实例源码

项目:cagrid-core    文件:FileHelper.java   
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;
}
项目:cagrid-core    文件:WSDLUtils.java   
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;
}
项目:openccg    文件:DisjunctivizerTest.java   
@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");
}
项目:intellij-ce-playground    文件:EditorColorsSchemeImplTest.java   
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;
}
项目:caadapter    文件:AddNewScenario.java   
/**
    * 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();
  }
项目:caadapter    文件:AddNewScenario.java   
/**
    * 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();
     }
项目:cas4.0.x-server-wechat    文件:SamlUtils.java   
private static Element toJdom(final org.w3c.dom.Element e) {
    return  new DOMBuilder().build(e);
}
项目:intellij-ce-playground    文件:JDOMUtil.java   
@SuppressWarnings("unused")
@Deprecated
public static Element convertFromDOM(org.w3c.dom.Element e) {
  return new DOMBuilder().build(e);
}
项目:cas-4.0.1    文件:SamlUtils.java   
private static Element toJdom(final org.w3c.dom.Element e) {
    return  new DOMBuilder().build(e);
}
项目:xsf    文件:RouteRegistrar.java   
/**
 * 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);
        }
    }
}
项目:p00    文件:SamlUtils.java   
private static Element toJdom(final org.w3c.dom.Element e) {
    return  new DOMBuilder().build(e);
}
项目:cas-server-4.0.1    文件:SamlUtils.java   
private static Element toJdom(final org.w3c.dom.Element e) {
    return  new DOMBuilder().build(e);
}
项目:mobile-starting-framework    文件:IconsServiceImpl.java   
/**
 * 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);
        }
    }
}
项目:tools-idea    文件:JDOMUtil.java   
public static Element convertFromDOM(org.w3c.dom.Element e) {
  return new DOMBuilder().build(e);
}
项目:wt-studio    文件:ComponentBuilder.java   
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;
}
项目:cagrid-core    文件:AxisJdomUtils.java   
public static Element fromMessageElement(MessageElement me) {
    return (Element) ((new DOMBuilder())).build(me).detach();
}
项目:consulo    文件:JDOMUtil.java   
@SuppressWarnings("unused")
@Deprecated
public static Element convertFromDOM(org.w3c.dom.Element e) {
  return new DOMBuilder().build(e);
}
项目:openccg    文件:LFGraphTest.java   
@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")));       
}
项目:parabuild-ci    文件:WireFeedInput.java   
/**
 * 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);
    }
}
项目:NK-VirtualGlobe    文件:WireFeedInput.java   
/**
 * 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);
    }
}
项目:springboot-shiro-cas-mybatis    文件:AbstractSamlObjectBuilder.java   
/**
 * Convert to a jdom element.
 *
 * @param e the e
 * @return the element
 */
private static org.jdom.Element toJdom(final org.w3c.dom.Element e) {
    return  new DOMBuilder().build(e);
}
项目:springboot-shiro-cas-mybatis    文件:AbstractSamlObjectBuilder.java   
/**
 * Convert to a jdom element.
 *
 * @param e the e
 * @return the element
 */
private static org.jdom.Element toJdom(final org.w3c.dom.Element e) {
    return  new DOMBuilder().build(e);
}
项目:cas-5.1.0    文件:AbstractSamlObjectBuilder.java   
/**
 * Convert to a jdom element.
 *
 * @param e the e
 * @return the element
 */
private static org.jdom.Element toJdom(final Element e) {
    return new DOMBuilder().build(e);
}
项目:cas-server-4.2.1    文件:AbstractSamlObjectBuilder.java   
/**
 * Convert to a jdom element.
 *
 * @param e the e
 * @return the element
 */
private static org.jdom.Element toJdom(final org.w3c.dom.Element e) {
    return  new DOMBuilder().build(e);
}
项目:cas4.1.9    文件:AbstractSamlObjectBuilder.java   
/**
 * Convert to a jdom element.
 *
 * @param e the e
 * @return the element
 */
private static org.jdom.Element toJdom(final org.w3c.dom.Element e) {
    return  new DOMBuilder().build(e);
}
项目:kc-rice    文件:XmlHelper.java   
/**
 * Creates jdom Document from a w3c Document.  Does not close the reader.
 *
 * @param document the w3c document
 * @return jdom document
 */
public static org.jdom.Document buildJDocument(org.w3c.dom.Document document) {
    return new DOMBuilder().build(document);
}
项目:google-apps-sso-sample    文件:Util.java   
/**
 * Converts a W3 DOM Element to a JDOM Element
 * 
 * @param e W3 DOM Element
 * @return JDOM Element
 */
public static org.jdom.Element toJdom(org.w3c.dom.Element e) {
  DOMBuilder builder = new DOMBuilder();
  org.jdom.Element jdomElem = builder.build(e);
  return jdomElem;
}
项目:rice    文件:XmlHelper.java   
/**
 * Creates jdom Document from a w3c Document.  Does not close the reader.
 *
 * @param document the w3c document
 * @return jdom document
 */
public static org.jdom.Document buildJDocument(org.w3c.dom.Document document) {
    return new DOMBuilder().build(document);
}
项目:samltools    文件:Util.java   
/**
 * Converts a W3 DOM Element to a JDOM Element
 * 
 * @param e W3 DOM Element
 * @return JDOM Element
 */
public static org.jdom.Element toJdom(org.w3c.dom.Element e) {
  DOMBuilder builder = new DOMBuilder();
  org.jdom.Element jdomElem = builder.build(e);
  return jdomElem;
}
项目:kuali_rice    文件:XmlHelper.java   
/**
 * Creates jdom Document from a w3c Document.  Does not close the reader.
 *
 * @param document the w3c document
 * @return jdom document
 */
public static org.jdom.Document buildJDocument(org.w3c.dom.Document document) {
    return new DOMBuilder().build(document);
}