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

Re: making html-form with an identifier in a xsl:for-e

Subject: Re: making html-form with an identifier in a xsl:for-each
From: "M. David Peterson" <conners_dad@xxxxxxx>
Date: Sat, 11 Oct 2003 18:22:46 -0600
html form concat
Hello Nica,

As long as you don't change your context node from 'test' you can simply 
insert the following into your XSLT file between the quotes...

{concat('test_', position())}

or in other words

<input type="text" name="{concat('test_', position())}"/>

Through each iteration through the <xsl:for-each> you will get Test_1, 
Test_2, Test_3 and so forth rendered into your html output.

Keep in mind that the postion() function of XPath is relative to the current 
context node (in this case 'test').  If that changes your position count 
will change.

Best regards,

M.


----- Original Message ----- 
From: "Nica Huestegge" <Nica.H@xxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Saturday, October 11, 2003 5:53 AM
Subject:  making html-form with an identifier in a xsl:for-each


> Hi!
>
> I have a little question - probably easy-to-answer, except for a newbie 
> like
> me. I try to describe it as precisely as possible, which makes my mail 
> very
> long. I am sorry, but I dont want to bother you with an unclear question 
> and
> i hope you wont mind the long mail. Thank You.
>
>
> I have a number of xml-files which includes something like the following
> (Actually, there is much more stuff around in those files, but I try to 
> keep
> it reduced to my question...):
>
> <test id="test1">
>   <question>
>     What is five plus four?
>   </question>
>   <answer>
>     nine
>   </answer>
> </test>
> <test id="test2">
>   <question>
>     What is five minus two?
>   </question>
>   <answer>
>     three
>   </answer>
> </test>
>
> Where the number of <test>-elements varies from file to file.
>
> I want an output in html, where the question is just text and after every
> question there is a form input for the answer. the whole form will be send
> to a servlet. So the html will look something like this:
>
> <form method="post" action="NextServlet">
>   <p>
>     What is five plus four?<br/>
>     <input type="text" name="test1"/>
>   </p>
>   <p>
>     What is five minus two?<br/>
>     <input type="text" name="test2"/>
>   </p>
>   <input type="submit"/>
> </form>
>
> Now, the xsl. I know it has to be something like this:
>             <form method="post" action="NextServlet">
>             <xsl:for-each select="test">
>             <p>
>             <xsl:value-of select="question" /><br/>
>             <input type="text" name="????????"/>
>             </p>
>             </xsl:for-each>
>             <input type="submit"/>
>             </form>
> As you can see, the questionmarks are where my problem is. How can I put a
> unique identifier there (which should equal "test1" or "test2", the id-
> attribute of <test>, so that my Servlet can compare the given answer to 
> that
> in the xml-file?
>
> Thank you for your time (and answer), sorry for any mistakes (english just
> isnt my language...),
> Nica Huestegge
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>
> 

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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-2013 All Rights Reserved.