xml transformation

Cringer

ProgressTalk.com Moderator
Staff member
I've got an Ajax request that creates some xml from a Progress db. I then perform an xsl transformation on it to create an HTML select to plonk on the screen. I pass the selected item through to the xslt as a parameter so that I can set the relevant option as selected. This all works brilliantly for a single option select. The trouble is that now I need to convert it to a multiple option select and thus my parameter is a comma delimited list of selected values. I'm not sure what I need to do to achieve this. Any ideas?
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">


<xsl:param name="SelectID" /> 
<xsl:param name="VarietyListNumber" />


<xsl:output method="html" media-type="text/html" cdata-section-elements="script" omit-xml-declaration="yes" standalone="yes"/>
    <xsl:template match="/">
        <xsl:choose>
            <xsl:when test="count(/finvlin/finvlinRow) = 0">
                                <xsl:element name="select">
                                <xsl:attribute name="multiple">multiple</xsl:attribute> 
                                <xsl:attribute name="size">5</xsl:attribute> 
                                <xsl:attribute name="name">VarietyList</xsl:attribute> 
                                <xsl:attribute name="id"><xsl:value-of select="$SelectID"/></xsl:attribute> 
                                <xsl:attribute name="class">ui-widget-content ui-corner-all DynamicCombo</xsl:attribute> 
                                </xsl:element>
            </xsl:when>
            <xsl:otherwise>    
                    <xsl:element name="select">
                    <xsl:attribute name="multiple">multiple</xsl:attribute> 
                    <xsl:attribute name="size">5</xsl:attribute> 
                    <xsl:attribute name="name">VarietyList</xsl:attribute> 
                    <xsl:attribute name="id"><xsl:value-of select="$SelectID"/></xsl:attribute> 
                    <xsl:attribute name="class">ui-widget-content ui-corner-all DynamicCombo</xsl:attribute> 
                                    <xsl:for-each select="/finvlin/finvlinRow">
                                            <xsl:sort select="VARIETY_DESCRIPTION" data-type="text"/>
                                                <xsl:element name="option">
                                                        <xsl:attribute name="value"><xsl:value-of select="VARIETY_NUMBER"/></xsl:attribute> 
                                                        [COLOR=#ff0000][B]<xsl:if test="VARIETY_NUMBER = $VarietyListNumber">
                                                            <xsl:attribute name="selected">selected</xsl:attribute>
                                                        </xsl:if>[/B][/COLOR]
                                                        <xsl:value-of select="VARIETY_DESCRIPTION"/>
                                                </xsl:element>
                                    </xsl:for-each> 
                                </xsl:element>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
</xsl:stylesheet>
 

Cringer

ProgressTalk.com Moderator
Staff member
Not to worry - I've deferred the selection to a piece of javascript that runs after the xslt has been applied.
 
Top