簡體   English   中英

如何在XSL文件中包含CSS文件

[英]How to include a CSS file in an XSL file

我希望通過CSS向XSL文檔添加樣式。 但是,我以前的嘗試沒有成功。

這是XSL文件中的相關部分:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
                version="1.0">
<xsl:include href="http://bootswatch.com/sandstone/bootstrap.min.css"/>
<html>
    <head>
        <title>News | Endeavour Explorers</title>
        <link rel="shortcut icon" 
              href="../resources/img/logo200.png"/>
        <style type="text/css">
            body {padding: 63px 0 63px 0;} 
            a[name] {
               padding-top: 40px; 
               margin-top: -40px; 
               display: inline-block; 
               /* required for webkit browsers */}
            @media print{body {margin-top: -63px;}}
        </style>
    </head>

這是指向整個XSL文件的鏈接。

這是.xml文件

您的XSL文件必須至少具有一個與輸入XML匹配的<xsl:template>元素,才能執行某項操作。

您不應該在XSL文件中包括CSS文件-XSL處理器不知道如何處理CSS,而應該在引用CSS的結果XML中輸出<link>元素。

像這樣:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
            version="1.0">

<xsl:template match="/">
    <html>
        <head>
            <title>News | Endeavour Explorers</title>
            <link rel="shortcut icon" 
                 href="../resources/img/logo200.png"/>
            <link rel="stylesheet"   
                 href="http://bootswatch.com/sandstone/bootstrap.min.css"  type="text/css">
            <style type="text/css">
                body {padding: 63px 0 63px 0;} 
                a[name] {
                   padding-top: 40px; 
                   margin-top: -40px; 
                   display: inline-block; 
                   /* required for webkit browsers */}
                @media print{body {margin-top: -63px;}}
            </style>
       </head>
       . . . .

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM