6 Replies Latest reply: Feb 21, 2012 12:27 PM by rp0428 RSS

    oraxsl infinite loop using kutable.xsl and xml with default column value

    rp0428
      oraxsl goes into an infinite loop when transforming table xml files if the table has a column with a default value; tables with no default value columns transform properly. Eventually a java.lang.StackOverflowError is thrown.

      Steps to reproduce (Oracle 11gR2 - Oracle Enterprise Linux)

      1. Create two tables - one with a column having a default value, one with no columns having defaults.

      CREATE TABLE TABLE_WITH_DEFAULT_COLUMN
      (
      COLA CHAR(1 BYTE) DEFAULT 'N',
      COLB CHAR(1 BYTE)
      )

      CREATE TABLE TABLE_WITH_NO_DEFAULT_COLUMN
      (
      COLA CHAR(1 BYTE),
      COLB CHAR(1 BYTE)
      )

      2. Extract the table metadata using the dbms_metadata functionality and save the resulting clobs to files.

      select dbms_metadata.get_xml('TABLE', 'TABLE_WITH_DEFAULT_COLUMN', 'REMEDY') FROM DUAL

      select dbms_metadata.get_xml('TABLE', 'TABLE_WITH_NO_DEFAULT_COLUMN', 'REMEDY') FROM DUAL

      3. Using the stylesheets in the $ORACLE_HOME/RDBMS/XML/XSL folder perform the transform on the table with no default columns

      java -cp .\xmlparserv2.jar;.\orai18n-collation.jar oracle.xml.parser.v2.oraxsl TABLE_WITH_NO_DEFAULT_COLUMN.xml xsl\kutable.xsl

      The result is a valid CREATE TABLE ddl statement.

      4. 3. Using the stylesheets in the $ORACLE_HOME/RDBMS/XML/XSL folder perform the transform on the table that has a column with a default value.

      java -cp .\xmlparserv2.jar;.\orai18n-collation.jar oracle.xml.parser.v2.oraxsl TABLE_WITH_DEFAULT_COLUMN.xml xsl\kutable.xsl

      The result is an infinite loop and a java.lang.StackOverflowError is thrown. Increasing the stack size (-Xss100m) to 100 megabytes only delays the exception.

      The external stylesheets at RDBMS/XML/XSL are identical to those stored in the database (SYS.METASTYLESHEET) except for the import statement references:

      External version of import

      <xsl:import href="kucommon.xsl"/>


      DB version of import
      <xsl:import href="/oradb/SYS/METASTYLESHEET/ROW[NAME='kucommon' and MODEL='ORACLE']/STYLESHEET/text()"/>

      Yet the DBMS_METADATA.GET_DDL function returns the proper result.

      I am using the xdk version_11.1.1.3.0_production version of the xmllparserv2.jar file

      Any idea as to the cause of an infinite loop when the transform is done externally?
        • 1. Re: oraxsl infinite loop using kutable.xsl and xml with default column value
          odie_63
          Hi,

          I can't reproduce right now using the external processor, but will try on monday.

          At least it works with the database XSLT engine :
          SQL> CREATE TABLE TABLE_WITH_DEFAULT_COLUMN
            2  (
            3  COLA CHAR(1 BYTE) DEFAULT 'N',
            4  COLB CHAR(1 BYTE)
            5  );
          
          Table created.
          
          SQL> set lines 120
          SQL> set long 500
          SQL> SELECT XMLTransform(
            2           XMLType(dbms_metadata.get_xml('TABLE', 'TABLE_WITH_DEFAULT_COLUMN', user))
            3         , DBUriType('/SYS/METASTYLESHEET/ROW[NAME="kutable" and MODEL="ORACLE"]/STYLESHEET/text()').getxml()
            4         )
            5  FROM DUAL
            6  ;
          
          XMLTRANSFORM(XMLTYPE(DBMS_METADATA.GET_XML('TABLE','TABLE_WITH_DEFAULT_COLUMN',USER)),DBURITYPE('/SYS/METASTYLESHEET/ROW
          ------------------------------------------------------------------------------------------------------------------------
          CREATE TABLE "DEV"."TABLE_WITH_DEFAULT_COLUMN"
             (    "COLA" CHAR(1) DEFAULT 'N',
                  "COLB" CHAR(1)
             ) SEGMENT CREATION IMMEDIATE
            PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
            STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
            PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
            TABLESPACE "USERS"
          • 2. Re: oraxsl infinite loop using kutable.xsl and xml with default column value
            rp0428
            Thanks for looking at this. You are correct that the internal XSLT engine transforms properly as do the DBMS_METADATA.GET_DDL and GET_SXML methods. The SXML file equivalent also transforms properly with the xmlparserv2.jar.

            Both with/without default column files transform fine using Saxon:

            JAVA -classpath %saxonpath%\saxon9he.jar;. net.sf.saxon.Transform ..\TABLE_WITH_DEFAULT_COLUMN.xml ..\xsl\kutable.xsl

            And I can compile kutable.xsl usng Java's xalan XSLTC class and transform properly with the compile version:

            java com.sun.org.apache.xalan.internal.xsltc.cmdline.Compile -j kutable.jar ..\xsl\kutable.xsl

            Though some stylesheets (kufull.xsl) won't compile due to some top-level parameters not being defined; these stylesheets will transform properly however. So I am currently having to compile some into a jar to get around the infinite loop while using the raw version of others (via a URIResolver class) that can't be compiled.

            I was, of course, hoping for a unified approach that would work in all cases so I could do all of this work offline.

            I appreciate any help that can be provided.
            • 3. Re: oraxsl infinite loop using kutable.xsl and xml with default column value
              rp0428
              Possible cause found!

              The culprit may be the xmlparserv2.jar file that I was using. I was using the jar from the sql developer 3 installation. When I retested with the jar from the Oracle 11gr2 installation there was no problem. Note that the sql developer 3 jar is newer and larger.

              1. xmlparserv2.jar from sqldeveloper-3.0.02.37-no-jre.zip manifests the problem using the original tests provided.

              size - 1,461,309
              located at sqldeveloper/modules/oracle.xsd_11.1.0/


              2. xmlparserv2.jar from Oracle 11gr2 (linux and/or windows) does not manifest the problem.
              • 4. Re: oraxsl infinite loop using kutable.xsl and xml with default column value
                rp0428
                Possible cause found!

                The culprit may be the xmlparserv2.jar file that I was using. I was using the jar from the sql developer 3 installation. When I retested with the jar from the Oracle 11gr2 installation there was no problem. Note that the sql developer 3 jar is newer and larger.

                1. xmlparserv2.jar from sqldeveloper-3.0.02.37-no-jre.zip manifests the problem using the original tests provided.

                size - 1,461,309
                date - 9/29/2010
                located at sqldeveloper/modules/oracle.xsd_11.1.0/


                2. xmlparserv2.jar from Oracle 11gr2 (linux and/or windows) does not manifest the problem.

                size - 1,382,291 (both linux and windows files are identical
                date 8/1/2009
                located at $ORACLE_HOME/xdk/lib (linux and/or windows)

                I'm not sure that there is anything I can do to determine why the newer jar file manifests the problem and don't know which group within Oracle is responsible for this particular jar file.
                • 5. Re: oraxsl infinite loop using kutable.xsl and xml with default column value
                  odie_63
                  Works on 11.2.0.3 as well :
                  C:\oracle\product\11.2.0\dbhome>java -cp xdk\lib\xmlparserv2.jar;jlib\orai18n-collation.jar oracle.xml.parser.v2.oraxsl -v c:\te
                  mp\TABLE_WITH_DEFAULT_COLUMN.xml rdbms\xml\xsl\kutable.xsl
                  Release version: Oracle XML Developers Kit 11.2.0.3.0 - Production
                  1 XML document will be transformed using XSLT stylesheet specified in rdbms\xml\xsl\kutable.xsl with 1 thread
                  Parsing file rdbms\xml\xsl\kutable.xsl
                  Parsing file c:\temp\TABLE_WITH_DEFAULT_COLUMN.xml
                  Transforming XML document specified in c:\temp\TABLE_WITH_DEFAULT_COLUMN.xml
                  
                    CREATE TABLE "DEV"."TABLE_WITH_DEFAULT_COLUMN"
                     (    "COLA" CHAR(1) DEFAULT 'N',
                          "COLB" CHAR(1)
                     ) SEGMENT CREATION DEFERRED
                    PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
                   NOCOMPRESS LOGGING
                    TABLESPACE "USERS"
                  • 6. Re: oraxsl infinite loop using kutable.xsl and xml with default column value
                    rp0428
                    Marking as answered to close it out. The appears to be a bug in one of the five xmlparserv2.jar files distributed with 11g.