Hi,
I have a suggestion for a new category of 'How-to''s': Xpath (or xquery) oneliners. Here's a little contribution: Problem: there's no substring-after-last Solution (Xpath 2): tokenize(inputString,'separator')[last()] Use the tokenize function to create a sequence and take the last item. This comes in handy if you're working with OIDs (universal object identifiers), here's an example: <dataset id="2.16.840.1.113883.2.4.6.99999.90.7.1" version="1" effectiveDate="2010-09-24" statusCode="draft"> The id attribute is in the form of an OID, if I want to increase the id I can use tokenize(@id,'.')[last()] to get the number after the last dot, cast it to an integer, get the maximum value and add 1. I hope you'll find this useful. Regards, Gerrit -- 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
|
Hi Gerrit,
I like the idea of having a how-to for XPath. I'll add you to the wiki access list, so you can log in, and add this yourself. The wiki uses Google Sites, so I just need to have an email address that you use to log into Google to add you (e.g. @gmail.com). If you can send me such an email address, I'll just add it to the ACL. (And of course, feel free to send to me by private email.) Alex On Sun, Jun 26, 2011 at 9:13 AM, Gerrit Boers <[hidden email]> wrote: > Hi, > I have a suggestion for a new category of 'How-to''s': Xpath (or xquery) > oneliners. > Here's a little contribution: > Problem: there's no substring-after-last > Solution (Xpath 2): tokenize(inputString,'separator')[last()] > Use the tokenize function to create a sequence and take the last item. > > This comes in handy if you're working with OIDs (universal object > identifiers), here's an example: > <dataset id="2.16.840.1.113883.2.4.6.99999.90.7.1" version="1" > effectiveDate="2010-09-24" statusCode="draft"> > The id attribute is in the form of an OID, if I want to increase the id I > can use tokenize(@id,'.')[last()] to get the number after the last dot, cast > it to an integer, get the maximum value and add 1. > I hope you'll find this useful. > > Regards, > Gerrit > > -- > 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 |