XSLT Tag - Hidden Input Form Fields

Posted on 2005-02-25
Medium Priority
Last Modified: 2013-11-19

If I have an XML file with multiple criteria (namely, Lastname, Insurance, Language):

<Name>Empire Health</Name>

How would I be able to submit all these values as hidden input form fields in my XSLT?

I am already sending in SessionID:

<input type="hidden" name="SessionID" value="{@SessionID}">

and a single Search Criterion:

<input type="hidden" name="{Params/Criteria/Criterion/Type}" value="{Params/Criteria/Criterion/Type}">

I fear I am missing the situation where multiple search criteria are within the XML and will not be returned. .. How would I iterate between all the values within the Criterion, so as to not miss sending those Criterion values in?

Any advice or guidance is greatly appreciated!

Best regards,
Question by:jmc430
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Author Comment

ID: 13407511
Slight correction, the single search criterion i am sending is:

<input type="hidden" name="{Params/Criteria/Criterion/Type}" value="{Params/Criteria/Criterion/Name}">

Author Comment

ID: 13407869
This is what I have so far:

<xsl:if test="count(Params/Criteria/Criterion) >0">
<xsl:for-each select="Params/Criteria/Criterion">
<xsl:if test="Name/text()">

<input type="hidden" value="{Params/Criteria/Criterion/Name}" name="{Params/Criteria/Criterion/Type}"></input>

and for testing purposes (to print out what's in the XML) <xsl:value-of select="Name"></xsl:Value-of>


What am I doing wrong?

LVL 52

Assisted Solution

by:Carl Tawn
Carl Tawn earned 800 total points
ID: 13408085
Something like this should do the trick:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:output method="html" encoding="iso-8859-1" />

    <xsl:template match="Params">
        <xsl:apply-templates />

    <xsl:template match="Criterion">
        <xsl:element name="input">
            <xsl:attribute name="type">hidden</xsl:attribute>
            <xsl:attribute name="name"><xsl:value-of select="Type" /></xsl:attribute>
            <xsl:attribute name="value"><xsl:value-of select="Name" /></xsl:attribute>


Hope this helps.
LVL 26

Accepted Solution

rdcpro earned 1200 total points
ID: 13408847
Or just fix the XPath:

<input type="hidden" value="{Name}" name="{Type}"></input>

When you do something like:

<xsl:for-each select="Params/Criteria/Criterion">

you're changing the context inside the for-each, so now your XPath expressions should be relative to the current Criterion node.

Mike Sharp

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question