Topic
7 replies Latest Post - ‏2011-10-04T13:26:01Z by HermannSW
HermannSW
HermannSW
4379 Posts
ACCEPTED ANSWER

Pinned topic EXSLT support in DataPower/Firefox/Xalan/xsltproc

‏2011-09-26T07:35:01Z |
In recent posting
http://www.ibm.com/developerworks/forums/thread.jspa?messageID=14686400#14686400

it was refrerred to posting "Supported EXSLT functions with corresponding XSLT/XPath 2.0 Functions" from 2008:
http://www.ibm.com/developerworks/forums/thread.jspa?messageID=14093259

The list of EXSLT functions described there is very limited.
We have much more supported EXSLT functions since then for eg. firmware 3.7.3.x and 3.8.1.x.
And we got a bunch of newly added EXSLT functionality with 3.8.2 firmware (eg. 100% coverage for Math module).
I had prepared something, but not posted til now.

Find attached an archive containing several files:
  • exslt.xsl for generating a single page 3 column HTML table of interlinked EXSLT support information
  • exslt.xml the list of all EXSLT functions defined on exslt.org, by module, with function/element indicator and core yes/no
  • 381.html the supported EXSLT page for DataPower firmware up to 3.8.1.x
  • 382.html the supported EXSLT page for 3.8.2.x and higher DataPower firmware
  • Firefox.html EXSLT support for Firefox -- the only browser supporting a significant amount for EXSLT functionality
  • xsltproc.html EXSLT support for xsltproc XSLT 1.0 processor
  • Xalan.html EXSLT support for Xalan XSLT 1.0 processor

All the pages are linked together -- if you extract the files into a single directory and open one HTML file you can switch to the others by clicking on the appropriate link at the top.

Additionally you can see the XSLT processor's output for
  • xsl:vendor
  • xsl:version
  • xsl:vendor-url

Stylesheet exslt.xsl is fine, but the output for 3.8.2 Funtions module shows two false negatives.
func:function and func:result ARE supported in DataPower firmware ...

