Search in sources :

Example 41 with Document

use of org.jdom.Document in project cxf by apache.

the class WriterTest method testLiteral.

@Test
public void testLiteral() throws Exception {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    ElementWriter writer = new ElementWriter(bos, "root", "urn:test");
    write(writer);
    writer.flush();
    bos.close();
    // System.out.println(bos.toString());
    StaxBuilder builder = new StaxBuilder();
    Document doc = builder.build(new StringReader(bos.toString()));
    testWrite(doc);
}
Also used : StaxBuilder(org.apache.cxf.aegis.util.jdom.StaxBuilder) StringReader(java.io.StringReader) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Document(org.jdom.Document) AbstractCXFTest(org.apache.cxf.test.AbstractCXFTest) Test(org.junit.Test)

Example 42 with Document

use of org.jdom.Document in project cxf by apache.

the class StaxBuilder method buildInternal.

private Document buildInternal(XMLStreamReader r) throws XMLStreamException {
    /*
         * Should we do sanity checking to see that r is positioned at
         * beginning in the non-mid-stream case?
         */
    JDOMFactory f = factory;
    if (f == null) {
        f = new UncheckedJDOMFactory();
    }
    Document doc = f.document(null);
    buildTree(f, r, doc);
    return doc;
}
Also used : UncheckedJDOMFactory(org.jdom.UncheckedJDOMFactory) JDOMFactory(org.jdom.JDOMFactory) Document(org.jdom.Document) UncheckedJDOMFactory(org.jdom.UncheckedJDOMFactory)

Example 43 with Document

use of org.jdom.Document in project cas by apereo.

the class GoogleAccountsServiceFactory method createService.

@Override
public GoogleAccountsService createService(final HttpServletRequest request) {
    final String relayState = request.getParameter(SamlProtocolConstants.PARAMETER_SAML_RELAY_STATE);
    final String xmlRequest = this.googleSaml20ObjectBuilder.decodeSamlAuthnRequest(request.getParameter(SamlProtocolConstants.PARAMETER_SAML_REQUEST));
    if (StringUtils.isBlank(xmlRequest)) {
        LOGGER.trace("SAML AuthN request not found in the request");
        return null;
    }
    final Document document = this.googleSaml20ObjectBuilder.constructDocumentFromXml(xmlRequest);
    if (document == null) {
        return null;
    }
    final Element root = document.getRootElement();
    final String assertionConsumerServiceUrl = root.getAttributeValue("AssertionConsumerServiceURL");
    final String requestId = root.getAttributeValue("ID");
    final GoogleAccountsService s = new GoogleAccountsService(assertionConsumerServiceUrl, relayState, requestId);
    s.setLoggedOutAlready(true);
    return s;
}
Also used : Element(org.jdom.Element) Document(org.jdom.Document)

Example 44 with Document

use of org.jdom.Document in project vcell by virtualcell.

the class TMLPanel method processComparisonResult.

// process events for loading the model displayed in the comparison panel
public VCDocument processComparisonResult() throws Exception {
    try {
        NodeInfo root = (NodeInfo) getTree().getModel().getRoot();
        // if (!isNormal(root)) {
        // displayMessage(this, "Please resolve all tagged elements/attributes before proceeding.");
        // }
        String xmlStr = root.toXmlString();
        // System.out.println(xmlStr);
        Element rootElement = (XmlUtil.stringToXML(xmlStr, null)).getRootElement();
        // ?
        XmlReader reader = new XmlReader(true);
        String rootName = rootElement.getName();
        Document doc = rootElement.getDocument();
        VCDocument vcDoc = null;
        if (rootName.equals(XMLTags.BioModelTag)) {
            String docSoftwareVersion = rootElement.getAttributeValue(XMLTags.SoftwareVersionAttrTag);
            vcDoc = reader.getBioModel(rootElement, (docSoftwareVersion == null ? null : VCellSoftwareVersion.fromString(docSoftwareVersion)));
        } else if (rootName.equals(XMLTags.MathModelTag)) {
            vcDoc = reader.getMathModel(rootElement);
        } else if (rootName.equals(XMLTags.GeometryTag)) {
            vcDoc = reader.getGeometry(rootElement);
        } else {
            throw new Exception("Invalid root for the tree");
        }
        return vcDoc;
    } catch (java.lang.Exception ivjExc) {
        handleException(ivjExc);
        throw ivjExc;
    }
}
Also used : VCDocument(org.vcell.util.document.VCDocument) NodeInfo(cbit.xml.merge.NodeInfo) ChangedNodeInfo(cbit.xml.merge.ChangedNodeInfo) Element(org.jdom.Element) XmlReader(cbit.vcell.xml.XmlReader) VCDocument(org.vcell.util.document.VCDocument) Document(org.jdom.Document)

Example 45 with Document

use of org.jdom.Document in project vcell by virtualcell.

the class DocumentCompiler method readTemplateFile.

private DocumentPage readTemplateFile(File file) throws XmlParseException {
    Document doc = XmlUtil.readXML(file);
    Element root = doc.getRootElement();
    if (!root.getName().equals(VCellDocTags.VCellDoc_tag)) {
        throw new RuntimeException("expecting ...");
    }
    Element pageElement = root.getChild(VCellDocTags.page_tag);
    if (pageElement != null) {
        String title = pageElement.getAttributeValue(VCellDocTags.page_title_attr);
        DocSection appearance = getSection(pageElement, VCellDocTags.appearance_tag, file);
        DocSection introduction = getSection(pageElement, VCellDocTags.introduction_tag, file);
        DocSection operations = getSection(pageElement, VCellDocTags.operations_tag, file);
        DocumentPage documentTemplate = new DocumentPage(file, title, introduction, appearance, operations);
        return documentTemplate;
    }
    return null;
}
Also used : Element(org.jdom.Element) Document(org.jdom.Document)

Aggregations

Document (org.jdom.Document)144 Element (org.jdom.Element)102 SAXBuilder (org.jdom.input.SAXBuilder)51 IOException (java.io.IOException)49 JDOMException (org.jdom.JDOMException)29 File (java.io.File)27 ArrayList (java.util.ArrayList)22 XMLOutputter (org.jdom.output.XMLOutputter)22 List (java.util.List)16 StringReader (java.io.StringReader)15 Format (org.jdom.output.Format)12 VCDocument (org.vcell.util.document.VCDocument)11 XPath (org.jdom.xpath.XPath)10 StringWriter (java.io.StringWriter)9 InputStream (java.io.InputStream)8 URL (java.net.URL)8 NotNull (org.jetbrains.annotations.NotNull)7 Nullable (org.jetbrains.annotations.Nullable)7 FileNotFoundException (java.io.FileNotFoundException)5 Writer (java.io.Writer)5