That's a useful clue, but it doesn't explain why Saxon is crashing!
 
Thanks,
 
Michael Kay
 
P.S. I've just noticed that you replied off-list, which means that the thread doesn't get properly archived. This is frustrating to other people if they find something that appears to be the same bug, and it's also frustrating to me as I rely on the archive to track the history, at least until such time as I have enough information to raise a bug entry.
-----Original Message-----
From: Oswald Campesato [mailto:ocampesato@yahoo.com]
Sent: 02 September 2003 10:23
To: Michael Kay
Subject: RE: [saxon] java.lang.NullPointerException in net.sf.saxon.expr.VariableReference.iterate(line 182)

Hello:
 
I think I've found the cause of the problem -- the value
of $index is 'off by one'.  If you make these changes:
 
old line:   $index  := ($row + $col) mod 2,
new line: $index  := (($row + $col) mod 2) + 1,

old line:   let $xCoord := $row*($interCellHGap+$cellWidth),
new line:  let $xCoord := $col*($interCellHGap+$cellWidth),

the SVG document is generated correctly.   The first change

results in a successful match in the XML document (whereas

the second one is just for the correct display location)....

Cordially,

Oswald

btw: thanks for the insight on the 'floor' function.


Michael Kay <mhk@mhk.me.uk> wrote:

Thanks, I've reproduced the bug and will investigate.
 
Michael Kay
-----Original Message-----
From: saxon-help-admin@lists.sourceforge.net [mailto:saxon-help-admin@lists.sourceforge.net] On Behalf Of Oswald Campesato
Sent: 30 August 2003 06:02
To: saxon-help@lists.sourceforge.net
Subject: [saxon] java.lang.NullPointerException in net.sf.saxon.expr.VariableReference.iterate(line 182)

Hello, everyone:
 
I'm using Saxon's XQuery in order to generate an SVG document
with a 'checkerboard' pattern and I got the above-mentioned error
on a Windows XP machine.  Although I'm doing this for fun, this
looks like a potential bug, so here I am (again)....
 
Cordially,
 
Oswald
 
 
The contents of checkerboard1.xq:
--------------------------------------------------
xquery version "1.0"
declare namespace math="java:java.lang.Math"
<svg>
<g>
{
  let $basePointX    := doc("checkerBoard1.xml")/svgData/basePointX
  let $basePointY    := doc("checkerBoard1.xml")/svgData/basePointY
  let $rowCount      := doc("checkerBoard1.xml")/svgData/rowCount
  let $colCount      := doc("checkerBoard1.xml")/svgData/colCount
  let $cellWidth     := doc("checkerBoard1.xml")/svgData/cellWidth
  let $cellHeight    := doc("checkerBoard1.xml")/svgData/cellHeight
  let $interCellHGap := doc("checkerBoard1.xml")/svgData/interCellHGap
  let $interCellVGap := doc("checkerBoard1.xml")/svgData/interCellVGap
 return (
  for $row in 0 to $rowCount
  for $col in 0 to $colCount
    let $xCoord := $row*($interCellHGap+$cellWidth),
        $yCoord := $row*($cellHeight+$interCellVGap),
        $index  := ($row + $col) mod 2,
        $style  := doc("checkerBoard1.xml")/svgData/styles/style[position()=$index]/@type
  return
    <rect x="{$basePointX + $xCoord}"
          y="{$basePointY + $yCoord}"
          width="{$cellWidth}"
          height="{$cellHeight}"
          style="{$style}">
    </rect>
 )
}
</g>
</svg>
The contents of checkerboard1.xml:
----------------------------------------------------
<?xml version="1.0"?>
<svgData>
  <basePointX>40</basePointX>
  <basePointY>40</basePointY>
  <rowCount>8</rowCount>
  <colCount>10</colCount>
  <cellWidth>30</cellWidth>
  <cellHeight>30</cellHeight>
  <interCellHGap>2</interCellHGap>
  <interCellVGap>2</interCellVGap>
  <styles>
    <style type="fill:red;"/>
    <style type="fill:blue;"/>
  </styles>
</svgData>
 
The stack trace:
-----------------------
java.lang.NullPointerException
 at net.sf.saxon.expr.VariableReference.iterate(VariableReference.java:182)
 at net.sf.saxon.expr.CardinalityChecker.evaluateItem(CardinalityChecker.java:110)
 at net.sf.saxon.expr.ArithmeticExpression.evaluateItem(ArithmeticExpression.java:236)
 at net.sf.saxon.expr.CastExpression.evaluateItem(CastExpression.java:119)
 at net.sf.saxon.expr.ComputedExpression.iterate(ComputedExpression.java:317)
 at net.sf.saxon.expr.CardinalityChecker.evaluateItem(CardinalityChecker.java:110)
 at net.sf.saxon.expr.ComputedExpression.evaluateAsString(ComputedExpression.java:295)
 at net.sf.saxon.instruct.SimpleNodeConstructor.expandChildren(SimpleNodeConstructor.java:88)
 at net.sf.saxon.instruct.Attribute.processLeavingTail(Attribute.java:176)
 at net.sf.saxon.instruct.Instruction.process(Instruction.java:151)
 at net.sf.saxon.instruct.Instruction.processChildren(Instruction.java:193)
 at net.sf.saxon.instruct.Element.evaluateItem(Element.java:277)
 at net.sf.saxon.instruct.ExprInstruction.iterate(ExprInstruction.java:128)
 at net.sf.saxon.expr.LetExpression.iterate(LetExpression.java:25)
 at net.sf.saxon.expr.LetExpression.iterate(LetExpression.java:25)
 at net.sf.saxon.expr.LetExpression.iterate(LetExpression.java:25)
 at net.sf.saxon.expr.ForExpression$MappingAction.map(ForExpression.java:141)
 at net.sf.saxon.expr.MappingIterator.advance(MappingIterator.java:67)
 at net.sf.saxon.expr.MappingIterator.hasNext(MappingIterator.java:95)
 at net.sf.saxon.expr.MappingIterator.advance(MappingIterator.java:79)
 at net.sf.saxon.expr.MappingIterator.hasNext(MappingIterator.java:95)
 at net.sf.saxon.instruct.Sequence.processLeavingTail(Sequence.java:133)
 at net.sf.saxon.instruct.Instruction.process(Instruction.java:151)
 at net.sf.saxon.instruct.Instruction.processChildren(Instruction.java:193)
 at net.sf.saxon.instruct.Element.processLeavingTail(Element.java:174)
 at net.sf.saxon.instruct.Instruction.process(Instruction.java:151)
 at net.sf.saxon.instruct.Instruction.processChildren(Instruction.java:193)
 at net.sf.saxon.instruct.Element.evaluateItem(Element.java:277)
 at net.sf.saxon.instruct.ExprInstruction.iterate(ExprInstruction.java:128)
 at net.sf.saxon.query.XQueryExpression.iterator(XQueryExpression.java:144)
 at net.sf.saxon.Query.doMain(Query.java:313)
 at net.sf.saxon.Query.main(Query.java:64)
Fatal error during transformation: null
 
 


Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software


Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software