• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSTL: Help needed in retrieving data from xml, setting it and printing  RSS feed

 
lavi mendonca
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am reading the contents of an xml file in my jsp through the jstl xml tags. How do i retrieve the data and set it into another variable, so that i can use it to either output on the browser or set in the html input tag.

I tried the below, but it does not work. The xml document is in the memory in request scope (xmlDoc)

<x:choose>
<x:when select="$xmlDoc/document/validation/flag[text()='N']">
<x:set var="name" select="$xmlDoc/document/names/firstName"/>
</x:when>

<xtherwise>
<x:set var="name" select="$xmlDoc/document/names/lastName"/>
</xtherwise>
</x:choose>
<b><cut value="${name}"/></b>
<input type="hidden" name="name-text" value="${name}"/>

Assume that the condition is not satisfied and it goes into the 'otherwise' loop. I verified this by putting a c: out in both the 'when' and 'otherwise' clause and 'otherwise' got executed. cut for name displays question: null
The same value gets displayed for the value of the input tag.

If I change the select to $xmlDoc/document/names/firstName/text(), then cut displays #text: ABC (i.e the value present for the element node question.

Could someone please let me know what is wrong and how do i correct it ?
I do not want to use xut tag and input html tag in both 'when' and 'otherwise' loop.

Thanks.
 
lavi mendonca
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I figured out the mistake.

Should be using <xut select="$var"/>
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!