• Please note: In an effort to ensure that all of our users feel welcome on our forums, we’ve updated our forum rules. You can review the updated rules here: http://forums.wolflair.com/showthread.php?t=5528.

    If a fellow Community member is not following the forum rules, please report the post by clicking the Report button (the red yield sign on the left) located on every post. This will notify the moderators directly. If you have any questions about these new rules, please contact support@wolflair.com.

    - The Lone Wolf Development Team

Default XSLT for AB Data file

Spack

Well-known member
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.
 
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>

The only thing that's out of place is the General heading, but I think I've just about figured that out.
 
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">

is not valid, it should be

Code:
<!ATTLIST statcalc decimals CDATA "0">

See http://www.w3.org/TR/xml/#sec-attr-defaults (note that IMPLIED means that the attribute is optional and has no default value)

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?)>

is not valid, it should be something like

Code:
<!ELEMENT faq (#PCDATA| comment)*>

See http://www.w3.org/TR/xml/#sec-element-content


And finally, this also caused a problem:

Code:
<!ATTLIST link parentreq (n/a | yes | no) "n/a">

as / is not allowed in the enumerated list because NameChar only allows "-", ".", ":", "_", letters, numbers, and some extended characters. The forward slash is not in the allowed list of characters. See http://www.w3.org/TR/2008/REC-xml-20081126/#NT-Name (scroll up just a little as the anchor puts the browser just under the definition).

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.
 
Last edited:
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!
 
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 :)
 
Back
Top