Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xsltproc doesn't recognize XSLT 2.0

I have this XSLT syltesheet:

<?xml version="1.0"?>

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml" indent="yes" />
  <xsl:strip-space elements="*" />

  <!-- Default behavior: copy everything -->
  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()" />
    </xsl:copy>
  </xsl:template>

  <!-- Do not copy: -->
  <xsl:template match="NodeLevel1[matches(NodeLevel2/@Param1, 'myRegex')]">
  </xsl:template>
</xsl:stylesheet>

So, I want to copy everything but certain nodes based on a regex expression. And I want to use the matches function of XSLT 2 to achieve this. But when I run the following command:

xsltproc.exe style.xsl input.xml > output.xml

I got this message looped on the standard output:

xmlXPathCompOpEval: function matches not found
XPath error : Unregistered function
xmlXPathCompiledEval: 1 object left on the stack

How to fix this please ?

Thanks very much.

like image 867
mikedu95 Avatar asked Jul 31 '14 14:07

mikedu95


People also ask

Is XSLT 2.0 backward compatibility?

The XSLT 2.0 engine is backwards compatible. The only time the backwards compatibility of the XSLT 2.0 engine comes into effect is when using the XSLT 2.0 engine to process an XSLT 1.0 stylesheet.

Is XSL the same as XSLT?

XSLT is designed to be used as part of XSL. In addition to XSLT, XSL includes an XML vocabulary for specifying formatting. XSL specifies the styling of an XML document by using XSLT to describe how the document is transformed into another XML document that uses the formatting vocabulary.

Can XSLT transform JSON to XML?

Transform JSON using XSLTOxygen makes it possible to transform JSON documents to XML or HTML through XSLT processing. A few predefined document templates are even available to help you define the XSLT necessary for the processing.


1 Answers

You will need to use an XSLT 2.0 processor like Saxon 9 or the other options listed on https://stackoverflow.com/tags/xslt-2.0/info, xsltproc is an XSLT 1.0 processor.

like image 102
Martin Honnen Avatar answered Oct 09 '22 10:10

Martin Honnen