[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: accessing attributes

Subject: Re: accessing attributes
From: "Tom Wright" <tom@xxxxxxxxxxxx>
Date: Tue, 09 Sep 2008 14:45:52 -0400
Re:  accessing attributes
On Tue, 09 Sep 2008 14:26:35 -0400, Tom Wright <tom@xxxxxxxxxxxx> wrote:

Hi everyone,
I'm new to this so please forgive any missing information etc.
I'm trying to write an xslt style sheet to transform the xml output from a filemaker database and I'm running into a few issues.
My processor allows XSL v1.0 with library libxslt (running using PHP so looks like this is all I can get).


The filemaker output gives the field names in a metadata node, with the data coming later:

<?xml version="1.0" encoding="UTF-8" ?>
<FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult">
<METADATA>
	<FIELD NAME="F1"/>
	<FIELD NAME="F2"/>
</METADATA>
<DATA>	
	<ROW>
	  <COL><DATA>V1</DATA></COL>
	  <COL><DATA>V2</DATA></COL>
	</ROW>
	<ROW>
	  <COL><DATA>V3</DATA></COL>
	  <COL><DATA>V4</DATA></COL>
	</ROW>
</DATA>



Basically I want to be able to relate each column value to it's name in the METADATA. However I'm not that far yet. To start with can someone please tell me how I should be writing this xsl:value-of element?

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fmp="http://www.filemaker.com/fmpxmlresult"
exclude-result-prefixes="fmp">


<xsl:template match="fmp:FMPXMLRESULT">
<xsl:value-of select="fmp:METADATA/fmp:FIELD[3]@NAME"/>
</xsl:template>
</xsl:stylesheet>


Many thanks tom


Forgive me, I knew that posting would cause me to fix that error. However now I'd like to put this into a for-each loop using the position() function


<xsl:for-each select="fmp:METADATA/fmp:FIELD">

    <tr><td>
      <xsl:param name="pos" select="position()"/>
      <xsl:value-of select="fmp:METADATA/fmp:FIELD[$pos]/@NAME"/>
      <xsl:value-of select="@NAME"/>
    </td></tr>
  </xsl:for-each>

whats the correct syntax to get this working?

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2011 All Rights Reserved.