Steve Jackson Games - Site Navigation
Home General Info Follow Us Search Illuminator Store Forums What's New Other Games Ogre GURPS Munchkin Our Games: Home

Go Back   Steve Jackson Games Forums > The Network > GURPS Character Assistant

Reply
 
Thread Tools Display Modes
Old 11-01-2017, 10:28 AM   #1
Liantefaron
 
Liantefaron's Avatar
 
Join Date: Dec 2005
Location: Giessen/Hessen/Germany
Default (Ab-?)Using GCA files as HTML table reference/shopping list

Hi guys,

I had an idea I'd like to share with you, namely, to display the existing GCA data files' equipment sections as a sortable, filterable shopping list (like in this screenshot).


Since this uses existing data (.GDF data sheets) and mechanisms (a .GCE export sheet), I'm confident that it wouldn't violate SJGames online policy... possibly as long as one has a valid GCA4 license to get at the "official" GDF files and actually use a GCE export sheet on them.

What you need:
  • GCA4 to process GCA files with a GCE sheet
  • A text editor (I use Notepad++ for XML highlighting)
  • Optionally Excel (or LibO Calc) to easily modify the XML
  • The example XSL sheet below to tell your browser to display the XML nicely
  • (optionally) the list.js JavaScript library, which adds sorting and filtering to XML/HTML tables

Here's how it works:
  1. Install a GCE export sheet that will render GDF data as XML. I have (mis-)used Spyke's Fantasy Grounds export filter, renamed it to "xml export equipment.gce" and deleted/commented out all sections following line 65 except the "Call PrintEquipment()" directive.
  2. Open a blank character in GCA4 with your data files of choice loaded and add all equipment to him (or her, or whatever).
  3. Use the export sheet to create your XML version of the equipment entries.
  4. Optional: Open the XML file in Excel and hide/delete columns you won't need, then save back as XML.
  5. Optional: Localize the XML for your non-English-speaking players by opening the XML in Excel, adding a new nameDE (or nameFR, nameES, etc.) column next to the 'name' column and save again as XML.
  6. Use a text editor to add <?xml-stylesheet type="text/xsl" href="GURPSequipment.xsl"?> as a new line after the opening <xml ...> tag. This will tell your browser to look for the specified XSL file to display the XML file.
  7. Use an XSL file to output the XML as HTML, so that your browser can render it in a way that doesn't look awful. Two examples follow, one for a bland English-only table and one for a localized table that uses the list.js library and some CSS to improve the look.
  8. Put the XML file, XSL file and optionally the list.js / list.min.js files in the same directory and open the XML file with your browser.
  9. Quickly search for equipment, look up relevant stats or the item's page reference for the full information. Bam!

Example XSL Sheet for a bland, English-only HTML table:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes"/>

<xsl:template match="/">
	<html>
	<body>
	<h1>GURPS Equipment (XSLT Conversion from GCA Files)</h1>
	<p><a href="index.php">Back to Index</a></p>
		<table border="1" cellspacing="0" cellpadding="2" color="#DDDDDD" style="border:1px solid #ddd;">
			<tr>
				<th>Item</th>
				<th>Cost</th>
				<th>Weight</th>
				<th>LC</th>
				<th>TL</th>
				<th>Page</th>
				<th>Other Info</th>
			</tr>
			<xsl:apply-templates/>
		</table>
	</body>
	</html>
</xsl:template>

