使用xslt动态分配td样式 [英] Dynamically assign td style with xslt

查看:106
本文介绍了使用xslt动态分配td样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以说出如何动态更改td标签上的样式.
我在XSLT文件中有一个代码,该代码应获取样式并分配给td标签.

我在XSLT中有下面的代码,在这里我需要在代码中为$ QuestionIndex + 1值的td提供样式.问题是如何动态生成td样式.

 <   xsl:何时   测试    ="  ../../@ IsQID ='True'" <   tr  > 
                    <   td     ="   top" 宽度  > 1%"     noWrap   =" 是" > 
                        <   xsl:if    测试  ="  <   xsl:if    测试  ="  <  > 
                        <   xsl:if    测试  ="  <   xsl:value-of    选择  ="  $ QuestionIndex + 1"   / > . ->  
                        <  /xsl:if  > 
                      <  /xsl:if  > 
                    <  /td  > 
                    <   td     ="  左" 宽度  > 99%"      ="  tdNumCls" <   xsl:value-of    选择    ="  > 
                    <  /td  > 
                  <  /tr  > 
                  <   tr  > 
                    <   td     ="   top" 宽度  > 1%"     noWrap   =" 是" > 
                    <  /td  > 
                    <   td     ="  左" 宽度  > 99%"      ="  tdNumCls" <   xsl:if    测试  ="  <   xsl:value-of    选择  ="     disable-output-escapeing   =" 是" > 
                      <  /xsl:if  > 
                    <  /td  > 
                  <  /tr  > 
                <  /xsl:何时 >  





没事我需要像Font-size:11 pt;这样的样式;字体粗细:粗体;字体风格:Arial.在下面的代码行中,@ QuestionIndexFont实际上是XMLDocument Attribute.在我用Font-size:11 pt分配字体样式的地方;字体粗细:粗体;字体:Arial

我尝试了如下所示的字体样式.但是,无法将字体分配给QuestionIndex值

 <  字体   样式  ="  > 
                                <   xsl:value-of    选择  ="  $ QuestionIndex + 1"   / > . ->  
                            <  /font  >  


但是,相同的代码可用于

 <  字体   样式  ="  <   xsl:value-of    选择  ="  $ QuestionIndex + 1"   / > . ->  
                            <  /font  >  


QuestionIndexFont更改.我应该如何分配字体样式?

解决方案

QuestionIndex + 1值在代码中.问题是如何动态生成td样式.

 <   xsl:何时   测试    ="  ../../@ IsQID ='True'" <   tr  > 
                    <   td     ="   top" 宽度  > 1%"     noWrap   =" 是" > 
                        <   xsl:if    测试  ="  <   xsl:if    测试  ="  <  > 
                        <   xsl:if    测试  ="  <   xsl:value-of    选择  ="  / > .<!-  加1以包括当前问题 ->  
                        <  /xsl:if  > 
                      <  /xsl:if  > 
                    <  /td  > 
                    <   td     ="  左" 宽度  > 99%"      ="  tdNumCls" <   xsl:value-of    选择    ="  > 
                    <  /td  > 
                  <  /tr  > 
                  <   tr  > 
                    <   td     ="   top" 宽度  > 1%"     noWrap   =" 是" > 
                    <  /td  > 
                    <   td     ="  左" 宽度  > 99%"      ="  tdNumCls" <   xsl:if    测试  ="  <   xsl:value-of    选择  ="     disable-output-escapeing   =" 是" > 
                      <  /xsl:if  > 
                    <  /td  > 
                  <  /tr  > 
                <  /xsl:何时 >  





没事我需要像Font-size:11 pt;这样的样式;字体粗细:粗体;字体风格:Arial.在下面的代码行中,@ QuestionIndexFont实际上是XMLDocument Attribute.在我用Font-size:11 pt分配字体样式的地方;字体粗细:粗体;字体:Arial

我尝试了如下所示的字体样式.但是,无法将字体分配给QuestionIndex值

 <  字体   样式  ="  > 
                                <   xsl:value-of    选择  ="  / > .<!-  加1以包括当前问题 ->  
                            <  /font  >  


但是,相同的代码可用于

 <  字体   样式  ="  <   xsl:value-of    选择  =" <xsl:when test ="../../@IsQID='True'">
                  <tr>
                    <td valign="top" width="1%" noWrap="yes" >
                        <xsl:if test="@QuestionType!='INS' and @QuestionType!='MAT'">
                        <xsl:if test="../../@IsQUnderline='True'">__</xsl:if>
                        <xsl:if test="../../@IsQNumber='True'">
                            <xsl:value-of select="$QuestionIndex+1" />.<!--plus 1 to include current questions-->
                        </xsl:if>
                      </xsl:if>
                    </td>
                    <td align="left" width="99%" class="tdNumCls">
                      <xsl:value-of select ="ID"/>
                    </td>
                  </tr>
                  <tr>
                    <td valign="top" width="1%" noWrap="yes" >
                    </td>
                    <td align="left" width="99%" class="tdNumCls">
                      <xsl:if test="../../@IsQStem='True'">
                        <xsl:value-of select="Stem/text()" disable-output-escaping="yes"/>
                      </xsl:if>
                    </td>
                  </tr>
                </xsl:when>





Nooo. I need style like Font-size:11 pt; Font-weight:Bold; Font-style:Arial. In below line of code @QuestionIndexFont actually is XMLDocument Attribute. Where I''m assigning Font style with Font-size:11 pt; Font-weight:Bold; Font-style:Arial

I tried with Font style like this shown below. But, not able to assign font to the questionIndex value

<font style="{@QuestionIndexFont}">
                                <xsl:value-of select="$QuestionIndex+1" />.<!--plus 1 to include current questions-->
                            </font>


But, same code works with

<font style="Font-size:11pt; Font-weight:bold">
                                <xsl:value-of select="$QuestionIndex+1" />.<!--plus 1 to include current questions-->
                            </font>


QuestionIndexFont changes. How should i assign font style ?

解决方案

QuestionIndex+1 value in the code. Problem is how to dynamically generate td style.

<xsl:when test ="../../@IsQID='True'">
                  <tr>
                    <td valign="top" width="1%" noWrap="yes" >
                        <xsl:if test="@QuestionType!='INS' and @QuestionType!='MAT'">
                        <xsl:if test="../../@IsQUnderline='True'">__</xsl:if>
                        <xsl:if test="../../@IsQNumber='True'">
                            <xsl:value-of select="


QuestionIndex+1" />.<!--plus 1 to include current questions--> </xsl:if> </xsl:if> </td> <td align="left" width="99%" class="tdNumCls"> <xsl:value-of select ="ID"/> </td> </tr> <tr> <td valign="top" width="1%" noWrap="yes" > </td> <td align="left" width="99%" class="tdNumCls"> <xsl:if test="../../@IsQStem='True'"> <xsl:value-of select="Stem/text()" disable-output-escaping="yes"/> </xsl:if> </td> </tr> </xsl:when>





Nooo. I need style like Font-size:11 pt; Font-weight:Bold; Font-style:Arial. In below line of code @QuestionIndexFont actually is XMLDocument Attribute. Where I''m assigning Font style with Font-size:11 pt; Font-weight:Bold; Font-style:Arial

I tried with Font style like this shown below. But, not able to assign font to the questionIndex value

<font style="{@QuestionIndexFont}">
                                <xsl:value-of select="


QuestionIndex+1" />.<!--plus 1 to include current questions--> </font>


But, same code works with

<font style="Font-size:11pt; Font-weight:bold">
                                <xsl:value-of select="


这篇关于使用xslt动态分配td样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