This is the top level 3.8.2 Infocenter page on EXSLT support:
http://publib.boulder.ibm.com/infocenter/wsdatap/v3r8m2/index.jsp?topic=%2Fxi50%2Fexsltextensionfunctionschapter.htm&resultof=%22EXSLT%22%20%22exslt%22

 
Hermann<myXsltBlog/>
Updated on 2011-10-04T13:26:01Z at 2011-10-04T13:26:01Z by HermannSW
  • HermannSW
    HermannSW
    4379 Posts
    ACCEPTED ANSWER

    Re: EXSLT support in DataPower/Firefox/Xalan/xsltproc

    ‏2011-09-26T07:39:17Z  in response to HermannSW
    For easier access find 382.html file attached here showing DataPower EXSLT support for DataPower firmware release 3.8.2.x or newer.
    func:function and func:result ARE supported in DataPower firmware although stated as "false" in "Supported" column.

     
    Hermann.

    Attachments

    • HermannSW
      HermannSW
      4379 Posts
      ACCEPTED ANSWER

      Re: EXSLT support in DataPower/Firefox/Xalan/xsltproc

      ‏2011-09-26T07:47:52Z  in response to HermannSW
      If you only make use of below EXSLT functionality in your stylesheet
      • Common module core
      • Math module core
      • Sets module core,
      • Regular Expressions module,
      • Strings module (str:tokenize, str:concat and str:split)

      then you can develop/test it in Firefox(!).

      See file "Firefox.html" from attached archive and how it does the processing of stylesheet exslt.xsl on input exslt.xml IN your Firefox browser:
      
      <html> <head> <script>   
      // 
      //  "Transforming XML to XHTML in the Browser" 
      //  http://www.w3schools.com/xsl/xsl_client.asp 
      // function loadXMLDoc(dname) 
      { xhttp=
      
      new XMLHttpRequest(); xhttp.open(
      "GET",dname,
      
      false); xhttp.send(
      ""); 
      
      return xhttp.responseXML; 
      }   function displayResult() 
      { 
      // get XML document  xml=loadXMLDoc(
      'exslt.xml');   
      // get stylesheet  xsl=loadXMLDoc(
      'exslt.xsl');   
      // apply stylesheet xsltproc = 
      
      new XSLTProcessor(); xsltproc.importStylesheet(xsl); result = xsltproc.transformToFragment(xml, document);   
      // display result document.getElementById(
      "example").appendChild(result); 
      }   </script> </head> <body onload=
      "displayResult()"> <div id=
      "example"/> </body> </html>
      


       
      Hermann<myXsltBlog/>
      • HermannSW
        HermannSW
        4379 Posts
        ACCEPTED ANSWER

        Re: EXSLT support in DataPower/Firefox/Xalan/xsltproc

        ‏2011-09-26T08:39:09Z  in response to HermannSW
        Stylesheet exslt.xsl generated HTML output by its statement:
        
        <xsl:output method=
        "html"/>
        


        What if your stylesheet outputs XML?
        dp:serialize extension is not available for Firefox.

        You may go with my serialize.xsl solution posted here:
        http://www.biglist.com/lists/lists.mulberrytech.com/xsl-list/archives/201008/msg00186.html

        It is full functionality, but in the thread's discussion it turned out that I was 10 years late ;-)

        So how can you use that for Firefox?
        This is the necessary glue-stylesheet serialize-html.xsl:
        
        <xsl:stylesheet version=
        "1.0" xmlns:xsl=
        "http://www.w3.org/1999/XSL/Transform" xmlns:str=
        "http://exslt.org/strings" > <xsl:include href=
        "serialize.xsl" />   <xsl:output method=
        "html" />   <xsl:template match=
        "/"> <pre> <xsl:call-template name=
        "doOutput"/> </pre> </xsl:template>   </xsl:stylesheet>
        


        This stylesheet includes serialize.xsl (you can find in links section of above posting and attached archive),
        and then generates "<pre>" HTML serialized output.

        This is the serialize output of exslt.xml generated by HTML page further below:
        
        <exslt> <module name=
        "Common" prefix=
        "exsl"> <element core=
        "no">document</element> <function core=
        "yes">node-set</function> <function core=
        "yes">object-type</function> </module> <module name=
        "Math" prefix=
        "math"> <function core=
        "yes">min</function> <function core=
        "yes">max</function> ... ... </module> <module name=
        "Random" prefix=
        "random"> <function core=
        "yes">random-sequence</function> </module> </exslt>
        


        Firefox XSLT processor has only one major deficiency:
        It does not support the namespace-axis!

        So this identity stylesheet
        
        <xsl:stylesheet version=
        "1.0" xmlns:xsl=
        "http://www.w3.org/1999/XSL/Transform" > <xsl:template match=
        "/"> <xsl:copy-of select=
        "."/> </xsl:template>   </xsl:stylesheet>
        


        applied to itself results in this output with missing declaration of xsl prefix:
        
        <xsl:stylesheet version=
        "1.0"> <xsl:template match=
        "/"> <xsl:copy-of select=
        "."/> </xsl:template>   </xsl:stylesheet>
        


        If you can live with that while developing your stylesheet you can still develop+test with just Firefox ... but please do not forget to test on DataPower box finally!

         
        This is the HTML page doing the serialization of output in addition:
        
        <html> <head> <script>   
        // 
        //  "Transforming XML to XHTML in the Browser" 
        //  http://www.w3schools.com/xsl/xsl_client.asp 
        // function loadXMLDoc(dname) 
        { xhttp=
        
        new XMLHttpRequest(); xhttp.open(
        "GET",dname,
        
        false); xhttp.send(
        ""); 
        
        return xhttp.responseXML; 
        }   function displayResult() 
        { 
        // get XML document  xml=loadXMLDoc(
        'exslt.xml');   
        // get stylesheet  xsl=loadXMLDoc(
        'identity.xsl');   
        // apply stylesheet xsltproc = 
        
        new XSLTProcessor(); xsltproc.importStylesheet(xsl); result = xsltproc.transformToDocument(xml);     
        // get stylesheet  xsl2=loadXMLDoc(
        'serialize-html.xsl');   
        // apply stylesheet xsltproc2 = 
        
        new XSLTProcessor(); xsltproc2.importStylesheet(xsl2); result2 = xsltproc2.transformToFragment(result, document);   
        // display result document.getElementById(
        "example").appendChild(result2); 
        }   </script> </head> <body onload=
        "displayResult()"> <div id=
        "example"/> </body> </html>
        


         
        Hermann<myXsltBlog/>
      • Liv2luv
        Liv2luv
        573 Posts
        ACCEPTED ANSWER

        Re: EXSLT support in DataPower/Firefox/Xalan/xsltproc

        ‏2011-09-26T16:16:52Z  in response to HermannSW
        Thank you Hermann. That is indeed a very useful compilation. The number of supported extension functions is significant for 3.8.2.

        So to help test the stylesheets remotely following are the available ways :

        1. XSLT Coproc
        2. webDataPower
        3. DataPower eclipse plugin
        4. firefox (NOT dp functions)
        5. xmlspy plug-in (never worked for me)

        Are there any other ways?

        Thanks.
        • HermannSW
          HermannSW
          4379 Posts
          ACCEPTED ANSWER

          Re: EXSLT support in DataPower/Firefox/Xalan/xsltproc

          ‏2011-09-26T17:44:16Z  in response to Liv2luv
          > ...
          > Are there any other ways?
          >
          1. XSLT Coproc
          a. (deprecated since 3.8.0) Coproc service in firmware
          b. coproc2
          c. coproc2.java
          d. coproc2swa
          ...
          6. xpath++ tool (for simple XPath expressions, including translate(...) or regexp:replace(...)

           
          Hermann<myXsltBlog/>
          • Jaango
            Jaango
            266 Posts
            ACCEPTED ANSWER

            Re: EXSLT support in DataPower/Firefox/Xalan/xsltproc

            ‏2011-10-04T08:30:10Z  in response to HermannSW
            Hi Hermann,

            This sounds great. We have a need to perform some math operations(Multiply variable 'a' with ten to the power of negative of variable 'b', ie a*10e(-b).) I would like to use the above for testing this in 3.8.2 firmware.

            When I opened firefox.html, nothing came up. Do I have to manually import the xsl and xml file? The version firefox is 2.0.0.20.
            • HermannSW
              HermannSW
              4379 Posts
              ACCEPTED ANSWER

              Re: EXSLT support in DataPower/Firefox/Xalan/xsltproc

              ‏2011-10-04T13:26:01Z  in response to Jaango
              Hi,
              >
              > This sounds great. We have a need to perform some math operations(Multiply variable 'a' with ten to the power of negative of variable 'b', ie a*10e(-b).) I would like to use the above for testing this in 3.8.2 firmware.
              >
              > When I opened firefox.html, nothing came up. Do I have to manually import the xsl and xml file? The version firefox is 2.0.0.20.

              Please extract the attached archive "exslt-files.zip" into a directory.
              Then open "Firefox.html" in that directory with Firefox browser, this should give the view your are interested in.
              (At minimum you need files "exslt.xsl" and "exslt.xml" extracted into same
              directory where you extracted "Firefox.html" -- Firefox.html loads both files).

              But you will have no fun with math:power() as it is not supported by Firefox ...
              (this is extracted from Firefox.html -- looks much nicer and colorful there):
              Math http://exslt.org/math math
              Name Element or function Supported
              core functions
              math:min() function true
              math:max() function true
              math:highest() function true
              math:lowest() function true
              other functions
              math:abs() function false
              math:sqrt() function false
              math:power() function false
              math:constant() function false
              math:log() function false
              math:random() function false
              math:sin() function false
              math:cos() function false
              math:tan() function false
              math:asin() function false
              math:acos() function false
              math:atan() function false
              math:atan2() function false
              math:exp() function false

               
              Hermann<myXsltBlog/>