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

时间:2013-06-23 20:36:04

标签: xslt node-set

Icecast包含基于libxsltxmlsoft的XSLT实现。

我想知道它是否支持node-set()功能,最好是以适用于其他仅限网络环境的方式:

  

令人遗憾的是,icecast中的XSLT处理器只能通过网络访问   icecast进程的界面(命令行上没有xsltproc)。   使其恶化:XSLT错误的记录有限(当你这样做时)   如果出现问题,冰球过程常常会死亡。

我正在运行icecast 2.3.2,因为它是latest Windows based build(有no 2.3.3 build for Windows yet),其中有libxslt.dll,日期是2008年。在DLL中没有版本号,最好我可以提供这个(参见底部的XSLT代码):

Version:    1.0
Vendor:     libxslt
Vendor URL: http://xmlsoft.org/XSLT/

我尝试运行“David Carlisle's blog”指向的The EXSLT node-set function文章How to use node-set function in a platform-independent way?中提到的节点集检测。

从输出中,我认为失败了:

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.....

通过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>
我试过

节点集脚本:

<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>

1 个答案:

答案 0 :(得分:4)

简短回答

  icecast中的

libxslt支持xt:node-set()功能   它下面由xsltFunctionNodeSet()实现   功能

通用答案

我使用CSTUG bibliography XSLT基于function system-property创建了一个解决方案。

如果这确实是正确的方法,请发表评论。

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()

使用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>