libxslt:编译错误

时间:2015-02-08 04:26:28

标签: ios libxslt

我在iOS上使用libxslt,并且我从简单的xslt中得到编译错误,例如:

compilation error: file /Users/yada/Library/Developer/CoreSimulator/Devices/ACE15E20-3230-4966-ACDE-DCADABF48B32/data/Containers/Bundle/Application/A4EC9B34-3A96-42E0-B58F-6EB44C942874/appname.app/upconversion-options.xsl line 19 element function
xsltStylePreCompute: unknown xsl:function
compilation error: file /Users/yada/Library/Developer/CoreSimulator/Devices/ACE15E20-3230-4966-ACDE-DCADABF48B32/data/Containers/Bundle/Application/A4EC9B34-3A96-42E0-B58F-6EB44C942874/appname.app/upconversion-options.xsl line 20 element param
element param only allowed within a template, variable or param

......还有更多这样的事情,当我这样做时:

xmlSubstituteEntitiesDefault(1);
xmlLoadExtDtdDefaultValue = 1;

NSString * pMathMLTocMathMLXSLPath = [[NSBundle mainBundle] pathForResource:@"upconversion-options" ofType:@"xsl"];
xsltStylesheetPtr pMathMLTocMathMLXSLStyleSheet = xsltParseStylesheetFile((const xmlChar *)[pMathMLTocMathMLXSLPath cStringUsingEncoding:NSUTF8StringEncoding]);

xsl文件如下所示:

<xsl:stylesheet version="2.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns:s="http://www.ph.ed.ac.uk/snuggletex"
  xmlns="http://www.w3.org/1998/Math/MathML"
  exclude-result-prefixes="xs s"
  xpath-default-namespace="http://www.w3.org/1998/Math/MathML">

  <xsl:function name="s:get-boolean-option" as="xs:boolean">
    <xsl:param name="upconversion-options" as="element(s:upconversion-options)"/>
    <xsl:param name="name" as="xs:string"/>
    <xsl:sequence select="boolean($upconversion-options/s:option[@name=$name]/@value='true')"/>
  </xsl:function>

  <xsl:function name="s:get-upconversion-option" as="xs:string?">
    <xsl:param name="upconversion-options" as="element(s:upconversion-options)"/>
    <xsl:param name="name" as="xs:string"/>
    <xsl:sequence select="$upconversion-options/s:option[@name=$name]/@value"/>
  </xsl:function>

  <xsl:function name="s:get-symbol-assumption" as="element(s:symbol)?">
    <xsl:param name="element" as="element()"/>
    <xsl:param name="upconversion-options" as="element(s:upconversion-options)"/>
    <xsl:sequence select="$upconversion-options/s:symbol[deep-equal(*, $element)]"/>
  </xsl:function>

  <xsl:function name="s:is-assumed-symbol" as="xs:boolean">
    <xsl:param name="element" as="element()"/>
    <xsl:param name="upconversion-options" as="element(s:upconversion-options)"/>
    <xsl:param name="assume" as="xs:string"/>
    <xsl:sequence select="exists($upconversion-options/s:symbol[@assume=$assume and deep-equal($element, *)])"/>
  </xsl:function>

  <xsl:function name="s:is-assumed-function" as="xs:boolean">
    <xsl:param name="element" as="element()"/>
    <xsl:param name="upconversion-options" as="element(s:upconversion-options)"/>
    <xsl:sequence select="s:is-assumed-symbol($element, $upconversion-options, 'function')"/>
  </xsl:function>

</xsl:stylesheet>

有什么建议吗?

1 个答案:

答案 0 :(得分:2)

libxslt不支持XSLT 2.0。您将需要使用尚未测试的Saxon/C,或者还原为XSLT 1.0。如果您恢复到1.0并需要额外的功能,请查看EXSLT。