0

我想要做的是通过循环遍历每个元素,按位置提取数据,然后对它们执行 XSLT 来使用元素call-template:SpecialRadioRadio出于某种原因,单选按钮出现了,但没有显示Caption数据StaticLabel,即“Postanschrift”和“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>

给定 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>
4

1 回答 1

1

不应该是这样的——

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

因为 Caption 是一个元素,而不是一个属性?

于 2012-09-06T22:21:19.317 回答