2012-09-06 33 views
0

我想要做的是在Radio元素上使用call-template:SpecialRadio,方法是循環遍歷每個元素,按位置提取數據,然後對它們執行XSLT 。出於某種原因,單選按鈕出現,但StaticLabelCaption數據沒有出現,即'Postanschrift'和'SMS/MMS'。我的XSL在哪裏出了問題?迭代使用xsl:for-each使用複雜的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

<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> 

回答

1

不是應該沿此線XSLT -

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

因爲標題是一個元素,而不是一個屬性?