Hi,
I try to find a way to build a xpath-expression which will be created within a repeat-loop dynamically during page creation. But this seems not working for some reason. The goal is to get a dynamic data structure displayed in a table. An example of my xhtml-file is at the end of the mail. Now I get a table like this (the second column ref is for testing only) (not OK): item: 1 label: Label A Label B Label C Label D ref: A value: 10 label: Label A Label B Label C Label D ref: B value: value B label: Label A Label B Label C Label D ref: C value: C item: 2 label: Label A Label B Label C Label D ref: A value: 10 label: Label A Label B Label C Label D ref: C value: C label: Label A Label B Label C Label D ref: D value: value D But I want a table like this (OK): item: 1 label: Label A value: 10 label: Label B value: value B label: Label C value: C item: 2 label: Label A value: 10 label: Label C value: C label: Label D value: value D I'm not sure how to write the xpath expression to get the desired label from my labels-instance which matches the value-item in the table. The construct for the label-column is not working as expected. Why? Where can I get more information on how to get this running? How can I build the xpath from the fixed part 'instance('labels')/item' and the changing part from the valueTag? What I get is either _all_ labels at once or just the tag-name, but not the text of my label-tag. Thanks for ideas Cheers Heinrich ----8< ---- 8< ------ <?xml version="1.0" encoding="UTF-8"?> <xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"> <xhtml:head> <xf:model id="table-model"> <xf:instance id="content"> <document> <items> <item> <A>10</A> <B>value B</B> <C>C</C> </item> <item> <A>10</A> <C>C</C> <D>value D</D> </item> </items> </document> </xf:instance> <xf:instance id="labels"> <items> <A>Label A</A> <B>Label B</B> <C>Label C</C> <D>Label D</D> </items> </xf:instance> </xf:model> </xhtml:head> <xhtml:body> <xf:group ref="instance('content')"> <xf:repeat nodeset="items/item" id="repeat-item"> <!-- outer table; contains all items --> <xhtml:table> <!-- first row, contains the header --> <xhtml:tr> <xhtml:td> <xf:output value="position()"> <xf:label>item: </xf:label> </xf:output> </xhtml:td> </xhtml:tr> <!-- second row, contains the items --> <xhtml:tr> <xhtml:td> <!-- inner table; one table per item --> <xhtml:table width="600px" style="border: solid black 1px;"> <xf:repeat nodeset="./*[node()]" id="table-item"> <xxforms:variable model="table-model" name="valueTag" select="name(.)" /> <xxforms:variable model="table-model" name="labelTag" select="instance('labels')/item" /> <xhtml:tr> <xhtml:td> <xf:group ref="instance('labels')"> <xxforms:variable model="table-model" name="label" select="instance('labels')/items/$valueTag" /> <xf:output select="$label/$valueTag"> <xf:label>label: </xf:label> </xf:output> <xf:output ref="$valueTag"> <xf:label>ref: </xf:label> </xf:output> </xf:group> </xhtml:td> <xhtml:td> <xf:output select="$valueTag"> <xf:label>value: </xf:label> </xf:output> </xhtml:td> </xhtml:tr> </xf:repeat> </xhtml:table> </xhtml:td> </xhtml:tr> </xhtml:table> </xf:repeat> </xf:group> </xhtml:body> </xhtml:html> ----8< ---- 8< ------ -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws |
Hi Heinrich,
I made two examples for you - one is dynamic as you wished and another is with fixed elements, which is IMHO simpler and easier to maintain. Both seem to give the correct answer. Regards, Tambet On 5.11.2010 0:05, Heinrich Götzger wrote: > Hi, > > I try to find a way to build a xpath-expression which will be created > within a repeat-loop dynamically during page creation. But this seems > not working for some reason. > > The goal is to get a dynamic data structure displayed in a table. > > An example of my xhtml-file is at the end of the mail. > > Now I get a table like this (the second column ref is for testing > only) (not OK): > > item: 1 > label: Label A Label B Label C Label D ref: A value: 10 > label: Label A Label B Label C Label D ref: B value: value B > label: Label A Label B Label C Label D ref: C value: C > item: 2 > label: Label A Label B Label C Label D ref: A value: 10 > label: Label A Label B Label C Label D ref: C value: C > label: Label A Label B Label C Label D ref: D value: value D > > > But I want a table like this > (OK): > > item: 1 > label: Label A value: 10 > label: Label B value: value B > label: Label C value: C > item: 2 > label: Label A value: 10 > label: Label C value: C > label: Label D value: value D > > > I'm not sure how to write the xpath expression to get the desired > label from my labels-instance which matches the value-item in the table. > > The construct for the label-column is not working as expected. > Why? > > Where can I get more information on how to get this running? > > How can I build the xpath from the fixed part > 'instance('labels')/item' and the changing part from the valueTag? > > What I get is either _all_ labels at once or just the tag-name, but > not the text of my label-tag. > > Thanks for ideas > > Cheers > > Heinrich > -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws |
Hi Tambet,
thanks for your answer. Worked as expected! The dynamic is because we don't know what's in the items, this changes from call to call. (And that's why we use <xf:repeat nodeset="./*[node()]" id="table-item"> in the inner loop. This omits the empty tags. That wasn't clear in the example.) But: Where can I find documentation on how to build such XPath. Or some introduction to have more chances to get things like this running at my own Thanks Cheers Heinrich On 11/05/10 07:08, Tambet Matiisen wrote: > Hi Heinrich, > > I made two examples for you - one is dynamic as you wished and another > is with fixed elements, which is IMHO simpler and easier to maintain. > Both seem to give the correct answer. > > Regards, > Tambet > > On 5.11.2010 0:05, Heinrich Götzger wrote: >> Hi, >> >> I try to find a way to build a xpath-expression which will be created >> within a repeat-loop dynamically during page creation. But this seems >> not working for some reason. >> >> The goal is to get a dynamic data structure displayed in a table. >> >> An example of my xhtml-file is at the end of the mail. >> >> Now I get a table like this (the second column ref is for testing >> only) (not OK): >> >> item: 1 >> label: Label A Label B Label C Label D ref: A value: 10 >> label: Label A Label B Label C Label D ref: B value: value B >> label: Label A Label B Label C Label D ref: C value: C >> item: 2 >> label: Label A Label B Label C Label D ref: A value: 10 >> label: Label A Label B Label C Label D ref: C value: C >> label: Label A Label B Label C Label D ref: D value: value D >> >> >> But I want a table like this >> (OK): >> >> item: 1 >> label: Label A value: 10 >> label: Label B value: value B >> label: Label C value: C >> item: 2 >> label: Label A value: 10 >> label: Label C value: C >> label: Label D value: value D >> >> >> I'm not sure how to write the xpath expression to get the desired >> label from my labels-instance which matches the value-item in the table. >> >> The construct for the label-column is not working as expected. >> Why? >> >> Where can I get more information on how to get this running? >> >> How can I build the xpath from the fixed part >> 'instance('labels')/item' and the changing part from the valueTag? >> >> What I get is either _all_ labels at once or just the tag-name, but >> not the text of my label-tag. >> >> Thanks for ideas >> >> Cheers >> >> Heinrich >> > -- Before printing this e-mail, think about our environmental responsibility. -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws |
Administrator
|
Heinrich,
If you're looking for a book, without any hesitation, I would recommend Michael Kay's book about XSLT 2.0 and XPath 2.0: http://www.amazon.com/XSLT-XPath-Programmers-Reference-Programmer/dp/0470192747 Mike worked on those specifications, and implemented the excellent XPath 2.0 engine used by Orbeon Forms. Alex On Fri, Nov 5, 2010 at 4:01 PM, Heinrich Götzger <[hidden email]> wrote: > Hi Tambet, > > thanks for your answer. Worked as expected! > > The dynamic is because we don't know what's in the items, this changes from > call to call. > > (And that's why we use > <xf:repeat nodeset="./*[node()]" id="table-item"> > in the inner loop. This omits the empty tags. That wasn't clear in the > example.) > > But: > Where can I find documentation on how to build such XPath. Or some > introduction to have more chances to get things like this running at my own > > Thanks > > Cheers > > Heinrich > > > On 11/05/10 07:08, Tambet Matiisen wrote: >> >> Hi Heinrich, >> >> I made two examples for you - one is dynamic as you wished and another >> is with fixed elements, which is IMHO simpler and easier to maintain. >> Both seem to give the correct answer. >> >> Regards, >> Tambet >> >> On 5.11.2010 0:05, Heinrich Götzger wrote: >>> >>> Hi, >>> >>> I try to find a way to build a xpath-expression which will be created >>> within a repeat-loop dynamically during page creation. But this seems >>> not working for some reason. >>> >>> The goal is to get a dynamic data structure displayed in a table. >>> >>> An example of my xhtml-file is at the end of the mail. >>> >>> Now I get a table like this (the second column ref is for testing >>> only) (not OK): >>> >>> item: 1 >>> label: Label A Label B Label C Label D ref: A value: 10 >>> label: Label A Label B Label C Label D ref: B value: value B >>> label: Label A Label B Label C Label D ref: C value: C >>> item: 2 >>> label: Label A Label B Label C Label D ref: A value: 10 >>> label: Label A Label B Label C Label D ref: C value: C >>> label: Label A Label B Label C Label D ref: D value: value D >>> >>> >>> But I want a table like this >>> (OK): >>> >>> item: 1 >>> label: Label A value: 10 >>> label: Label B value: value B >>> label: Label C value: C >>> item: 2 >>> label: Label A value: 10 >>> label: Label C value: C >>> label: Label D value: value D >>> >>> >>> I'm not sure how to write the xpath expression to get the desired >>> label from my labels-instance which matches the value-item in the table. >>> >>> The construct for the label-column is not working as expected. >>> Why? >>> >>> Where can I get more information on how to get this running? >>> >>> How can I build the xpath from the fixed part >>> 'instance('labels')/item' and the changing part from the valueTag? >>> >>> What I get is either _all_ labels at once or just the tag-name, but >>> not the text of my label-tag. >>> >>> Thanks for ideas >>> >>> Cheers >>> >>> Heinrich >>> >> > > > -- > Before printing this e-mail, think about our environmental responsibility. > > > -- > You receive this message as a subscriber of the [hidden email] mailing > list. > To unsubscribe: mailto:[hidden email] > For general help: mailto:[hidden email]?subject=help > OW2 mailing lists service home page: http://www.ow2.org/wws > > -- Orbeon Forms - Web forms, open-source, for the Enterprise - http://www.orbeon.com/ My Twitter: http://twitter.com/avernet -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
Free forum by Nabble | Edit this page |