2 Replies Latest reply: Jun 29, 2012 10:33 AM by MiroMas RSS

    DBMS_XSLPROCESSOR.SETPARAM problem

    MiroMas
      When I try to pass values of global parameters of stylesheet with DBMS_XSLPROCESSOR.SETPARAM I get "ORA-31020: The operation is not allowed, Reason: Invalid XSL Parameter or its Value". Can someone provide me with working example, please?
      Database version Oracle XE 11g 11.2.0.2.0
        • 1. Re: DBMS_XSLPROCESSOR.SETPARAM problem
          odie_63
          This works for me :
          SQL> set serveroutput on
          SQL> 
          SQL> DECLARE
            2  
            3   p  dbms_xslprocessor.Processor;
            4   s  dbms_xslprocessor.Stylesheet;
            5  
            6   xsldoc  clob := '<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
            7  <xsl:output method="xml"/>
            8  <xsl:param name="test"/>
            9  <xsl:template match="/">
           10  <result><xsl:value-of select="$test"/></result>
           11  </xsl:template>
           12  </xsl:stylesheet>';
           13  
           14   xmlresult varchar2(4000);
           15  
           16  BEGIN
           17  
           18   p := dbms_xslprocessor.newProcessor;
           19   s := dbms_xslprocessor.newStylesheet(dbms_xmldom.newDOMDocument(xsldoc), null);
           20   dbms_xslprocessor.setParam(s, 'test', '"Hello!"');
           21  
           22   dbms_xslprocessor.processXSL(p, s, dbms_xmldom.newDOMDocument('<dummy/>'), xmlresult);
           23  
           24   dbms_xslprocessor.freeStylesheet(s);
           25   dbms_xslprocessor.freeProcessor(p);
           26  
           27   dbms_output.put_line(xmlresult);
           28  
           29  END;
           30  /
           
          <?xml version="1.0" encoding="utf-8"?>
          <result>Hello!</result>
           
          PL/SQL procedure successfully completed
           
          • 2. Re: DBMS_XSLPROCESSOR.SETPARAM problem
            MiroMas
            Thanks. It works for me also. The problem was in my XSLT. I had <xsl:param> element after <xsl:template match="/">.