retrieve last element in document to generate next ID value

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

retrieve last element in document to generate next ID value

swami
Hi,

I am creating an 'events' database, where each event has the following form:

<event>
   <eventId>EV00001</eventId>
   <eventTypeId>003</eventTypeId>
   <eventLocId>00034</eventLocID>
   <comments>blah, blah...</comments>
</event>

I am using xforms to allow the user to add a new event, and I want to have an output control which displays the eventID that will be associated with the new event. To do this I need to retrieve the eventId value of the last event element in the document, +1 to the numeric part, and then display it.

whenever I try to access any of the instance data, it only gives me data from the first event element in the document

my document is stored in an exist database.

Any ideas on how to do this would be greatly appreciated

Pranams

Swami Kevala
Reply | Threaded
Open this post in threaded view
|

Re: retrieve last element in document to generate next ID value

Alessandro Vernet
Administrator
Swami,

On Jan 18, 2008 2:12 AM, Swami Kevala <[hidden email]> wrote:
> I am using xforms to allow the user to add a new event, and I want to have
> an output control which displays the eventID that will be associated with
> the new event. To do this I need to retrieve the eventId value of the last
> event element in the document, +1 to the numeric part, and then display it.
>
> whenever I try to access any of the instance data, it only gives me data
> from the first event element in the document

I assume you are doing this with XPath. Are you writing something like
/events/event[last()]/id? Note the "[last()]" part. If this doesn't
help, could you post here a standalone example that runs in the XForms
sandbox and shows what you are talking about.

Alex
--
Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise
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