jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rick Bullotta" <rick.bullo...@lighthammer.com>
Subject Issue with JSTL xml taglib when accessing node attribute
Date Tue, 06 Apr 2004 14:33:15 GMT
We're discovering some fairly significant limitations with the xml taglib
when dealing with node values, particularly attribute values...


Given the following xml:




                        <Column Name="ABC" Type="1"/>          

                        <Column Name="CDE" Type="2"/>          
















And the following JSP (this was pseudo-coded from the real thing):


The goal is to iterate through the rows and columns, and based on the
column's metadata type (which can easily be derived via Xpath and the column
name), output data accordingly..


<c:import var="docString" url="Thing.xml"/>

<x:parse var="document" doc="${docString}"/>


<x:forEach select="$document/Data/DataRow" var="RowDetail"

            <x:forEach select="$RowDetail/*" var="ColumnDetail">

                        <x:set var="ColumnName" select="name(.)"/>

                        <x:set var="ColumnType"
select="../../Metadata/Column[@Name = $ColumnName]"/>


<c:if test="${ColumnType == '1'}>

                                    Do Something for type 1.



<c:if test="${ColumnType == '2'}>

                                    Do Something for type 2.





Bottom line is we need to place the value of the xml node's attribute into a
variable that can later be used in comparisons, as in the above example, and
there does not appear to be a way to do so.


We've also tried using the following in lieu of the c:if tags, to no avail:


                        <x:if select="../../Metadata/Column[@Name =
$ColumnName][@Type == '1']">

                                    Do something for type 1



                        <x:if select="../../Metadata/Column[@Name =
$ColumnName][@Type == '2']">

                                    Do something for type 2



Is there a way to "scalar-ize" (new word! <g>) the results of an x:set.  If
you do a c:out on an attribute node selected using x:set, it is treated as
the string:


[Type = "1"]


..,not simply 1


Any recommendations welcomed!


- Rick





  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message