Achhh, didn't realise my replies weren't going to the list.
---------- Forwarded message ---------- From: Ihe Onwuka <[email protected]> Date: Fri, Jul 13, 2012 at 5:10 PM Subject: Re: [xquery-talk] Simple (I thought) Xquery giving run-time error. To: Josh Spiegel <[email protected]> Thats what I did before. Thats what I thought I did again and to be doubly sure I cut and pasted from your post. I get <switch xmlns="http://www.w3.org/2002/xforms"> <case id="sales stocks plants clientsCase"> *************************the id attribute is wrong ******************************* <b2b:Sales xmlns:b2b="http://www.b2b.net/plants"> <xf:bind repeat="saleBindings.xml"/> </b2b:Sales> <b2b:Stocks xmlns:b2b="http://www.b2b.net/plants"> <xf:bind repeat="stockBindings.xml"/> </b2b:Stocks> <b2b:Plants xmlns:b2b="http://www.b2b.net/plants"> <xf:bind repeat="plantBindings.xml"/> </b2b:Plants> <b2b:Clients xmlns:b2b="http://www.b2b.net/plants"> <xf:bind repeat="clientBindings.xml"/> </b2b:Clients> </case> </switch> I should add though I am running this in eXide maybe Saxon would give me a different result. On Fri, Jul 13, 2012 at 5:04 PM, Josh Spiegel <[email protected]> wrote: > If you change your original query exactly as I suggested, you should get a > result that looks something like: > <switch xmlns="http://www.w3.org/2002/xforms"><case > id="salesCase"><b2b:Sales xmlns:b2b="http://www.b2b.net/plants" > xmlns=""><xf:bind repeat="saleBindings.xml" …. > > Josh > > > > On Jul 13, 2012, at 8:59 AM, Ihe Onwuka wrote: > >> Both you and Michael are saying the same thing. >> >> I've tried this before posting. I get <case id="sales stocks plants >> clientsCase" ........ which is not right, so you can see why I went >> down a level, which has not worked either. >> >> I have also tried . instead of text(). >> >> On Fri, Jul 13, 2012 at 4:20 PM, Josh Spiegel <[email protected]> >> wrote: >>> It seems like you might have too many '/*' steps. For example, if you >>> evaluate $models/* in the body, I think you should get the empty sequence. >>> $models appears to bind to the sequence of <Model> elements so $models/* >>> would select element children of each but there aren't any. >>> >>> I would try changing your line to the following: >>> >>> {$models/<case >>> id='{text()}Case'>{local:bindModel(local:defineModelRoot(.),"",xs:QName('group'))}</case>} >>> >>> Josh >>> >>> On Jul 13, 2012, at 7:41 AM, Ihe Onwuka wrote: >>> >>>> 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> >>>> </ModelNames> >>>> >>>> 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()* >>>> :=doc(concat($configDir,"/modelNames.xml"))/*/*; >>>> >>>> declare function local:bindModel($x,$y,$z) {$x}; >>>> >>>> declare function local:capitalise($str) >>>> { >>>> concat(upper-case(substring($str,1,1)),substring($str,2)) >>>> }; >>>> >>>> declare function local:defineModelRoot($model as element()) >>>> { >>>> element {concat('b2b:',local:capitalise($model/text()))} >>>> {element xf:bind {attribute repeat >>>> {local:getBindingFileName($model)}}} >>>> }; >>>> >>>> declare function local:getBindingFileName($model as element()) as xs:string >>>> { >>>> concat($model/@singular,'Bindings.xml') >>>> }; >>>> <switch xmlns="http://www.w3.org/2002/xforms"> >>>> {$models/*/<case >>>> id='{text()}Case'>{local:bindModel(local:defineModelRoot(.),"",xs:QName('group'))}</case>} >>>> </switch> >>>> >>>> The idea of the line that says >>>> >>>> {$models/*/<case >>>> id='{text()}Case'>{local:bindModel(local:defineModelRoot(.),"",xs:QName('group'))}</case>} >>>> >>>> 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. >>>> >>>> thanks. >>>> _______________________________________________ >>>> [email protected] >>>> http://x-query.com/mailman/listinfo/talk >>> > _______________________________________________ [email protected] http://x-query.com/mailman/listinfo/talk
