将xslt连接到外部CSS

拉玛威

我有我使用xslt样式设置的xml文件。我有一个外部css文件来样式化xslt中的表格..如何将这个外部css文件连接到我的xslt?

这是我的InternetTv.xml代码

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="InternetTvXSL.xsl" ?>

<InternetTelevision xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="InternetTvXSD.xsd">
<subscription subscriber_IP="1.2.3"  Server_IP="10.144.50.55">
    <info>
        <name>
            <first>lama</first>
            <last>tatwany</last>
        </name>
        <id>1234567890</id>
        <dob>1999-12-01</dob>
        <phone>1111111</phone>
    </info>
    <channel name="aaa" id="1" favorite="true">
        <program broadcast_frequency="Daily" broadcast_time="11:50:00" >
            <name>vvv</name>
            <id>aaa</id>
            <description>eeeeee</description>
        </program>
    </channel>
    <channel name="aaa" id="1" favorite="false">
        <program broadcast_frequency="Daily" broadcast_time="11:50:00" >
            <name>vvv</name>
            <id>aaa</id>
            <description>eeeeee</description>
        </program>
        <program broadcast_frequency="Daily" broadcast_time="11:50:00" >
            <name>vvv</name>
            <id>aaa</id>
            <description>eeeeee</description>
        </program>
    </channel>
</subscription>
</InternetTelevision>

和我的InternetTvXSLT.xsl文件

 <?xml version="1.0" encoding="ISO-8859-1"?>
 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

 <xsl:template match="/">
 <html>
 <head>
 <style>

 body {
font-family: Georgia;
 }
 h1 {
color: orange;
 } 
 h2 {
color: gray;
 }
 h5 {
background: #D5ECFD;
 } 
 </style>
 </head>
<body>

<h1>Subscriber Profile</h1>
<h4>This profile provides all the information you need to know about <xsl:value-of select="InternetTelevision/subscription/info/name/last"/>&#160;<xsl:value-of select="InternetTelevision/subscription/info/name/first"/></h4>
<h2>General Information</h2>
<h5>Server IP: <xsl:value-of select="InternetTelevision/subscription/@Server_IP"/> &#160; User IP: <xsl:value-of select="InternetTelevision/subscription/@subscriber_IP"/></h5> 
<h5>Name: <xsl:value-of select="InternetTelevision/subscription/info/name/last"/>&#160;<xsl:value-of select="InternetTelevision/subscription/info/name/first"/> &#160; ID: <xsl:value-of select="InternetTelevision/subscription/info/id"/> &#160; Date of Birth: <xsl:value-of select="InternetTelevision/subscription/info/dob"/> &#160; Phone: <xsl:value-of select="InternetTelevision/subscription/info/phone"/></h5>
<h2>Channels Subscriptions:</h2>
<xsl:for-each select="InternetTelevision/subscription/channel">
<xsl:choose>
     <xsl:when test="@favorite = 'true'">
<h3>Channel Name: <font color="green"><xsl:value-of select="@name"/></font></h3>
    </xsl:when>
     <xsl:otherwise>
        <h3>Channel Name: <xsl:value-of select="@name"/></h3>
     </xsl:otherwise>
   </xsl:choose>
<h4>Channel ID: <xsl:value-of select="@id"/></h4>

<h3>Programs:</h3>
    <xsl:for-each select="program">
 <table>
  <tr>
    <th>Program Name:</th>
    <td><xsl:value-of select="name"/></td>
  </tr>
  <tr>
    <th>Broadcast Time:</th>
    <td><xsl:value-of select="@broadcast_frequency"/> at <xsl:value-of select="@broadcast_time"/></td>
  </tr>
  <tr>
    <th>Description:</th>
    <td><xsl:value-of select="description"/></td>
  </tr>
 </table>
</xsl:for-each>
</xsl:for-each>
</body>
</html>

 </xsl:template>
 </xsl:stylesheet>

这是table_style.css

  #gradient-style{
  font-family:"Lucida Sans Unicode", "Lucida Grande", Sans-Serif;
  font-size:13px;
  width:90%;
  text-align:left;
  border-collapse:collapse;
  margin:10px;}

  #gradient-style th{
  font-size:18px;
  font-weight:normal;
  background:#b9c9fe url("http://media.smashingmagazine.com/images/express-css-table-                  design/table-images/gradhead.png") repeat-x;
  border-top:2px solid #d3ddff;
  border-bottom:1px solid #fff;
  color:#039;
  padding:2px;}

  #gradient-style td{
  border-bottom:1px solid #fff;
  color:#669;
  border-top:1px solid #fff;
  background:#e8edff url("http://media.smashingmagazine.com/images/express-css-table-design/table-images/gradback.png") repeat-x;
  padding:2px;}

  #gradient-style tfoot tr td{
  background:#e8edff;
  font-size:12px;
  color:#99c;}

  #gradient-style tbody tr:hover td{
  background:#d0dafd url("http://media.smashingmagazine.com/images/express-css-table-design/table-images/gradhover.png") repeat-x;
  color:#339;}

我在哪里连接它?在xml或xslt中?我尝试了不同的代码,但没有用:(

有人可以帮忙吗?

托尼·格雷厄姆

使用中的link元素head,就像您手工编写HTML一样:

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

如果您需要将其插入HTML输出中(并且您正在使用XSLT 2.0):

<style>
  <xsl:value-of select="unparsed-text('table_style.css')"
                disable-output-escaping="yes"/>
</style>

参见http://www.w3.org/TR/xslt20/#unparsed-text

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

将Heroku App连接到外部数据库

将Macbook Pro连接到外部显示器

将 MongoDB shell 连接到外部数据库

Prometheus Docker - 连接到外部机器

VueJS连接到外部数据

从Docker容器连接到外部主机

将电子秤(测量体重)连接到外部设备(PC或iPhone)

将单独的WordPress Docker-Compose堆栈连接到外部MySQL和phpMyAdmin容器

如何将“匿名”网络名称空间中的veth设备连接到外部设备?

如何将Meteor服务器连接到外部Websocket / Socket IO API?

如何从控制台动态将LightTable连接到外部浏览器?

将APIMAN连接到外部ElasticSearch数据库以获取指标

如何使用Python将Google App Engine连接到外部Mysql数据库

将Spring Authorization服务器连接到外部IDP并触发身份验证

将 Cloud Run 实例连接到外部 RabbitMQ 实例 (CloudAMQP)

将运行OpenVPN服务器的我的家庭服务器连接到外部VPN

Docker:连接到外部数据库

如何从MVC应用程序连接到外部URL

同事无法连接到外部FTP服务器

MySQL无法连接到外部服务器

将我的 docker 连接到外部 docker

使用Go代码从Kubernetes连接到外部Kubernetes集群

apt升级后PHP无法连接到外部Mysql

docker容器中的jupyterhub无法连接到外部目录

思维Sphinx连接到外部Sphinx守护程序

无法连接到外部IP上的Kubernetes集群

docker-compose无法连接到外部网络

如何在Meteor中连接到外部MongoDB实例?

使用/作为本地IP连接到外部主机