[xquery-talk] Simple (I thought) Xquery giving run-time error.

Ihe Onwuka ihe.onwuka at googlemail.com
Fri Jul 13 07:41:50 PDT 2012

Given this in modelNames.xml

<?xml version="1.0"?>
<ModelNames xmlns="http://www.b2b.net/plants">
  <Model singular="sale">sales</Model>
  <Model singular="stock">stocks</Model>
  <Model singular="plant">plants</Model>
  <Model singular="client">clients</Model>

I am having problems with the following XQuery

xquery version "1.0";

declare namespace b2b = "http://www.b2b.net/plants";
declare namespace xf="http://www.w3.org/2002/xforms";
declare namespace html="http://www.w3.org/1999/xhtml";
declare namespace ev="http://www.w3.org/2001/xml-events";

declare variable $configDir as xs:string :="config";

declare variable $models as element()*

declare function local:bindModel($x,$y,$z) {$x};

declare function local:capitalise($str)

declare function local:defineModelRoot($model as element())
   element {concat('b2b:',local:capitalise($model/text()))}
            {element xf:bind {attribute repeat

declare function local:getBindingFileName($model as element()) as xs:string
    <switch xmlns="http://www.w3.org/2002/xforms">

The idea of  the line that says


is for the <case> direct constructor to be evaluated for each model
element in $models. The two substitutions I am hoping for is the
text() element in the AVT for the id attribute of the case element and
the . in local:defineModelRoot, which is meant to pass the context
model element as a parameter to local:defineModelRoot.

Is my understanding of what I should expect incorrect. If so I would
appreciate an explanation rather than just a solution.


More information about the talk mailing list