Hi all,
I've been trying to use a lookup table in order to find a text prompt according to the key(@name) that is retrieved from the source xml.
Here follows snippets of my xml and xsl.
It all looks to be correct, but it's not displaying the prompt text...
I would appreciate a fresh pair of eyes on this.
Lookup XML - prompts.xml:
<prompts>
<prompt>
<key>rentity_branch</key>
<value>Branch</value>
</prompt>
<prompt>
<key>reason</key>
<value>Reason</value>
</prompt>
<prompt>
<key>action</key>
<value>Action taken</value>
</prompt>
...
</prompts>
Source XML to be transformed to HTML:
<element>
<element name="rentity_branch" type="string" mandatory="false" uid="report:rentity_branch"/>
<element name="submission_code" type="string" enum="true" mandatory="true" uid="report:submission_code"/>
<element name="report_code" type="string" enum="true" mandatory="true" uid="report:report_code"/>
....
</element>
XSL: in this snippet i'm trying to get the rentity_branch element to display a prompt text:
<xsl:key name="promptLookup" match="prompt" use="key"/>
<xsl:variable name="promptsElt" select="document('prompts.xml')/prompts"/>
<xsl:template match="*[@name='rentity_branch']">
<span class="lineval">
<xsl:apply-templates select="$promptsElt">
<xsl:with-param name="curr-element" select="./@name"/>
</xsl:apply-templates>
<xsl:text> : </xsl:text>
<input>
<xsl:attribute name="type">text</xsl:attribute>
<xsl:attribute name="class">box</xsl:attribute>
<xsl:attribute name="id">
<xsl:value-of select="@uid"/>
</xsl:attribute>
<xsl:attribute name="name">
<xsl:value-of select="@uid"/>
</xsl:attribute>
<xsl:attribute name="value">
<xsl:value-of select="current()"/>
</xsl:attribute>
</input>
</span>
</xsl:template>
<xsl:template match="prompts">
<xsl:param name="curr-element"/>
<xsl:value-of select="key('promptLookup', $curr-element)/value"/>
</xsl:template>