I found my problem.

Sent from my iPad

On Mar 23, 2014, at 4:32 PM, Loren Cahlander <loren.cahlander@gmail.com> wrote:


Hello folks.  I found what appears to be a bug in the at expression in a flwor statement. (current codebase)  I have the following in a function module:

declare function xs2svg:recurse($node as node()?, $model as map()) as item()* {
    if ($node)
    then
        let $children := $node/node()
        let $count := map:entry('count', count($children))
        let $parent-y := map:entry('parent-y', $model('y-position'))
        let $parent-x := map:entry('parent-x', $model('x-position'))
        let $x-position := map:entry('x-position', xs:integer($model('x-position')) + xs:integer($model('width')) + 45)
        let $id := $model('id')
        return
            for $cnode at $position in $children
                let $new-id := xs:string($id) || '_' || xs:string($position)
                let $new-map := map:new((
                                    map:entry('id', $new-id ),
                                    map:entry('y-position', xs:integer($model('y-position')) + (($position - 1) * (46 + 25))),
                                    $x-position,
                                    $parent-x,
                                    $parent-y,
                                    $count,
                                    map:entry('position', $position)
                                    ))
                order by $position
                return xs2svg:process-node($cnode, $new-map)
    else ()
};

I get the following values 10, 12, 14, 15, ... instead of 1, 2, 3, 4, ...

When I run the following in eXide, it does give the proper values:

xquery version "3.0";

    let $doc := doc('http://www.docbook.org/xml/5.0/xsd/docbook.xsd')//xs:schema
    let $children := $doc/node()
    let $results := for $cnode at $position in $children
                    return <result name='{$cnode/@name}' position='{$position}'></result>
                    
return <results>{$results}</results>


I am attaching the XAR.  Run the code in modules/runsvg.xq


I am in the process of translating the code for http://xsdvi.sourceforge.net/ipo.svg from java to an XQuery function module.

<xsd-lib-0.1.xar>