Search in sources :

Example 71 with Document

use of com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_02.Document in project step by STEPBible.

the class NaveXmlDataProcessor method process.

private void process(final SAXBuilder builder, final String line, final Tree<String> t) throws JDOMException, IOException {
    final StringReader stringReader = new StringReader(line);
    final Document doc;
    try {
        doc = builder.build(stringReader);
    } catch (final Exception x) {
        // quietly exit and log
        System.out.println("Unable to process line: " + line);
        return;
    }
    final List<Content> content = doc.getContent();
    for (final Content c : content) {
        // look for paragraphs
        if (c instanceof Element) {
            final Element element = (Element) c;
            if (element.getName().equals("entryFree")) {
                processEntryFree(t, doc, element);
            }
        }
    }
}
Also used : Content(org.jdom2.Content) Element(org.jdom2.Element) StringReader(java.io.StringReader) Document(org.jdom2.Document) IOException(java.io.IOException) JDOMException(org.jdom2.JDOMException)

Example 72 with Document

use of com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_02.Document in project step by STEPBible.

the class JSwordPassageServiceImplTest method testInterleave.

/**
 * Justs shows XML on the stdout
 *
 * @throws BookException      an exceptioon
 * @throws NoSuchKeyException an exception
 * @throws IOException        an exception
 * @throws JDOMException      an exception
 */
@Test
public void testInterleave() throws BookException, NoSuchKeyException, JDOMException, IOException {
    final XMLOutputter xmlOutputter = new XMLOutputter(Format.getPrettyFormat());
    final String ref = "John 4:1";
    // do the test
    final String[] versions = new String[] { "Byz", "Tisch" };
    final BookData data = new BookData(new Book[] { Books.installed().getBook(versions[0]), Books.installed().getBook(versions[1]) }, Books.installed().getBook(versions[0]).getKey(ref), true);
    LOGGER.debug("Original is:\n {}", xmlOutputter.outputString(data.getOsisFragment()));
    final OsisWrapper interleavedVersions = this.jsi.getInterleavedVersions(versions, ref, new ArrayList<LookupOption>(), InterlinearMode.COLUMN_COMPARE, "en");
    final SAXBuilder sb = new SAXBuilder();
    final Document d = sb.build(new StringReader(interleavedVersions.getValue()));
    LOGGER.debug("\n {}", xmlOutputter.outputString(d));
}
Also used : XMLOutputter(org.jdom2.output.XMLOutputter) SAXBuilder(org.jdom2.input.SAXBuilder) LookupOption(com.tyndalehouse.step.core.models.LookupOption) StringReader(java.io.StringReader) BookData(org.crosswire.jsword.book.BookData) Document(org.jdom2.Document) OsisWrapper(com.tyndalehouse.step.core.models.OsisWrapper) Test(org.junit.Test)

Example 73 with Document

use of com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_02.Document in project step by STEPBible.

the class JSwordPassageServiceImplTest method testSegVariants.

/**
 * Justs shows XML on the stdout
 *
 * @throws BookException      an exceptioon
 * @throws NoSuchKeyException an exception
 * @throws IOException        an exception
 * @throws JDOMException      an exception
 */
@Test
public void testSegVariants() throws BookException, NoSuchKeyException, JDOMException, IOException {
    final XMLOutputter xmlOutputter = new XMLOutputter(Format.getPrettyFormat());
    final String ref = "Mat.9.4";
    final String version = "WHNU";
    final Book book = Books.installed().getBook(version);
    // do the test
    final BookData data = new BookData(book, book.getKey(ref));
    LOGGER.info("Original is:\n {}", xmlOutputter.outputString(data.getOsisFragment()));
    final OsisWrapper interleavedVersions = this.jsi.getOsisText(version, ref);
    final SAXBuilder sb = new SAXBuilder();
    final Document d = sb.build(new StringReader(interleavedVersions.getValue()));
    final String outputString = xmlOutputter.outputString(d);
    LOGGER.info(outputString);
    assertTrue(outputString.contains("ειδως"));
    assertTrue(outputString.contains("title=\"ιδων"));
}
Also used : XMLOutputter(org.jdom2.output.XMLOutputter) SAXBuilder(org.jdom2.input.SAXBuilder) BibleBook(org.crosswire.jsword.versification.BibleBook) Book(org.crosswire.jsword.book.Book) StringReader(java.io.StringReader) BookData(org.crosswire.jsword.book.BookData) Document(org.jdom2.Document) OsisWrapper(com.tyndalehouse.step.core.models.OsisWrapper) Test(org.junit.Test)

Example 74 with Document

