Hello Again,
        Okay, more information (I apologize for the length of this
e-mail):

Xalan version 2.6.0 (the xml-apis and xercesImpl that came with that
binary distribution).

I tried running my code with the newer version of Xalan and apparently a
class I was using has been renamed and/or removed. I haven't dug any
deeper on that... I will cross that bridge when I get to it.

The error I get is:
SystemID: file:///test.xsl; Line#: 81; Column#: 54
javax.xml.transform.TransformerException: java.lang.NullPointerException
at java.lang.Throwable.<init>(Throwable.java:195)

at java.lang.Exception.<init>(Exception.java:41)

at javax.xml.transform.TransformerException.<init>(Unknown Source)

at
org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(Trans
formerImpl.java:2341)    
at
org.apache.xalan.templates.ElemElement.constructNode(ElemElement.java:33
8)                       
at org.apache.xalan.templates.ElemElement.execute(ElemElement.java:287)

at
org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(Trans
formerImpl.java:2336)    
at
org.apache.xalan.templates.ElemElement.constructNode(ElemElement.java:33
8)                       
at org.apache.xalan.templates.ElemElement.execute(ElemElement.java:287)

at
org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(Trans
formerImpl.java:2336)    
at org.apache.xalan.templates.ElemIf.execute(ElemIf.java:161)

at
org.apache.xalan.templates.ElemForEach.transformSelectedNodes(ElemForEac
h.java:420)              
at org.apache.xalan.templates.ElemForEach.execute(ElemForEach.java:259)

at
org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes(Ele
mApplyTemplates.java:395)
at
org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates
.java:177)               
at
org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(Trans
formerImpl.java:2336)    
at
org.apache.xalan.templates.ElemElement.constructNode(ElemElement.java:33
8)                   
at org.apache.xalan.templates.ElemElement.execute(ElemElement.java:287)

at
org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(Trans
formerImpl.java:2336)
at
org.apache.xalan.templates.ElemElement.constructNode(ElemElement.java:33
8)                   
at org.apache.xalan.templates.ElemElement.execute(ElemElement.java:287)

at
org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(Trans
formerImpl.java:2336)
at
org.apache.xalan.transformer.TransformerImpl.applyTemplateToNode(Transfo
rmerImpl.java:2202)  
at
org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerIm
pl.java:1276)        
at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.j
ava:673)             
at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.j
ava:1192)            
at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.j
ava:1170)            

That line is <xsl:for-each select="../row[col[3] = $thisUser]"> which is
why I need to turn streaming off. This error does not happen when I
remove enough records from the file to drop the record count to just
under 3100 records (3098). When the record count is higher (3183) I get
this error. It doesn't matter which records I removed... it isn't an
issue with the data. The error also doesn't happen when I turn streaming
back on, but the output is of course incorrect.

I found a bug report from 2003 that describes similar behavior, but no
resolution: http://issues.apache.org/bugzilla/show_bug.cgi?id=20843

The structure of the table is like this

Mode  Office  User  Flag1  Flag2  Flag3  Flag4  Flag5  CValue   CType   
Foo    62     Bob    Y      Y      N      N      N       0        0
Foo    62     Bob    Y      Y      N      N      N       1        2
Foo    62     Bob    Y      Y      N      N      N       2        2
Foo    62     Bob    Y      Y      N      N      N       12       4
Foo    62     Bob    Y      Y      N      N      N       42       4
Foo    62     Jan    Y      N      Y      N      N       1        2
Foo    62     Jan    Y      N      Y      N      N       2        2
Foo    62     Jan    Y      N      Y      N      N       3        2
Foo    62     Jan    Y      N      Y      N      N       72       5


You'll notice the redundant Flag data for each user in this table. That
flag data is only output once per user in my output XML. However, the
changing CValue's and Ctypes are output within a child node of the User
node... so I have to loop through those until the User changes, and then
I pop back out and make a new User Node. Here's an example User node to
give you a picture:

