[jsword-devel] XSLT

DM Smith dmsmith555 at yahoo.com
Wed Apr 25 10:29:40 MST 2007


ZJ,
I don't see anything wrong with your code. I wonder if "converter" is 
not the stylesheet you think it is. The default XSLT behavior is to 
return just the text of a document.
Hope this helps,
DM

ZJ Li wrote:
> 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
>
> _______________________________________________
> jsword-devel mailing list
> jsword-devel at crosswire.org
> http://www.crosswire.org/mailman/listinfo/jsword-devel
>
>   




More information about the jsword-devel mailing list