使用xsl:for-each迭代,使用复杂的xsl:template定义



我要做的是在Radio元素上使用call-template:SpecialRadio,方法是循环遍历每个元素,按位置提取数据,然后对它们执行XSLT。出于某种原因,单选按钮会显示,但StaticLabelCaption数据不会显示,即"Postanschrift"one_answers"SMS/MMS"。XSL哪里出错了?

给定jsp include.xsl

<xsl:template name="SpecialRadio">      
        <xsl:param name="name"/>
        <xsl:param name="map"/>
        <xsl:param name="radio"/>
        <xsl:param name="radioStyle"/>
        <xsl:param name="radioLabel"/>
        <xsl:param name="i"/>

    <StaticLabel>
        <xsl:attribute name="style">
          <xsl:copy-of select="$radioStyle[position()=$i]/@style"/>
          <xsl:text>; margin-left:500px</xsl:text>
        </xsl:attribute>
        <xsl:copy-of select="$radioLabel[position()=$i]/@Caption"/>
    </StaticLabel>

    <Radio>                             
           <ReadOnly>false</ReadOnly>                                                                   
           <Map rtexprvalue="true">mb.getLookup("YES_NO")</Map>
           <Name rtexprvalue="true"><xsl:value-of select="$radio/Name"/></Name>
           <Default rtexprvalue="true">mb.getValue("<xsl:value-of select="Name"/>")/Default>
        </Radio>
</xsl:template>

Given Main.xsl

<div id="head">
    <xsl:call-template name="JspInclude">
            <xsl:with-param name="flush" select="'true'"/>
        <xsl:with-param name="file" select="'Header_1_D.jsp'"/>
    </xsl:call-template>
    <xsl:for-each select="$radio[position() &lt;= 4]">
    <xsl:call-template name="SpecialRadio">
                <xsl:with-param name="i" select="position()"/>
            <xsl:with-param name="name" select="FieldList[@group='2']/Radio/Name"/>
                 <xsl:with-param name="map" select="FieldList[@group='2']/Radio/Map"/>
            <xsl:with-param name="radio" select="FieldList[@group='2']/Radio"/>
            <xsl:with-param name="radioStyle" select="FieldList[@group='2']/StaticLabel"/>
        <xsl:with-param name="radioLabel" select="FieldList[@group='2']/StaticLabel"/>
</xsl:call-template>

给定XML

<FieldList group="2">
        <StaticLabel style="font-family:Arial;color:#330000;font-size:9pt">
            <Caption><![CDATA[Postanschrift]]></Caption>
            <Name><![CDATA[APPLICATION_CUSTOMER.APPLICATION_TYPE]]></Name>
        </StaticLabel>
        <Radio>
            <EntityID><![CDATA[6100]]></EntityID>
            <Name><![CDATA[APPLICATION_CUSTOMER.APPLICATION_TYPE]]></Name>
            <FieldType><![CDATA[]]></FieldType>
            <Default rtexprvalue="true"><![CDATA[mb.getValue("APPLICATION_CUSTOMER.APPLICATION_TYPE", "")]]></Default>
            <Map rtexprvalue="true"><![CDATA[mb.getLookup("YES_NO", "CODE", "NAME", "EN", false,"")]]></Map>
            <ReadOnly rtexprvalue="true"><![CDATA[mb.isReadonly(2)]]></ReadOnly>
            <AccessType><![CDATA[2]]></AccessType>
            <SearchMatchFlag><![CDATA[]]></SearchMatchFlag>
            <InvalidatePlanFlag><![CDATA[false]]></InvalidatePlanFlag>
        </Radio>
        <StaticLabel style="font-family:Arial;color:#330000;font-size:9pt">
            <Caption><![CDATA[SMS / MMS]]></Caption>
            <Name><![CDATA[APPLICATION_CUSTOMER.APPLICATION_TYPE]]></Name>
        </StaticLabel>
        <Radio>
            <EntityID><![CDATA[6101]]></EntityID>
            <Name><![CDATA[APPLICATION_CUSTOMER.APPLICATION_TYPE]]></Name>
            <FieldType><![CDATA[]]></FieldType>
            <Default rtexprvalue="true"><![CDATA[mb.getValue("APPLICATION_CUSTOMER.APPLICATION_TYPE", "")]]></Default>
            <Map rtexprvalue="true"><![CDATA[mb.getLookup("YES_NO", "CODE", "NAME", "EN", false,"")]]></Map>
            <ReadOnly rtexprvalue="true"><![CDATA[mb.isReadonly(2)]]></ReadOnly>
            <AccessType><![CDATA[2]]></AccessType>
            <SearchMatchFlag><![CDATA[]]></SearchMatchFlag>
            <InvalidatePlanFlag><![CDATA[false]]></InvalidatePlanFlag>
        </Radio>        
    </FieldList>

使用Altova生成XSLT

<div id="head">
        <HtmlCode xmlns:jsp="http://www.microforum.com/calms/tags/jsptag-1">
            <jsp:include flush="true" page="Header_1_D.jsp"/>
        </HtmlCode>
        <StaticLabel xmlns:jsp="http://www.microforum.com/calms/tags/jsptag-1" style="; margin-left:500px"/>
        <Radio xmlns:jsp="http://www.microforum.com/calms/tags/jsptag-1">
            <ReadOnly>false</ReadOnly>
            <Map rtexprvalue="true">mb.getLookup("YES_NO")</Map>
            <Name rtexprvalue="true"/>
            <Default rtexprvalue="true">mb.getValue("APPLICATION_CUSTOMER.APPLICATION_TYPE")</Default>
        </Radio>
        <StaticLabel xmlns:jsp="http://www.microforum.com/calms/tags/jsptag-1" style="; margin-left:500px"/>
        <Radio xmlns:jsp="http://www.microforum.com/calms/tags/jsptag-1">
            <ReadOnly>false</ReadOnly>
            <Map rtexprvalue="true">mb.getLookup("YES_NO")</Map>
            <Name rtexprvalue="true"/>
            <Default rtexprvalue="true">mb.getValue("APPLICATION_CUSTOMER.APPLICATION_TYPE")</Default>
        </Radio>
        <HtmlCode>
            <br/>
            <br/>
            <br/>
        </HtmlCode>
    </div>

它不应该沿着这个-的线吗

<xsl:copy-of select="$radioLabel[position()=$i]/Caption"/>

既然Caption是一个元素,而不是一个属性?

最新更新