Senior Member
Volunteer Data File Author
Join Date: Apr 2006
Posts: 130
|
Just wondering if it's possible to get a copy of the XSLT file that AB uses internally to generate a HTML document. For instance, in the AB40k files we have a faqDat.dat file that is an "Army Builder Data" XML document type which when the files are compiled AB creates an faq.htm file.
What I'm after is a copy of the XSLT that AB itself uses to create that faq.htm file from the faqDat.dat XML if possible, so we can use it to generate a copy of the faq.htm file without having to compile the AB40k files - this way we can generate an online version of the FAQ on our website direct from the source .dat file without having to manually copy the faq.htm file from a compiled AB installation. I could probably create an XSLT file from scratch given a couple of weeks to get to grips with XSLT, but if a readily useable file is already kicking around it would be a great help. Dan AB40k Site Admin http://www.ab40k.org - home of the AB40k maintainers |
#1 |
Senior Member
Volunteer Data File Author
Join Date: Apr 2006
Posts: 130
|
I think I've figured out 99% of it, at least it looks pretty close.
Code:
<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <body bgcolor="#000030" text="#FFFFFF" link="#00FFFF" vlink="#00FFFF"> <p align="center"><b><font size="5" color="#ffff88"><u>Frequently Asked Questions</u></font></b></p> <p align="center"><b><font size="5" color="#ffff88">Warhammer 40 000 5th Edition Data Files</font></b></p> <p align="left">Welcome to the FAQ for the <b>Warhammer 40 000 5th Edition</b> data files for Army Builder. This FAQ contains a collection of important details about the data files for this game system that their author thought you should be aware of. If you have questions that are not covered below, please contact the author of the data files for further information. You will find contact information for the author under the 'Help' menu by selecting the 'Contact Data File Author' menu item.</p> <ul type="circle"> <xsl:for-each select="document/faq"> <xsl:sort select="@order" data-type="number"/> <li><a><xsl:attribute name="href">#<xsl:value-of select="@id"/></xsl:attribute><xsl:value-of select="@topic" disable-output-escaping="yes"/></a></li> </xsl:for-each> </ul> <xsl:for-each select="document/faq"> <xsl:sort select="@order" data-type="number"/> <p align="left"><font color="#ffff88"><a><xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute><u><xsl:value-of select="@topic" disable-output-escaping="yes"/></u></a></font></p> <xsl:value-of select="." disable-output-escaping="yes"/> </xsl:for-each> </body> </html> </xsl:template> </xsl:stylesheet> Dan AB40k Site Admin http://www.ab40k.org - home of the AB40k maintainers |
#2 |
Senior Member
Volunteer Data File Author
Join Date: Apr 2006
Posts: 130
|
Managed to sort out the one element that wasn't ordered, it was due to the default from the DTD being 100 and me not referencing the DTD. I used the copy of the DTD as provided in the current AB Creator kit documentation (file:///C:/Program%20Files/Army%20Builder/docs/kit/kit_dtd.htm#data)
I did have issues with the DTD though - xsltproc keep throwing parser errors on lines using #IMPLIED "0" as this type doesn't allow providing a default value, and this is borne out by all the DTD documentation I could find. eg. Code:
<!ATTLIST statcalc decimals CDATA #IMPLIED "0"> Code:
<!ATTLIST statcalc decimals CDATA "0"> Also had issues with elements that declared children and used #PCDATA as one of the children in the list, as again this is not valid in the DTD specification - if a list of children is provided and includes #PCDATA, the list must use | between child names and cannot use ? after any child name. eg Code:
<!ELEMENT faq (#PCDATA, comment?)> Code:
<!ELEMENT faq (#PCDATA| comment)*> And finally, this also caused a problem: Code:
<!ATTLIST link parentreq (n/a | yes | no) "n/a"> How did you create the DTDs for AB? Are they from a generator, or were they hand coded? For parsing, did you write your own DTD parser? I can't get it to validate with any of the standard tools I've tried. My DTD knowledge is pretty limited but I'm learning fast, I'm pretty sure what I've written above is correct but I'd welcome any info showing that the DTD is valid, possibly using a newer spec than the current version of the XML tools on Ubuntu use and that I've referenced in the links to the W3C. Dan AB40k Site Admin http://www.ab40k.org - home of the AB40k maintainers Last edited by Spack; May 7th, 2011 at 02:12 AM. |
#3 |
Senior Member
Lone Wolf Staff
Join Date: Dec 2008
Posts: 4,690
|
Thanks for your comments about issues with the DTDs - I've put these on a list to investigate in a future bugfix update.
We actually don't use an XSLT file to render the FAQ html - Army Builder parses the data files itself and generates the output HTML file manually. Back in the day (10+ years ago!) when Army Builder was first written, Windows didn't have nearly as good support for XSLT and the other XML stuff as it does now, so we had to roll a lot of our own code. Hope this helps! |
#4 |
Senior Member
Volunteer Data File Author
Join Date: Apr 2006
Posts: 130
|
Cheers Colen.
So far the testing I've done with the XLST and DTD fixes I came up with have gone well, we have automated faq HTML production working from CVS updates and hope to put it public soon Dan AB40k Site Admin http://www.ab40k.org - home of the AB40k maintainers |
#5 |
|
|