javascript - 如何在 XSLT 中包含 CSS 文件

标签 javascript html css xml xslt

所以我有一个如下所示的 CSS 文件

.table_class1DeffCell
{
border-top-width : 1;
border-left-width : 1;
border-right-width : 1;
border-bottom-width : 1;
}
.table_class11DeffCell
{
border-bottom-color : 000000;
border-top-color : 000000;
border-right-color : 000000;
border-left-color : 000000;
border-top-style : solid;
border-left-style : solid;
border-right-style : solid;
border-bottom-style : solid;
border-top-width : 1;
border-left-width : 1;
border-right-width : 1;
border-bottom-width : 1;
}
.table_class24DeffCell
{
border-bottom-color : 000000;
border-top-color : 000000;
border-right-color : 000000;
border-left-color : 000000;
border-top-style : solid;
border-left-style : solid;
border-right-style : solid;
border-bottom-style : solid;
border-top-width : 1;
border-left-width : 1;
border-right-width : 1;
border-bottom-width : 1;
}

.text_class40
{
font-style : italic;
}

.text_class41
{
font-weight : bold;
}

.image_class42
{
}

在 HTML 中,它的链接如下所示

<link rel="stylesheet" type="text/css" href="FormatingProblem.css"></link>

由于链接了 CSS 文件,在 HTML 中粗体和斜体可以正常工作。

实际上我正在将 HTML 文件转换为 Word 文档,以防我无法使用这些粗体和斜体。

