我试图在xsl1.0中使用日期和时间,我尝试遵循以下解决方案:Can an XSLT insert the current date?
但是我收到一个错误:Error loading stylesheet: An unknown error has occurred (805303f4)它没有告诉我错误在哪里,所以我有点卡住了。
在我的xml文件中,下面是我对名称空间的声明:
<?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文件:
<?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文件:
<?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>发布于 2018-02-05 11:19:43
您的错误特别指出:
“加载样式表错误”。
因此,您的样式表正在导入许多其他样式表。
您需要做的是验证它们的存在并验证路径。其中至少有一个是失败的。
https://stackoverflow.com/questions/48540203
复制相似问题