[jsword-devel] XSLT

ZJ Li lzj369 at gmail.com
Wed Apr 25 09:49:41 MST 2007


DM,

I am working on an  OSIS editor.  I could not get the preview work.

I get the the OSIS doc as a string.  Then I try to use JSWORD util to
transform it to an HTML string.

Somehow, I only get the text, without any html codes.

	// Parses an XML file and returns a DOM document.
	// If validating is true, the contents is validated against the DTD
	// specified in the file.
	public Document parseXml(String content, boolean validating) {

		// Create a builder factory
		DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
		factory.setValidating(validating);
		SAXBuilder builder = new SAXBuilder();
		// Create the builder and parse the file
		Document doc;
		try {
			doc = (Document) builder.build(new StringReader(content));
			return doc;
		} catch (JDOMException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return null;
	}

	public String getHTMLfromOSIS(String content) {
		Document osis = parseXml(content, false);
		VerseMarkData vmd = new VerseMarkData();
		String text = "";
		try {

			boolean direction = false;
			// Element osis=new Element(content);
			SAXEventProvider osissep = new JDOMSAXEventProvider(osis);

			TransformingSAXEventProvider htmlsep =
(TransformingSAXEventProvider) converter
					.convert(osissep);
			vmd.BCV = true;
			vmd.CV = true;
			vmd.MORPH = true;
			vmd.NO_VERSE_NUMBERS = true;
			vmd.NOTES = true;
			vmd.START_VERSE_ON_NEWLINE = true;
			vmd.STRONGS_NUMBERS = true;
			vmd.TINY_VERSE_NUMBERS = true;
			vmd.VERSE_NUMBERS = true;
			vmd.XREF = true;

			vmd.setProperties(htmlsep);

			htmlsep.setParameter("direction", direction ? "ltr" : "rtl");
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
			text = XMLUtil.writeToString(htmlsep);

		} catch (Exception ex) {
			ex.printStackTrace();
		}

		return text;
	}


Thanks a lot for your help!

ZJ Li



More information about the jsword-devel mailing list