I am trying to figure out an XPath expression, and not able to... I would would really appreciate a hint...
Here is my problem: 1. I have a document, which at the top level has Person elements and Account elements. Inside each account element (several levels deep) I have an attribute that references a Person: <Person key="p1"> <Name>Name1</Name> </Person> <Person key="p2"/> <Name>Name1</Name> </Person> <Person key="p3"/> <Name>Name1</Name> </Person> <Account> <Policy> <Policy Holder personReference="p1"/> </Policy> </Account> <Account> <Policy> <Policy Holder personReference="p2"/> </Policy> <Policy> <Policy Holder personReference="p3"/> </Policy> </Account> 2. I am trying to dispaly records in a grid format (number of records equal number of policies): /Account/Person and in on of the columns I would like to display Person's name, based on the reference. 3. Here is an XPath that I have but it doesnot work (I am also attaching a sample XForms file that shows my problem): ../../Person[@key=./PolicyHolder/@personReference] (The starnge part for me here is that if I select ../../Person[@key='p1'] it returns the name of the Person with "p1", prooving that my XPath is correct; ./PolicyHolder/@personReference expression is returning "p1", "p2", "p3".. whet it is in the loop, but combining it togethere simse impossible) Thanks! accounts-test.xhtml |
2008/6/9 mangvlad <[hidden email]>:
> Here is my problem: > > 1. I have a document, which at the top level has Person elements and Account > elements. No, in xml terms you have two documents (or more) To use xpath you need all the xml to have a single root. Inside each account element (several levels deep) I have an > attribute that references a Person: > > <Person key="p1"> > <Name>Name1</Name> > </Person> > <Person key="p2"/> > <Name>Name1</Name> > </Person> > > 2. I am trying to dispaly records in a grid format (number of records equal > number of policies): /Account/Person and in on of the columns I would like > to display Person's name, based on the reference. Once you have it all 'wrapped' in a single element ask again. > > 3. Here is an XPath that I have but it doesnot work (I am also attaching a > sample XForms file that shows my problem): > > ../../Person[@key=./PolicyHolder/@personReference] Rather than having a context 'down in the depths', try using a context from higher up, then access the parts you want from there, looking down. The child:: axis is much easier to use (and visualize) HTH -- Dave Pawson XSLT XSL-FO FAQ. http://www.dpawson.co.uk -- 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 |
Thanks for the reply.
>Once you have it all 'wrapped' in a single element ask again. Actually, it is wrapped in one document (I have a sample in attached file), I just "skipped" that detail in my post (sorry). >Rather than having a context 'down in the depths', try >using a context from higher up, then access the parts >you want from there, looking down. The child:: axis is much >easier to use (and visualize) My context is defined by the loop, so there is not much I can do to change it, since I have to have a current row. I have tried all possible combination of this Xpath, even tried using saxon:evaluate, but it still does not work... |
In reply to this post by mangvlad
I'll assume a 'doc' wrapper in no namespace.
2008/6/9 mangvlad <[hidden email]>: > 1. I have a document, which at the top level has Person elements and Account > elements. Inside each account element (several levels deep) I have an > attribute that references a Person: > > <Person key="p1"> > <Name>Name1</Name> > </Person> > <Person key="p2"/> > <Name>Name1</Name> > </Person> > <Person key="p3"/> > <Name>Name1</Name> > </Person> > <Account> > <Policy> > <Policy Holder personReference="p1"/> > </Policy> > </Account> > <Account> > <Policy> > <Policy Holder personReference="p2"/> > </Policy> > <Policy> > <Policy Holder personReference="p3"/> > </Policy> > </Account> > > 2. I am trying to dispaly records in a grid format (number of records equal > number of policies): /Account/Person and in on of the columns I would like > to display Person's name, based on the reference. Can you do that in xforms? <xsl:variable name='person' select="@PersonReference"/> Then <xsl:value-of select="//Person[@key=$person]/Name"/> will get you the value you want. If it's taking too long, replace //Person with a better path. Try it first though. HTH - Dave Pawson XSLT XSL-FO FAQ. http://www.dpawson.co.uk -- 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 |
Thanks for your help!
The "variable" approach worked ok. I am attaching the version of the form that work (if anyone ever needs a reference). Thanks, again! accounts-test.xhtml |
In reply to this post by PE2Dave
Another puzzle... :)
Before using variables, it was very easy for me to sort (by using sort() extension function). Now, since I have a field that is a "lookup" I cannot figure out how to sort it by that field (in a simple/elegant way :) ). (I can send the whole instance to an XPL service that can use XSLT to sort it, but maybe there is anothe way...) Thanks.
|
Administrator
|
On Wed, Jun 11, 2008 at 12:46 PM, mangvlad <[hidden email]> wrote:
> Another puzzle... :) > > Before using variables, it was very easy for me to sort (by using sort() > extension function). > Now, since I have a field that is a "lookup" I cannot figure out how to sort > it by that field > (in a simple/elegant way :) ). > > (I can send the whole instance to an XPL service that can use XSLT to sort > it, but maybe there is anothe way...) a variable. Could tell us more about the issue? Is there a way for us to reproduce it? An example we can run in the XForms sandbox would be ideal. Alex -- Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise Orbeon's Blog: http://www.orbeon.com/blog/ Personal Blog: http://avernet.blogspot.com/ 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 |
>exf:sort() should work equally well if the data you are sorting is in
>a variable. Could tell us more about the issue? Is there a way for us >to reproduce it? An example we can run in the XForms sandbox would be >ideal. I am now getting some help on this project, so I asked James to work on this and he started another thread: http://www.nabble.com/forum/ViewPost.jtp?post=17867017 which now has a sample that shows the problem. Thanks
|
2008/6/21 mangvlad <[hidden email]>:
> >>exf:sort() should work equally well if the data you are sorting is in >>a variable. exf:sort() isn't any sort of standard xpath? Hope you don't want portability? regards -- Dave Pawson XSLT XSL-FO FAQ. http://www.dpawson.co.uk -- 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
|
>>> exf:sort() should work equally well if the data you are sorting is
>>> in >>> a variable. > > exf:sort() isn't any sort of standard xpath? > Hope you don't want portability? Given that there is no standard sorting function in XPath 1.0, XPath 2.0, or XForms, using an extension function seems unavoidable. -Erik -- Orbeon Forms - Web Forms for the Enterprise Done the Right Way http://www.orbeon.com/ -- 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 |
2008/6/22 Erik Bruchez <[hidden email]>:
> Given that there is no standard sorting function in XPath 1.0, XPath 2.0, or > XForms, using an extension function seems unavoidable. http://www.w3.org/TR/xslt#element-sort xslt http://www.w3.org/TR/xslt20/#xsl-sort I guess it was not seen as an xpath function. regards -- Dave Pawson XSLT XSL-FO FAQ. http://www.dpawson.co.uk -- 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 |
Free forum by Nabble | Edit this page |