use of com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_02.Document in project step by STEPBible.

the class JSwordPassageServiceImplTest method testComparing.

/**
 * tests that the XSLT transformation is handled correctly
 *
 * @throws BookException      uncaught exception
 * @throws NoSuchKeyException uncaught exception
 * @throws IOException        uncaught exception
 * @throws JDOMException      uncaught exception
 */
@Test
public void testComparing() throws BookException, NoSuchKeyException, JDOMException, IOException {
    final Book currentBook = Books.installed().getBook("ESV_th");
    final Book secondaryBook = Books.installed().getBook("KJV");
    final String reference = "Psalm.3";
    final BookData bookData = new BookData(new Book[] { currentBook, secondaryBook }, currentBook.getKey(reference), true);
    final Element osisFragment = bookData.getOsisFragment();
    final XMLOutputter xmlOutputter = new XMLOutputter(Format.getPrettyFormat());
    LOGGER.info(xmlOutputter.outputString(osisFragment));
    // do the test
    final List<LookupOption> options = new ArrayList<LookupOption>();
    final String osisText = this.jsi.getInterleavedVersions(new String[] { currentBook.getInitials(), secondaryBook.getInitials() }, reference, options, InterlinearMode.INTERLEAVED_COMPARE, "en").getValue();
    final SAXBuilder sb = new SAXBuilder();
    final Document d = sb.build(new StringReader(osisText));
    LOGGER.info("\n {}", xmlOutputter.outputString(d));
    Assert.assertTrue(osisText.contains("span"));
}
Also used : XMLOutputter(org.jdom2.output.XMLOutputter) SAXBuilder(org.jdom2.input.SAXBuilder) LookupOption(com.tyndalehouse.step.core.models.LookupOption) BibleBook(org.crosswire.jsword.versification.BibleBook) Book(org.crosswire.jsword.book.Book) Element(org.jdom2.Element) ArrayList(java.util.ArrayList) StringReader(java.io.StringReader) BookData(org.crosswire.jsword.book.BookData) Document(org.jdom2.Document) Test(org.junit.Test)

Example 75 with Document

use of com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_02.Document in project plexus-containers by codehaus-plexus.

the class AbstractMerger method mergeDescriptors.

public void mergeDescriptors(File outputDescriptor, List<File> descriptors) throws IOException {
    SAXBuilder builder = new SAXBuilder(new XMLReaderSAX2Factory(false, Driver.class.getName()));
    Document finalDoc = null;
    for (File f : descriptors) {
        try {
            Document doc = builder.build(f);
            if (finalDoc != null) {
                // Last specified has dominance
                finalDoc = merge(doc, finalDoc);
            } else {
                finalDoc = doc;
            }
        } catch (JDOMException e) {
            throw new IOException("Invalid input descriptor for merge: " + f + " --> " + e.getMessage());
        } catch (MergeException e) {
            throw new IOException("Error merging descriptor: " + f + " --> " + e.getMessage());
        }
    }
    if (finalDoc != null) {
        try {
            writeMergedDocument(finalDoc, outputDescriptor);
        } catch (IOException e) {
            throw new IOException("Error writing merged descriptor: " + outputDescriptor);
        }
    }
}
Also used : XMLReaderSAX2Factory(org.jdom2.input.sax.XMLReaderSAX2Factory) SAXBuilder(org.jdom2.input.SAXBuilder) IOException(java.io.IOException) Document(org.jdom2.Document) JDOMException(org.jdom2.JDOMException) File(java.io.File)

Aggregations

Document (org.jdom2.Document)1034 Element (org.jdom2.Element)587 Test (org.junit.Test)340 SAXBuilder (org.jdom2.input.SAXBuilder)271 IOException (java.io.IOException)266 XMLOutputter (org.jdom2.output.XMLOutputter)182 JDOMException (org.jdom2.JDOMException)162 File (java.io.File)148 ArrayList (java.util.ArrayList)75 InputStream (java.io.InputStream)74 StringReader (java.io.StringReader)63 Path (java.nio.file.Path)59 HashMap (java.util.HashMap)57 DocumentHelper.getDocument (com.mulesoft.tools.migration.helper.DocumentHelper.getDocument)53 DocumentHelper.getElementsFromDocument (com.mulesoft.tools.migration.helper.DocumentHelper.getElementsFromDocument)53 MCRJDOMContent (org.mycore.common.content.MCRJDOMContent)48 PID (edu.unc.lib.boxc.model.api.ids.PID)47 Attribute (org.jdom2.Attribute)44 List (java.util.List)42 Namespace (org.jdom2.Namespace)39