<xsl:template match="equipment">
	<xsl:for-each select="*"> <!-- take all descendants of equipment (ID tags) -->
		<tr>
			<!--<td><xsl:value-of select="local-name()"/></td>-->
			<td><xsl:value-of select="./name"/></td>
			<td><xsl:value-of select="./basecost"/> <xsl:text>$</xsl:text> </td>
			<td><xsl:value-of select="./baseweight"/> <xsl:text>lbs.</xsl:text> </td>
			<td>
				<xsl:choose>
					<xsl:when test="./lc != ''">
						<xsl:value-of select="./lc"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:text>4</xsl:text>
					</xsl:otherwise>
				</xsl:choose>
			</td>
			<td>
				<xsl:choose>
					<xsl:when test="./tl != ''">
						<xsl:value-of select="./tl"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:text>3</xsl:text>
					</xsl:otherwise>
				</xsl:choose>
			</td>
			<td><xsl:value-of select="./page"/></td>
			<td style="font-size:0.8rem">
				<xsl:choose>
					<xsl:when test="./damage != ''">
						<xsl:text>Dam: </xsl:text> <xsl:value-of select="./mode"/>
						<xsl:text> </xsl:text> <xsl:value-of select="./damage"/>
						<xsl:text> </xsl:text> <xsl:value-of select="./damtype"/>
						<xsl:text> / R: </xsl:text> <xsl:value-of select="./reach"/>
						<xsl:text> Parry: </xsl:text> <xsl:value-of select="./parry"/>
						<xsl:text> MinST: </xsl:text> <xsl:value-of select="./minst"/>
						<xsl:text> / Acc: </xsl:text> <xsl:value-of select="./acc"/>
						<xsl:text> D: </xsl:text> <xsl:value-of select="./rangehalfdam"/>
						<xsl:text> Max: </xsl:text> <xsl:value-of select="./rangemax"/>
						<xsl:text> RoF: </xsl:text> <xsl:value-of select="./rof"/>
						<xsl:text> Shots: </xsl:text> <xsl:value-of select="./shots"/>
						<xsl:text> Blk: </xsl:text> <xsl:value-of select="./bulk"/><br/>
					</xsl:when>
				</xsl:choose>

				<xsl:choose>
					<xsl:when test="./dr != ''">
					<xsl:text>DR: </xsl:text> <xsl:value-of select="./dr"/>
					<xsl:text> </xsl:text><xsl:value-of select="./location"/><br/>
					</xsl:when>
				</xsl:choose>

				<xsl:choose>
					<xsl:when test="./skillused != ''">
					<xsl:text>Skill: </xsl:text> <xsl:value-of select="./skillused"/> <xsl:text> / </xsl:text>
					</xsl:when>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="./notes != ''">
					<xsl:text> Notes: </xsl:text> <xsl:value-of select="./notes"/> <br/>
					</xsl:when>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="./description != ''">
					<xsl:text> Desc: </xsl:text> <xsl:value-of select="./description"/> <br/>
					</xsl:when>
				</xsl:choose>
				<xsl:text> Cat: </xsl:text> <xsl:value-of select="./cat"/> <br/>
			</td>
		</tr>
	</xsl:for-each>
</xsl:template>

<!-- do nothing for unmatched text or attribute nodes -->
<xsl:template match="text()|@*"/>

</xsl:stylesheet>
Cheers,
Christopher
__________________
Liantefaron - Hunter of Spiders
Woodelven Ranger

Real Name: Christopher.
steinmetze.org (with my GCA-datafiles) has perished in 2012. Try an archive.org version if you need them.

Last edited by Liantefaron; 11-01-2017 at 11:17 AM.
Liantefaron is offline   Reply With Quote
Old 11-01-2017, 10:32 AM   #2
Liantefaron
 
Liantefaron's Avatar
 
Join Date: Dec 2005
Location: Giessen/Hessen/Germany
Default Re: (Ab-?)Using GCA files as HTML table reference/shopping list

And here's an example that uses a bilingual XML file and loads list.js and as well as some CSS to pretty up things:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes"/>

