Hi all!

Does anyone know if it is it possible to send the "document" variable
created by a x:set as a parameter to a tag file? 
I need to continue with xml x xpath expressions within the tag file.

Example:

FILE: index.jsp

<%@ taglib uri="http://java.sun.com/jsp/jstl/xml"; prefix="x" %> 
<%@ taglib uri="http://java.sun.com/jsp/jstl/core"; prefix="c" %>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<c:set var="xml">
        <record_list>
                <record>
                        <field>
                                <string>
                                        <red>Volvo</red>
                              </string>
                        </field>
                        <field>
                                <string>
                                      <black>1200</black>
                            </string>
                        </field>
                        ...
                </record>
        </record_list>
</c:set>

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

<x:forEach select="$document/record_list/record/field" var="node">
        <x:if select="$node/string">
                <x:set var="string" select="$node/string"/>
                <tags:formatString string="$string"/>
        </x:if>
        ...
        <x:if select...>
        </x:if>
</x:forEach>


FILE: formatString.tag

<%@ taglib uri="http://java.sun.com/jsp/jstl/xml"; prefix="x" %> 
<%@ attribute name="string" %>
<x:choose>
        <x:when select="$string/red" var="text">
                <font style="font-color:red"><x:out
select="$text"/></font>
        </x:when>
        <x:when select="$string/black" var="text">
                <font style="font-color:black"><x:out
select="$text"/></font>
        </x:when>
</x:choose>


Thanks for your help

/Christian Andersson

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to