在icecast服务器的xslt实现中检测node-set()函数的可用性

Jer*_*ers 3 xslt node-set

的Icecast包含基于一个XSLT实现的libxsltxmlsoft

我想知道它是否支持node-set()函数,最好以一种也适用于其他纯网络环境的方式:

遗憾的是,icecast 中的XSLT 处理器只能通过icecast 进程的Web 界面进行Web 访问(因此命令行上没有xsltproc)。更糟糕的是:XSLT 错误的日志记录有限(当你做错事时,icecast 进程通常会死掉)。

我正在运行 icecast 2.3.2,因为它是基于 Windows最新版本(目前还没有用于 Windows 的 2.3.3 版本),其中 libxslt.dll 的日期是 2008 年。DLL 中没有版本号,我是最好的可以提供的是这个(见底部的 XSLT 代码):

Version:    1.0
Vendor:     libxslt
Vendor URL: http://xmlsoft.org/XSLT/
Run Code Online (Sandbox Code Playgroud)

我尝试运行David Carlisle 的博客文章“如何以独立于平台的方式使用节点集功能? ”指向的 EXSLT 节点集功能中提到的节点集检测。

从输出来看,我认为失败了:

icemaster@localhost972990localhost00EarthIcecast 2.3.2Sun, 23 Jun 2013 20:02:19 W. Europe Daylight Time202200ice-samplerate=44100;ice-bitrate=64;ice-channels=264StationGenre6424410000http://localhost:8000.....
Run Code Online (Sandbox Code Playgroud)

通过 Web 界面中的 XSL 文件进行查找的最佳方法是什么?

版本脚本:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
  <xsl:output method="text" encoding="UTF-8" />
  <xsl:template match="/">
Version:    <xsl:value-of select="system-property('xsl:version')" />
Vendor:     <xsl:value-of select="system-property('xsl:vendor')" />
Vendor URL: <xsl:value-of select="system-property('xsl:vendor-url')" />
  </xsl:template>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)

我试过的节点集脚本:

<xsl:stylesheet
  version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:exslt="http://exslt.org/common"
  xmlns:msxsl="urn:schemas-microsoft-com:xslt"
  exclude-result-prefixes="exslt msxsl">

<xsl:output
  omit-xml-declaration="no"
  method="html"
  indent="yes"
  encoding="UTF-8" />

<msxsl:script language="JScript" implements-prefix="exslt">
 this['node-set'] =  function (x) {
  return x;
  }
</msxsl:script>

<xsl:variable name="x">
  <y/>
</xsl:variable>

<xsl:template match="x">
  <html>
    <head><title>test exslt node set</title></head>
    <body>
      <xsl:apply-templates select="exslt:node-set($x)/*"/>
    </body>
  </html>
</xsl:template>

<xsl:template match="y">
  <p>node set!</p>
</xsl:template>

</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)

Jer*_*ers 6

简答

icecast 中的libxslt支持xt:node-set()函数。
在它下面由xsltFunctionNodeSet() 函数实现。

通用答案

我使用函数 system-property基于CSTUG 书目 XSLT创建了一个解决方案。

如果这确实是执行此操作的正确方法,请发表评论。

CSTUG 代码处理这些 node-set() 函数:

  • exslt:节点集()
  • msxml:节点集()
  • xalanc:节点集()

我也添加了对这些的支持:

  • xt:节点集()
  • saxon6:节点集()

icecast 的输出:

Version:    1.0
Vendor:     libxslt
Vendor URL: http://xmlsoft.org/XSLT/
node-set(): xt:node-set()
Run Code Online (Sandbox Code Playgroud)

使用的 XSLT:

<xsl:stylesheet
  version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:exslt="http://exslt.org/common"
  xmlns:msxml="urn:schemas-microsoft-com:xslt"
  xmlns:xalanc="http://xml.apache.org/xalanc"
  xmlns:xt="http://www.jclark.com/xt"
  xmlns:saxon6="http://icl.com/saxon"
  extension-element-prefixes="exslt msxml xalanc xt saxon6"
  exclude-result-prefixes="exslt msxml xalanc xt saxon6"
  >

  <xsl:output method="text" encoding="UTF-8" />
  <xsl:template match="/">
    <xsl:text>
Version:    </xsl:text>
    <xsl:value-of select="system-property('xsl:version')" />
    <xsl:text>
Vendor:     </xsl:text>
    <xsl:value-of select="system-property('xsl:vendor')" />
    <xsl:text>
Vendor URL: </xsl:text>
    <xsl:value-of select="system-property('xsl:vendor-url')" />
<!--
Prefixes used for node-set()
exslt: EXSLT aware processors (Saxon, xsltproc, Xalan-J, jd.xslt, 4XSLT)
msxml: MSXML
xalanc: Xalan-C, Xalan-J 2.6.x
xt: XT, libxslt
saxon6: Saxon 6
-->
    <xsl:text>
node-set(): </xsl:text>
    <xsl:choose>
      <xsl:when test="function-available('exslt:node-set')">
        <xsl:text>exslt:node-set()</xsl:text>
      </xsl:when>
      <xsl:when test="function-available('msxml:node-set')">
        <xsl:text>msxml:node-set()</xsl:text>
      </xsl:when>
      <xsl:when test="function-available('xalanc:nodeset')">
        <xsl:text>xalanc:nodeset()</xsl:text>
      </xsl:when>
      <xsl:when test="function-available('xt:node-set')">
        <xsl:text>xt:node-set()</xsl:text>
      </xsl:when>
      <xsl:when test="function-available('saxon6:node-set')">
        <xsl:text>saxon6:node-set()</xsl:text>
      </xsl:when>
      <xsl:otherwise>
        <xsl:text>EXSLT:node-set not found!</xsl:text>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)