[jsword-devel] rendering

Chris Burrell christopher at burrell.me.uk
Sat Nov 6 01:45:18 MST 2010


Hi Matthew

As far as I understand, JSword reads the OSIS xml, and then the developer
can do what he wants with it. So this is some of the code I've used to use
an XSLT: (in the example below, xslConversionDefinition is the name/path to
the XSLT file you choose).

            final Book currentBook = Books.installed().getBook(version);
            final BookData bookData = new BookData(currentBook,
currentBook.getKey(reference));

            final SAXEventProvider osissep = bookData.getSAXEventProvider();
            final TransformingSAXEventProvider htmlsep =
(TransformingSAXEventProvider) new Converter() {

                public SAXEventProvider convert(final SAXEventProvider
provider) throws TransformerException {
                    try {
                        final TransformingSAXEventProvider tsep = new
TransformingSAXEventProvider(getClass()

 .getResource(JSwordServiceImpl.this.xslConversionDefinition).toURI(),
osissep);

                        // set parameters here
                        tsep.setParameter("Strongs", true);
                        tsep.setParameter("Morph", true);

                        // then return
                        return tsep;
                    } catch (final URISyntaxException e) {
                        throw new StepInternalException("Failed to load
resource correctly", e);
                    }
                }
            }.convert(osissep);
           return XMLUtil.writeToString(htmlsep)

In the example below, you can get the XML out, and then the developer can do
whatever he chooses to do:
public void getOsisAsXML(version, reference) {
            final Book currentBook = Books.installed().getBook(version);
            final BookData bookData = new BookData(currentBook,
currentBook.getKey(reference));
            final Element osisFragment = bookData.getOsisFragment();
            return osisFragment;
}

I think there are some examples in the JSword code base on how to get the
text straight out without transformation
Hope that helps
Chris

On 6 November 2010 08:17, Matthew Talbert <ransom1982 at gmail.com> wrote:

> My understanding is that jsword converts everything to OSIS
> internally, then uses an xslt stylesheet to convert to html. I've
> found the xslt, but where is the other conversion done?
>
> Thanks,
> Matthew
>
> _______________________________________________
> jsword-devel mailing list
> jsword-devel at crosswire.org
> http://www.crosswire.org/mailman/listinfo/jsword-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.crosswire.org/pipermail/jsword-devel/attachments/20101106/ffdd4a95/attachment.html>


More information about the jsword-devel mailing list