<UserInfo mode="Foo">
  <UserLst Office="62" Company="bleh">
   <User UserName="Bob">
     <FlagLst>
      <Flag Type="Foo"/>
      <Flag Type="Bar"/>
     </FlagLst>
     <CodeLst>
       <Code value="1" type="2"/>
       <Code value="2" type="2"/>
       <Code value="12" type="4"/>
       <Code value="42" type="4"/>
     </CodeLst>
   </User>
  </UserLst>
</UserInfo>

Here is what my stylesheet looks like:
<?xml version="1.0"?>

<xsl:stylesheet xmlns:xalan="http://xml.apache.org/xslt";
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0"
xmlns:sql="org.apache.xalan.lib.sql.XConnection"
extension-element-prefixes="sql">

<xsl:output method="xml" indent="yes" xalan:indent-amount="2"/>
<xsl:param name="bank"/>
<xsl:param name="mode"/>
<!-- parameter setting to connect to DB400 using JTOpen-->
<xsl:param name="query"/>
<xsl:param name="p1type" select="string"/>

<xsl:template match="/">
        <xsl:variable name="db" select="sql:new()"/>
        <!-- Connect to the database with minimal error detection -->
        <xsl:if test="not(sql:connect($db, 'extpool'))" >
                <xsl:message>Error Connecting to the
Database</xsl:message>
                <xsl:copy-of select="sql:getError($db)/ext-error" />
        </xsl:if>
        <xsl:value-of select="sql:disableStreamingMode($db)" />
        <xsl:element name="UserInfo" namespace="">
                <xsl:attribute name="Mode"><xsl:value-of
select="$mode"/></xsl:attribute>
                <xsl:element name="UserLst" namespace="">
                        <xsl:attribute name="Office"><xsl:value-of
select="$bank"/></xsl:attribute>
                        <xsl:attribute
name="Company">FOO</xsl:attribute>
                                                
                        <xsl:value-of
select="sql:addParameterWithType($db,$mode,$p1type)"/>                  
                        <xsl:variable name="table"
select='sql:pquery($db, $query)'/>

                        <xsl:if test="not($table)" >
                                <xsl:message>Error in
Query</xsl:message>
                                <xsl:copy-of
select="sql:getError($db)/ext-error"/>
                        </xsl:if>
                        <xsl:apply-templates
select="$table/sql/row-set"/>
                </xsl:element>
        </xsl:element>
<xsl:value-of select="sql:close($db)"/>
</xsl:template>

<xsl:template match="row-set">
        <xsl:for-each select="row">

        <xsl:variable name="thisUser">
                <xsl:value-of select="col[3]"/>
        </xsl:variable>
        
        <!-- Handle the first record -->
        <xsl:if test="count(preceding-sibling::row)=0">
                        
                <xsl:element name="User" namespace="">
                        <xsl:attribute name="UserName"><xsl:value-of
select="normalize-space($thisUser)"/></xsl:attribute>
                        
                        <xsl:element name="FlagLst" namespace="">
                                <xsl:if test="col[4] = 'Y'">
                                        <xsl:element name="Flag"
namespace="">
                                                <xsl:attribute
name="Type">Foo</xsl:attribute>
                                        </xsl:element>
                                </xsl:if>
                                <xsl:if test="col[5] = 'Y'">
                                        <xsl:element name="Flag"
namespace="">
                                                <xsl:attribute
name="Type">Bar</xsl:attribute>
                                        </xsl:element>
                                </xsl:if>
                                <xsl:if test="col[6] = 'Y'">
                                        <xsl:element name="Flag"
namespace="">
                                                <xsl:attribute
name="Type">Baz</xsl:attribute>
                                        </xsl:element>
                                </xsl:if>
                                <xsl:if test="col[7] = 'Y'">
                                        <xsl:element name="Flag"
namespace="">
                                                <xsl:attribute
name="Type">Ufo</xsl:attribute>
                                        </xsl:element>
                                </xsl:if>
                                <xsl:if test="col[8] = 'Y'">
                                        <xsl:element name="Flag"
namespace="">
                                                <xsl:attribute