这是我的 XSLT 文件

 <table width="100%">
            <tr>
              <xsl:if test="@class=$TableClass">
                <!--left Table Cell-->
                <xsl:choose>
                  <!--Requirement-->
                  <xsl:when test="td[@class=$RequirementType]/span/span/. = 'Non Functional' or td[@class=$RequirementType]/span/span/. = 'Functional' or td[@class=$RequirementType]/span/span/. = 'Scenario' or td[@class=$RequirementType]/span/span/. = 'Actor'">
                    <td style="border-Top: black 1.0pt solid; border-Bottom: #4896a black 1.0pt solid; vertical-align:'top'" bgcolor = "#DDD9C3" width="80%">
                      <!--Text-->
                      <xsl:if test="td/@class=$Requirements">
                        <xsl:for-each select="td[@class=$Requirements]/span/span | td[@class=$Requirements]/span/br | td[@class=$Requirements]/span/blockquote">
                          <span>
                            <xsl:if test="name() != 'br'">
                              <xsl:value-of select="." />
                              <xsl:if test="name() = 'blockquote'">
                                <br/>
                              </xsl:if>
                            </xsl:if>
                            <xsl:if test="name() = 'br'">
                              <br/>
                            </xsl:if>

                          </span>
                        </xsl:for-each>
                      </xsl:if>
                      <br />
                      <br />
                      <!--Reference-->
                      <xsl:if test="td/@class=$References">
                        <xsl:if test="string-length(td[@class=$References]/span/span)!=0">
                          <span>
                            <br />
                            <xsl:for-each select="td[@class=$References]/span/span | td[@class=$References]/span/br">
                              <span>
                                <xsl:if test="name() != 'br'">
                                  <xsl:value-of select="." />
                                </xsl:if>
                                <xsl:if test="name() = 'br'">
                                  <br/>
                                </xsl:if>
                              </span>
                            </xsl:for-each>
                          </span>
                        </xsl:if>
                      </xsl:if>
                      <br />
                      <br />
                    </td>
                  </xsl:when>
                </xsl:choose>
                <!--right Table Cell-->
                <xsl:choose>
                  <!--Requirement-->
                  <xsl:when test="td[@class=$RequirementType]/span/span/. = 'Functional' or td[@class=$RequirementType]/span/span/. = 'Non Functional' or td[@class=$RequirementType]/span/span/. = 'Scenario' or td[@class=$RequirementType]/span/span/. = 'Actor'">
                    <xsl:choose>
                      <!--Search 1-->
                      <xsl:when test="td[@class=$Auxiliary]/span[contains(span, $search1)]">
                        <td style="vertical-align:'top'" bgcolor="{$search1Color}" width="20%">
                          <span style="font-size:8pt">
                            <!--UID_ATR-->
                            <xsl:if test="td/@class=$UID">
                              ID:
                              <xsl:value-of select="td[@class=$UID]/." />
                            </xsl:if>
                            <br />
                            <!--TFS_ID-->
                            <xsl:if test="td/@class=$TFS_ID">
                              TFS:
                              <xsl:value-of select="td[@class=$TFS_ID]/." />
                            </xsl:if>
                            <br />
                            <!--TFS_Triage-->
                            <xsl:if test="td/@class=$Triage">
                              <xsl:value-of select="td[@class=$Triage]/." />
                            </xsl:if>
                            <br />
                            <!--V. In-->
                            <xsl:if test="td/@class=$V.In">
                              <xsl:value-of select="td[@class=$V.In]/." />
                            </xsl:if>
                            <br />
                            <!--TFS_Priority-->
                            <xsl:if test="td/@class=$Priority">
                              (Prio
                              <xsl:value-of select="td[@class=$Priority]/." />)
                            </xsl:if>
                            <br />
                            <!--TFS_Requirement Type-->
                            <xsl:if test="td/@class=$RequirementType">
                              <xsl:value-of select="td[@class=$RequirementType]/." />
                            </xsl:if>
                            <br />
                            <br />
                            <!--Auxiliary-->
                            <xsl:if test="td/@class=$Auxiliary">
                              <xsl:value-of select="td[@class=$Auxiliary]/." />
                              <br />
                            </xsl:if>
                            <br />
                          </span>
                        </td>
                      </xsl:when>
                      <!--Search 2-->
                      <xsl:when test="td[@class=$Auxiliary]/span[contains(span, $search2)]">
                        <td style="vertical-align:'top'" bgcolor="{$search2Color}" width="20%">
                          <span style="font-size:8pt">
                            <!--UID_ATR-->
                            <xsl:if test="td/@class=$UID">
                              ID:
                              <xsl:value-of select="td[@class=$UID]/." />
                            </xsl:if>
                            <br />
                            <!--TFS_ID-->
                            <xsl:if test="td/@class=$TFS_ID">
                              TFS:
                              <xsl:value-of select="td[@class=$TFS_ID]/." />
                            </xsl:if>
                            <br />
                            <!--TFS_Triage-->
                            <xsl:if test="td/@class=$Triage">
                              <xsl:value-of select="td[@class=$Triage]/." />
                            </xsl:if>
                            <br />
                            <!--V. In-->
                            <xsl:if test="td/@class=$V.In">
                              <xsl:value-of select="td[@class=$V.In]/." />
                            </xsl:if>
                            <br />
                            <!--TFS_Priority-->
                            <xsl:if test="td/@class=$Priority">
                              (Prio
                              <xsl:value-of select="td[@class=$Priority]/." />)
                            </xsl:if>
                            <br />
                            <!--TFS_Requirement Type-->
                            <xsl:if test="td/@class=$RequirementType">
                              <!--Zeilenumbruch-->
                              <xsl:value-of select="td[@class=$RequirementType]/." />
                            </xsl:if>
                            <br />
                            <br />
                            <!--Auxiliary-->
                            <xsl:if test="td/@class=$Auxiliary">
                              <xsl:value-of select="td[@class=$Auxiliary]/." />
                              <br />
                              <!--Zeilenumbruch-->
                            </xsl:if>
                            <br />
                          </span>
                        </td>
                      </xsl:when>
                      <!--No Search-->
                      <xsl:otherwise>
                        <td style="vertical-align:'top'" width="20%">
                          <span style="font-size:8pt">
                            <!--UID_ATR-->
                            <xsl:if test="td/@class=$UID">
                              ID:
                              <xsl:value-of select="td[@class=$UID]/." />
                            </xsl:if>
                            <br />
                            <!--TFS_ID-->
                            <xsl:if test="td/@class=$TFS_ID">
                              TFS:
                              <xsl:value-of select="td[@class=$TFS_ID]/." />
                            </xsl:if>
                            <br />
                            <!--TFS_Triage-->
                            <xsl:if test="td/@class=$Triage">
                              <xsl:value-of select="td[@class=$Triage]/." />
                            </xsl:if>
                            <br />
                            <!--V. In-->
                            <xsl:if test="td/@class=$V.In">
                              <xsl:value-of select="td[@class=$V.In]/." />
                            </xsl:if>
                            <br />
                            <!--TFS_Priority-->
                            <xsl:if test="td/@class=$Priority">
                              (Prio
                              <xsl:value-of select="td[@class=$Priority]/." />)
                            </xsl:if>
                            <br />
                            <!--TFS_Requirement Type-->
                            <xsl:if test="td/@class=$RequirementType">
                              <xsl:value-of select="td[@class=$RequirementType]/." />
                            </xsl:if>
                            <br />
                            <br />
                            <!--Auxiliary-->
                            <xsl:if test="td/@class=$Auxiliary">
                              <xsl:value-of select="td[@class=$Auxiliary]/." />
                              <br />
                              <!--Zeilenumbruch-->
                            </xsl:if>
                            <br />
                          </span>
                        </td>
                      </xsl:otherwise>
                    </xsl:choose>
                  </xsl:when>
                  <!--No Requirement-->
                  <xsl:otherwise>
                    <span width="20%"></span>
                  </xsl:otherwise>
                </xsl:choose>
              </xsl:if>
            </tr>
          </table>

在 HTML 中,它显示如下图

enter image description here

并且在转换为 Word 格式后,BOLD(Character) 将无法像下图那样工作

enter image description here

我错在哪里?

最佳答案

我看不出问题出在哪里。

<xsl:template match="/">
  <html>
    <head>
      <link rel="stylesheet" type="text/css" href="FormatingProblem.css" />
    </head>
    <body>
      <xsl:apply-templates />
    </body>
  </html>
</xsl:template>

关于javascript - 如何在 XSLT 中包含 CSS 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28697342/

相关文章:

嵌套数组的 Javascript 数组重组

javascript - Angular 三元运算符?具有功能

javascript - 如何存储要传递给 .not() 的元素?

javascript - Bootstrap Popover 在页面调整大小时不移动

javascript - 将 curl 调用转换为 javascript ajax 调用

javascript - jQuery document.ready() 不触发动态加载的内容

javascript - 使用按钮和鼠标滚动 DIV

javascript - jquery mobile 1.4.5 设置面板高度可能吗?

jquery slider 优化...也许是 CSS 技巧?

css - 如何使用 CSS 从主页的网格部分删除类别元?