<xsl:template match="/">
	<html>
	<head>
		<STYLE type="text/css"><!--
		body {font-family:sans-serif;}
		table {border-collapse:collapse;}
		th,td {border:1px solid #999; vertical-align:top;}
		th {text-align:center;}
		td.name, td.namede, td.comments {text-align:left;}
		td.basecost, td.baseweight, td.page {text-align:right;}
		td.lc, td.tl {text-align:center;}
		input {
		  border:solid 1px #ccc;
		  border-radius: 5px;
		  padding:7px 14px;
		  margin-bottom:10px
		}
		input:focus {
		  outline:none;
		  border-color:#aaa;
		}
		.sort {
		  padding:8px 30px;
		  border-radius: 6px;
		  border:none;
		  display:inline-block;
		  color:#fff;
		  text-decoration: none;
		  background-color: #28a8e0;
		  height:30px;
		}
		.sort:hover {
		  text-decoration: none;
		  background-color:#1b8aba;
		}
		.sort:focus {
		  outline:none;
		}
		.sort:after {
		  display:inline-block;
		  width: 0;
		  height: 0;
		  border-left: 5px solid transparent;
		  border-right: 5px solid transparent;
		  border-bottom: 5px solid transparent;
		  content:"";
		  position: relative;
		  top:-10px;
		  right:-5px;
		}
		.sort.asc:after {
		  width: 0;
		  height: 0;
		  border-left: 5px solid transparent;
		  border-right: 5px solid transparent;
		  border-top: 5px solid #fff;
		  content:"";
		  position: relative;
		  top:4px;
		  right:-5px;
		}
		.sort.desc:after {
		  width: 0;
		  height: 0;
		  border-left: 5px solid transparent;
		  border-right: 5px solid transparent;
		  border-bottom: 5px solid #fff;
		  content:"";
		  position: relative;
		  top:-4px;
		  right:-5px;
		}
	-->	</STYLE>
	</head>
	<body>
	<h1>GURPS Equipment (XSLT Conversion from GCA Files)</h1>
	<p><a href="index.php">Back to Index</a></p>
	<div id="sorttable">
		<button class="sort" data-sort="name" style="margin-right:10px;">Sort by EN Item Name</button>
		<button class="sort" data-sort="namede" style="margin-right:10px;">Nach DE Name sortieren</button>
		<input class="search" placeholder="Search / Suche"/>
		<table id="G4Equip" border="1" cellspacing="0" cellpadding="2" color="#DDDDDD" style="border:1px solid #ddd;">
			<tbody class="list">
			<tr>
				<th width="15%">Item</th>
				<th width="15%">Deutsch</th>
				<th width="5%">Cost</th>
				<th width="5%">Weight</th>
				<th width="5%">LC</th>
				<th width="5%">TL</th>
				<th width="5%">Page</th>
				<th width="45%">Other Info</th>
			</tr>
			<xsl:apply-templates/>
			</tbody>
		</table>
	</div>
	<script src="list.min.js"></script>
	<script>
		var options = { valueNames: [ 'name', 'namede', 'basecost', 'baseweight', 'lc', 'tl', 'page', 'comments' ] };
		var userList = new List('sorttable', options);
	</script>
	</body>
	</html>
</xsl:template>

<xsl:template match="equipment">
	<xsl:for-each select="*"> <!-- take all descendants of equipment (ID tags) -->
		<tr>
			<!--<td><xsl:value-of select="local-name()"/></td>-->
			<td class="name" width="15%"><xsl:value-of select="./name"/></td>
			<td class="namede" width="15%"><xsl:value-of select="./namede"/></td>
			<td class="basecost" width="5%"><xsl:value-of select="./basecost"/> <xsl:text> $</xsl:text> </td>
			<td class="baseweight" width="5%"><xsl:value-of select="./baseweight"/> <xsl:text> lbs.</xsl:text> </td>
			<td class="lc" width="5%">
				<xsl:choose>
					<xsl:when test="./lc != ''">
						<xsl:value-of select="./lc"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:text>4</xsl:text>
					</xsl:otherwise>
				</xsl:choose>
			</td>
			<td class="tl" width="5%">
				<xsl:choose>
					<xsl:when test="./tl != ''">
						<xsl:value-of select="./tl"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:text>3</xsl:text>
					</xsl:otherwise>
				</xsl:choose>
			</td>
			<td class="page" width="5%"><xsl:value-of select="./page"/></td>
			<td class="comments" width="45%" style="font-size:0.8rem">
				<xsl:choose>
					<xsl:when test="./damage != ''">
						<xsl:text>Dam: </xsl:text> <xsl:value-of select="./mode"/>
						<xsl:text> </xsl:text> <xsl:value-of select="./damage"/>
						<xsl:text> </xsl:text> <xsl:value-of select="./damtype"/>
						<xsl:text> / R: </xsl:text> <xsl:value-of select="./reach"/>
						<xsl:text> Parry: </xsl:text> <xsl:value-of select="./parry"/>
						<xsl:text> MinST: </xsl:text> <xsl:value-of select="./minst"/>
						<xsl:text> / Acc: </xsl:text> <xsl:value-of select="./acc"/>
						<xsl:text> D: </xsl:text> <xsl:value-of select="./rangehalfdam"/>
						<xsl:text> Max: </xsl:text> <xsl:value-of select="./rangemax"/>
						<xsl:text> RoF: </xsl:text> <xsl:value-of select="./rof"/>
						<xsl:text> Shots: </xsl:text> <xsl:value-of select="./shots"/>
						<xsl:text> Blk: </xsl:text> <xsl:value-of select="./bulk"/><br/>
					</xsl:when>
				</xsl:choose>

				<xsl:choose>
					<xsl:when test="./dr != ''">
					<xsl:text>DR: </xsl:text> <xsl:value-of select="./dr"/>
					<xsl:text> </xsl:text><xsl:value-of select="./location"/><br/>
					</xsl:when>
				</xsl:choose>

				<xsl:choose>
					<xsl:when test="./skillused != ''">
					<xsl:text>Skill: </xsl:text> <xsl:value-of select="./skillused"/> <xsl:text> / </xsl:text>
					</xsl:when>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="./notes != ''">
					<xsl:text> Notes: </xsl:text> <xsl:value-of select="./notes"/> <br/>
					</xsl:when>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="./description != ''">
					<xsl:text> Desc: </xsl:text> <xsl:value-of select="./description"/> <br/>
					</xsl:when>
				</xsl:choose>
				<xsl:text> Cat: </xsl:text> <xsl:value-of select="./cat"/> <br/>
			</td>
		</tr>
	</xsl:for-each>
</xsl:template>

<!-- do nothing for unmatched text or attribute nodes -->
<xsl:template match="text()|@*"/>

</xsl:stylesheet>
Three lines are particularly interesting for changes: line 90 (<th width="15%">Deutsch</th>), where I create a table row header for the second language; line 104 (var options= ...), where I tell list.js which columns it should process; and line 116 (<td class="namede" width="15%"><xsl:value-of select="./namede"/></td>), where the iterating XSL transformation will fill the table's second language column with data. Change/delete these to allow for another second language or to get by without.

So... what do you think?
__________________
Liantefaron - Hunter of Spiders
Woodelven Ranger

Real Name: Christopher.
steinmetze.org (with my GCA-datafiles) has perished in 2012. Try an archive.org version if you need them.

Last edited by Liantefaron; 11-01-2017 at 10:38 AM.
Liantefaron is offline   Reply With Quote
Old 11-03-2017, 12:25 PM   #3
Armin
 
Armin's Avatar
 
Join Date: Aug 2004
Location: Portland, OR
Default Re: (Ab-?)Using GCA files as HTML table reference/shopping list

I don't see any problem with doing this. It seems like it could be helpful for some folks, although it's not something that I need.

Thanks for sharing. Perhaps it will also inspire some other folks to make other such tools.
__________________
Armin D. Sykes | GCA Prime
My GCA page | The GCA Wiki
Armin is offline   Reply With Quote
Old 11-06-2017, 05:07 AM   #4
Liantefaron
 
Liantefaron's Avatar
 
Join Date: Dec 2005
Location: Giessen/Hessen/Germany
Default Re: (Ab-?)Using GCA files as HTML table reference/shopping list

Thank you for your encouragement, Armin. :)
__________________
Liantefaron - Hunter of Spiders
Woodelven Ranger

Real Name: Christopher.
steinmetze.org (with my GCA-datafiles) has perished in 2012. Try an archive.org version if you need them.
Liantefaron is offline   Reply With Quote
Reply

Tags
gca4, gdf, html, xml

Thread Tools
Display Modes

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
Fnords are Off
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 11:18 PM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2017, vBulletin Solutions, Inc.