A Sample FAQ DTD and XSL
1. What do you mean with extending here ?
You can add your own DTD and XSL and let xdoc produce the HTML2. Yes, but I can do this by just using XSLT, so why is this ?
There are several advantages to use xdoc extensibility:
- You can reuse the standard text.dtd and text2html.xsl for all basic text stuff thus only concentrate on the overall document structure (e.g. a FAQ)
- You can seamlessly add your document to an xbook.xml with the standard <document>-tag
- You can reuse standard skins
- Advanced: When you split documents you can use XSLTHelper.java (see text2html.xsl) to resolve internal anchors/links
3. How do I get started ?
This FAQ itself is setup as an extention. You can study the main files myfaq.dtd, myfaq2html.xsl and myfaq.bat. The contents of this file
are in myfaq.xml (all the <para> etc stuff is reused from text.dtd).
These are the main steps:
- Write a DTD for your document. In your DTD you may reuse text.dtd (see faq.dtd) but you're not obliged.
- Write an XSLT stylesheet for your DTD. The convention is that the name is <mydtd>2html.xsl e.g. faq2html.xsl.
If you use text.dtd you may want to include text2html.xsl in your XSL file (see e.g. faq2html.xsl).
- Test by writing documents according to your DTD. The convention is that the DTD name after <!DOCTYPE is <mydtd> e.g. "myfaq"
- xdoc searches DTDs and XSL files according to the CLASSPATH. So you may need to adapt the xdoc.bat (.sh)
script to put your directory in first. (see myfaq.bat)
- Test the conversion by calling xdoc on your XML documents. The result here is in myfaq.html.
4. What else can I extend ?
Offcourse you can always modify the existing DTDs and XSL files and overrule the ones in xbook.jar by putting them
in your CLASSPATH first.
5. I think this is cool.
Thanks.