Lone Wolf Development Forums  

Go Back   Lone Wolf Development Forums > Army Builder Forums > Army Builder
Register FAQ Community Today's Posts Search

Notices

Reply
 
Thread Tools Display Modes
Spack
Senior Member
Volunteer Data File Author
 
Join Date: Apr 2006
Posts: 130

Old May 6th, 2011, 07:15 AM
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
Spack is offline   #1 Reply With Quote
Spack
Senior Member
Volunteer Data File Author
 
Join Date: Apr 2006
Posts: 130

Old May 6th, 2011, 12:00 PM
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.

Dan
AB40k Site Admin
http://www.ab40k.org - home of the AB40k maintainers
Spack is offline   #2 Reply With Quote
Spack
Senior Member
Volunteer Data File Author
 
Join Date: Apr 2006
Posts: 130

Old May 7th, 2011, 01:45 AM
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.

Dan
AB40k Site Admin
http://www.ab40k.org - home of the AB40k maintainers

Last edited by Spack; May 7th, 2011 at 02:12 AM.
Spack is offline   #3 Reply With Quote
Colen
Senior Member
Lone Wolf Staff
 
Join Date: Dec 2008
Posts: 4,690

Old May 9th, 2011, 09:08 PM
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!
Colen is offline   #4 Reply With Quote
Spack
Senior Member
Volunteer Data File Author
 
Join Date: Apr 2006
Posts: 130

Old May 12th, 2011, 11:54 PM
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
Spack is offline   #5 Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 07:30 AM.


Powered by vBulletin® - Copyright ©2000 - 2024, vBulletin Solutions, Inc.
wolflair.com copyright ©1998-2016 Lone Wolf Development, Inc. View our Privacy Policy here.