本文介绍了exsl:OS X中的日期年份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如该问题中所述,我正在尝试使用Perl和libXSLT转换输入的xml文档.但是,当我尝试在OS X上运行相同的Perl脚本时,在

As mentioned in this question, I am trying to transform my input xml document using Perl and libXSLT. However, when I try to run the same Perl script on OS X with little addition of following in my xsl file under the

 <xsl:variable name="current-year">
            <xsl:value-of select="date:year()"/>
    </xsl:variable>

我收到以下错误消息.

xmlXPathCompOpEval: function year not found
Unregistered function
xmlXPathCompiledEval: evaluation failed
runtime error: file trans.xsl line 24 element value-of
XPath evaluation returned no result.

我的XSLT文件头中有

My XSLT file header has following

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xalan="http://xml.apache.org/xslt"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:exsl="http://exslt.org/common"
    xmlns:date="http://exslt.org/dates-and-times"
    extension-element-prefixes="exsl">
    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" media-type="text/xml"/>

正在跑步Perl -v吸引了我

This is perl, v5.8.8 built for darwin-thread-multi-2levelCopyright 1987-2006, Larry Wall....

This is perl, v5.8.8 built for darwin-thread-multi-2levelCopyright 1987-2006, Larry Wall....

运行uname -a会吸引我关注

Darwin machine-maci 15.3.0 Darwin Kernel Version 15.3.0: Thu Dec 10 18:40:58 PST 2015; root:xnu-3248.30.4~1/RELEASE_X86_64 x86_64

为什么显示此错误?我认为 OS X供应商已经对其libXSLT进行了扩展.还不支持exsl扩展吗?

Why is this error showing up? I thought OS X Vendor has already exsl extensions to their libXSLT. Aren't exsl extensions supported yet?

更新

我对示例进行了一些调整,得到的输出为Vendor:-libxslt,如下面的注释所建议.

I tweaked my example a little bit and I got the output as Vendor :- libxslt as suggested by comments below.

推荐答案

您还必须将日期声明为扩展元素:

You must declare date as extension element too:

extension-element-prefixes="exsl date"

使用libxslt时,可能不需要您声明的xalan命名空间.否则,这可能也必须添加到extension-element-prefixs中.

Your declared xalan namespace probably will not be necessary when using libxslt. Otherwise that would probably have to be added to the extension-element-prefixes also.

这篇关于exsl:OS X中的日期年份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 02:25