name="Type">Bob</xsl:attribute>
                                        </xsl:element>
                                </xsl:if>
                        </xsl:element>
                        
                        <xsl:element name="CodeLst" namespace="">
                        <xsl:for-each select="../row[col[3] =
$thisUser]">
                                <xsl:if test="not(col[9] = 0)">
                                <xsl:element name="Code" namespace="">
                                        <xsl:attribute
name="Value"><xsl:value-of select="col[9]"/></xsl:attribute>
                                        <xsl:attribute
name="Type"><xsl:value-of select="col[10]"/></xsl:attribute>
                                </xsl:element>
                                </xsl:if>
                        </xsl:for-each>
                        </xsl:element>
                        
                </xsl:element>
                
        </xsl:if>
        
        <!-- Handle all following records with a different user name -->
        <xsl:if test="preceding-sibling::row[1]/col[3] != $thisUser">
                                        
                <xsl:element name="User" namespace="">
                        <xsl:attribute name="UserName"><xsl:value-of
select="normalize-space($thisUser)"/></xsl:attribute>
                                                
                        <xsl:element name="FlagLst" namespace="">
                                <xsl:if test="col[4] = 'Y'">
                                        <xsl:element name="Flag"
namespace="">
                                                <xsl:attribute
name="Type">Foo</xsl:attribute>
                                        </xsl:element>
                                </xsl:if>
                                <xsl:if test="col[5] = 'Y'">
                                        <xsl:element name="Flag"
namespace="">
                                                <xsl:attribute
name="Type">Bar</xsl:attribute>
                                        </xsl:element>
                                </xsl:if>
                                <xsl:if test="col[6] = 'Y'">
                                        <xsl:element name="Flag"
namespace="">
                                                <xsl:attribute
name="Type">Baz</xsl:attribute>
                                        </xsl:element>
                                </xsl:if>
                                <xsl:if test="col[7] = 'Y'">
                                        <xsl:element name="Flag"
namespace="">
                                                <xsl:attribute
name="Type">Ufo</xsl:attribute>
                                        </xsl:element>
                                </xsl:if>
                                <xsl:if test="col[8] = 'Y'">
                                        <xsl:element name="Flag"
namespace="">
                                                <xsl:attribute
name="Type">Bob</xsl:attribute>
                                        </xsl:element>
                                </xsl:if>
                        </xsl:element>

                        <xsl:element name="CodeLst" namespace="">
                        <xsl:for-each select="../row[col[3] =
$thisUser]">
                                <xsl:if test="not(col[9] = 0)">
                                <xsl:element name="Code" namespace="">
                                        <xsl:attribute
name="Value"><xsl:value-of select="col[9]"/></xsl:attribute>
                                        <xsl:attribute
name="Type"><xsl:value-of select="col[10]"/></xsl:attribute>
                                </xsl:element>
                                </xsl:if>
                        </xsl:for-each>
                        </xsl:element>
                        
                </xsl:element>
                
        </xsl:if>
        
        </xsl:for-each>
</xsl:template>

</xsl:stylesheet>

Anyone have any idea what is going on here? Thanks!

-Dan

-----Original Message-----
From: Dan Feather [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, February 22, 2006 5:09 PM
To: [email protected]
Subject: Sql Extension - Possible limitation in number of records?

Hello,
        I am using the SQL-Extension and I running into a problem that I
think is related to the number of records in a result set and I am not
using streaming mode. I need to make recursive stylesheet calls and
access previous rows, so I cannot use streaming mode.

        My table has 10 columns, and 3,183 rows in this case. When I run
my stylesheet over this table I immediately get a NullPointerException.
However, if I delete around 80 rows and run it, everything works fine. I
can delete a different 80 rows (to eliminate it being a problem in the
data contained in one of the rows) and it works fine. It seems to happen
right around 3100 rows. I haven't gone and deleted one row at a time yet
to determine the exact number of rows in this case.

        Anyway, my question is has anyone experienced similar behavior?
Are there any known changes or work arounds for this problem? Is this a
known issue? If you would like more information I would be happy to
provide it, but I figured I would just see if this rang any bells with
anyone before we dove to far into the code. I appreciate your help.

-Dan

Reply via email to