I'm stuck on something that should be simple. I have a "templet" of a form, and I am filling in the values of input fields with a dataset generated from an SQl query.
Code:
[XML]
<root>
<template>
<section>
<line class="label">
<edit type="TEXT" label="First" name="nameFirst"/>
<edit type="TEXT" label="Last" name="nameLast"/>
</line>
<section>
<!-- more sections -->
</template>
<dataSet>
<nameFirst>Thomas</nameFirst>
<nameLast>Smith</nameLast>
</dataSet>
</root>
[/XML]
[XSLT]
<xslt:transform xmlns:xslt="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform"[/URL] version="1.0">
<xslt:output method="html" omit-xml-declaration="yes"/>
<xslt:template match="template">
<xslt:apply-templates/>
</xslt:template>
<xslt:template match="section">
<div class="formElement">
<xslt:for-each select="line">
<div class="line">
<xslt:for-each select="edit">
<span class="label">
<xslt:value-of select="@label"/>:</span>\n
<xslt:element name="input">
<xslt:attribute name="type">TEXT</xslt:attribute>
<xslt:attribute name="name">
<xslt:apply-templates select="@name"/>
</xslt:attribute>
<xslt:attribute name="class">
<xslt:apply-templates select="@class"/>
</xslt:attribute>
<xslt:attribute name="value">
<xslt:apply-templates select="//dataSet/@name"/>
</xslt:attribute>
</xslt:element>
</xslt:for-each>
</div>
</xslt:for-each>
</div>
</xslt:template>
<xslt:template match="dataSet/*">
<xslt:value-of select="."/>
</xslt:template>
</xslt:transform>
[/XSLT]
[code]
I am trying to use the name e.g. nameFirst to select the value of nameFirst from my dataSet and assign that to the value= attribute of an element.
<xslt:apply-templates select="@name"/>
inserts "nameFirst" (being the name attribute) for value
<xslt:apply-templates select="//@name"/>
inserts all of the values of the members of dataSet
<xslt:apply-templates select="//dataSet/@name"/>
and many other variations, select nothing.
I have struggled with too many variations to number here. I would appreciate any pointers/