We help IT Professionals succeed at work.

Filemaker xsl file

Hi,

I am having a xml , which is a simple table . I just need to make the first column bold and header in yellow color .

Please help me provide a xsl file for it.

Thanks
test.xml
Comment
Watch Question

So, do you need an XSLT which converts the data XML to HTML?
Since I did not get an answer to my question, I assumed you need an HTML output.
I made a simple XSLT which creates an HTML table from your input XML:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" 
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:f="http://www.filemaker.com/fmpxmlresult">
<xsl:output method="html" encoding="iso-8859-1"/>

<xsl:template match="/">
  	<xsl:apply-templates select="f:FMPXMLRESULT/f:RESULTSET/f:ROW"/>
</xsl:template>

<xsl:template match="f:ROW">
  <table border="1">
  	<xsl:apply-templates select="f:COL"/>
  </table>
</xsl:template>
	
<xsl:template match="f:COL">
  <tr>
	<xsl:if test="position() = 1">
		<xsl:attribute name="style">background-color: yellow;</xsl:attribute>
	</xsl:if>
    <xsl:apply-templates select="f:DATA"/>
  </tr>
</xsl:template>	
	
<xsl:template match="f:DATA">
	<td>
		<xsl:if test="position() = 1">
			<xsl:attribute name="style">font-weight: bold;</xsl:attribute>
  		</xsl:if>
		<xsl:value-of select="."/>
		<xsl:if test="string-length(normalize-space(.)) = 0">&#xA0;</xsl:if>
	</td>
</xsl:template>	
	
</xsl:stylesheet>

Open in new window

Author

Commented:
Hi,
yes this is what i am looking for , i will test it and let you know.

Thanks

Author

Commented:
Hi ,

I am getting the output in different manner.
I want them to show like  below.

NAME              VALUE
Retail Price       100
Item Class         25486

But i am getting the html table in horizontal way. Please find the result i have got.

<table xmlns:f="http://www.filemaker.com/fmpxmlresult" border="1">
<tr style="background-color: yellow;">
<td style="font-weight: bold;">Retail Price</td><td>Item Class</td><td>Item Group</td><td>Consumer Description</td><td>Color</td><td>Item Code</td><td>Catalog Vendor Name</td><td>Item Status</td><td>Wildcat Eligible</td><td>Item Description</td><td>Primary Vendor</td><td>InventoryTyp</td><td>ProductPageNumber</td><td>Vendor Group</td>
</tr>
<tr>
<td style="font-weight: bold;">234.99</td><td>13034</td><td>13</td><td>BlackGorge Expandable Convertible Pack System With Hydration Pocket Mossy Oak Break Up Camouflage</td><td>Mossy Oak Break-Up</td><td>73CP00M1</td><td>BLACKHAWK!</td><td>OPEN</td><td>Y</td><td>BHP BLACKGORGE EXPAND MOBU</td><td>58895</td><td>MDS</td><td>&nbsp;</td><td>BHP</td>
</tr>
</table>

Open in new window


Thanks,
Ok, have redesigned it a little:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" 
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:f="http://www.filemaker.com/fmpxmlresult">
<xsl:output method="html" encoding="iso-8859-1"/>

<xsl:template match="/">
  	<xsl:apply-templates select="f:FMPXMLRESULT/f:RESULTSET/f:ROW"/>
</xsl:template>

<xsl:template match="f:ROW">
  <table border="1" cellspacing="0">
  	<tr style="background-color: yellow;"><td>NAME</td><td>VALUE</td></tr>
  	<xsl:apply-templates select="f:COL[1]/f:DATA"/>
  </table>
</xsl:template>

<xsl:template match="f:DATA">
  <xsl:variable name="p" select="position()"/>
  <tr>
	<td style="font-weight: bold;">
		<xsl:value-of select="."/>
	</td>
	<xsl:apply-templates select="../../f:COL[2]/f:DATA[$p]" mode="right-col"/>
  </tr>
</xsl:template>

<xsl:template match="f:DATA" mode="right-col">
	<td>
		<xsl:value-of select="."/>
		<xsl:if test="string-length(normalize-space(.)) = 0">&#xA0;</xsl:if>
	</td>
</xsl:template>	
	
</xsl:stylesheet>

Open in new window

Author

Commented:
This works great , thank you.
You're welcome