首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >加载样式表时出错

加载样式表时出错
EN

Stack Overflow用户
提问于 2018-01-31 10:44:21
回答 1查看 648关注 0票数 1

我试图在xsl1.0中使用日期和时间,我尝试遵循以下解决方案:Can an XSLT insert the current date?

但是我收到一个错误:Error loading stylesheet: An unknown error has occurred (805303f4)它没有告诉我错误在哪里,所以我有点卡住了。

在我的xml文件中,下面是我对名称空间的声明:

代码语言:javascript
复制
    <?xml version="1.0" encoding="UTF-8"?>
<!-- xsl stylesheet declaration with xsl namespace:
Namespace tells the xlst processor about which element is to be processed and
which is used for output purpose only
-->
   <xsl:stylesheet version="1.0"
        xmlns:date="http://exslt.org/dates-and-times"
        extension-element-prefixes="date"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:import href="date.xsl" />

我就是这样想得到时间和日期的:

<xsl:message terminate="no"> here: <xsl:value-of select="date:date-time()"/> </xsl:message>

我在github上下载了日期和时间包。

我不知道我做错了什么。我没有更改从Github下载的文件中的任何内容。

这里是整个xml文件:

代码语言:javascript
复制
 <?xml version="1.0" encoding="UTF-8"?>
<!-- xsl stylesheet declaration with xsl namespace:
Namespace tells the xlst processor about which element is to be processed and
which is used for output purpose only
-->
<xsl:stylesheet version="1.0"
        xmlns:date="http://exslt.org/dates-and-times"
        extension-element-prefixes="date"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:import href="date.xsl" />
  <!-- xsl template declaration:
       template tells the xlst processor about the section of xml document which is to be
       formatted. It takes an XPath expression.
       In our case, it is matching document root element and will tell processor to
       process the entire document with this template.
  -->
  <xsl:template match="/">
    <!-- HTML tags
     Used for formatting purpose. Processor will skip them and browser will simply
     render them.
    -->
    <html>
      <body>
    <h2>Students</h2>
    <table border="1">
      <tr bgcolor="#9acd32">
        <th>Roll No</th>
        <th>First Name</th>
        <th>Last Name</th>
        <th>Nick Name</th>
        <th>Marks</th>
      </tr>
      <!-- for-each processing instruction
           Looks for each element matching the XPAth expression
      -->
      <xsl:message terminate="no"> hello </xsl:message>
      <xsl:for-each select="class/student">
        <xsl:sort select="@rollno"/>
        <xsl:if test="marks >= 85">
          <xsl:message terminate="no"> her: <xsl:value-of select="date:date-time()"/> </xsl:message>
        <tr>
          <td>
        <!-- value-of processing instruction
             process the value of the element matching the XPath expression
        -->
        <xsl:value-of select="@rollno"/>
          </td>
          <td><xsl:value-of select="firstname"/></td>
          <td><xsl:value-of select="lastname"/></td>
          <td><xsl:value-of select="nickname"/></td>
          <td><xsl:value-of select="marks"/></td>
        </tr>
        </xsl:if>
      </xsl:for-each>
    </table>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>

下面是date.xsl文件:

代码语言:javascript
复制
    <?xml version="1.0" encoding="utf-8"?>
<stylesheet xmlns="http://www.w3.org/1999/XSL/Transform" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:date="http://exslt.org/Dates and Times" version="1.0" extension-element-prefixes="date" date:doc="http://www.exslt.org/date">
   <import href="functions/date-time/date.date-time.xsl"/>
   <import href="functions/date/date.date.xsl"/>
   <import href="functions/time/date.time.xsl"/>
   <import href="functions/year/date.year.xsl"/>
   <import href="functions/leap-year/date.leap-year.xsl"/>
   <import href="functions/month-in-year/date.month-in-year.xsl"/>
   <import href="functions/month-name/date.month-name.xsl"/>
   <import href="functions/month-abbreviation/date.month-abbreviation.xsl"/>
   <import href="functions/week-in-year/date.week-in-year.xsl"/>
   <import href="functions/day-in-year/date.day-in-year.xsl"/>
   <import href="functions/day-in-month/date.day-in-month.xsl"/>
   <import href="functions/day-of-week-in-month/date.day-of-week-in-month.xsl"/>
   <import href="functions/day-in-week/date.day-in-week.xsl"/>
   <import href="functions/day-name/date.day-name.xsl"/>
   <import href="functions/day-abbreviation/date.day-abbreviation.xsl"/>
   <import href="functions/hour-in-day/date.hour-in-day.xsl"/>
   <import href="functions/minute-in-hour/date.minute-in-hour.xsl"/>
   <import href="functions/second-in-minute/date.second-in-minute.xsl"/>
   <import href="functions/format-date/date.format-date.xsl"/>
   <import href="functions/parse-date/date.parse-date.xsl"/>
   <import href="functions/week-in-month/date.week-in-month.xsl"/>
   <import href="functions/difference/date.difference.xsl"/>
   <import href="functions/add/date.add.xsl"/>
   <import href="functions/add-duration/date.add-duration.xsl"/>
   <import href="functions/sum/date.sum.xsl"/>
   <import href="functions/seconds/date.seconds.xsl"/>
   <import href="functions/duration/date.duration.xsl"/>
</stylesheet>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-02-05 11:19:43

您的错误特别指出:

“加载样式表错误”。

因此,您的样式表正在导入许多其他样式表。

您需要做的是验证它们的存在并验证路径。其中至少有一个是失败的。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48540203

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档