How can I get at the document url?

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

How can I get at the document url?

Mathias Picker
What would be the right way to get at the document url of the xforms
document? I only find fn:document-uri(), but can I get at the xforms
document with xpath, or only at instances defined in the model?

Do I need to escape into javascript for this?



Thanks for any pointers,

Mathias



--
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
Reply | Threaded
Open this post in threaded view
|

Re: How can I get at the document url?

Hank Ratzesberger
Hi Mathias,

On Jul 31, 2009, at 2:34 AM, Mathias Picker wrote:

> What would be the right way to get at the document url of the xforms
> document? I only find fn:document-uri(), but can I get at the xforms
> document with xpath, or only at instances defined in the model?
>
> Do I need to escape into javascript for this?

When you say JavaScript, I suppose you mean to get at document
using it.  Orbeon provides a way for you to get values of
controls and dispatch events:

http://wiki.orbeon.com/forms/doc/developer-guide/xforms- 
extensions#TOC-JavaScript-Integration

It is not difficult to pass an instance to javascript by
converting the xml to text and holding it in a (hidden) input
control. I use xxforms:serialize as html, I recall it creates
line breaks that make parsing it in JavaScript better. Roughly:

  <xforms:bind nodeset="text" type="xs:string"
   calculate="xxforms:serialize( instance('my-instance'), 'html' )"/>

...

  var xml = GXml.parse(text); // Google Map API to parse xml


I don't know that you can get the xforms document in JavaScript,
and indeed, the "real" document is on the server, where the full
XPath 2.0, etc., environment is assured.

Hope I understood your question,
Hank


Hank Ratzesberger
NEES@UCSB
Institute for Crustal Studies,
University of California, Santa Barbara
805-893-8042







--
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
Reply | Threaded
Open this post in threaded view
|

Re: How can I get at the document url?

Erik Bruchez
Administrator
In reply to this post by Mathias Picker
Do you mean the URL of the document on the server, e.g.:

oxf:/apps/my-app/foo.xhtml

Or do you mean the URL as seen by the browser, e.g.:

http://example.com/orbeon/my-app/foo

-Erik

On Fri, Jul 31, 2009 at 2:34 AM, Mathias Picker<[hidden email]> wrote:

> What would be the right way to get at the document url of the xforms
> document? I only find fn:document-uri(), but can I get at the xforms
> document with xpath, or only at instances defined in the model?
>
> Do I need to escape into javascript for this?
>
>
>
> Thanks for any pointers,
>
> Mathias
>
>
>
> --
> 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
>
>


--
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
Reply | Threaded
Open this post in threaded view
|

Re: Re: How can I get at the document url?

Mathias Picker
Am Samstag, den 01.08.2009, 16:26 -0700 schrieb Erik Bruchez:
> Do you mean the URL of the document on the server, e.g.:
>
> oxf:/apps/my-app/foo.xhtml
>
> Or do you mean the URL as seen by the browser, e.g.:
>
> http://example.com/orbeon/my-app/foo
>
> -Erik

I mean the url the browser sees, including query string.

I know how to get instance data into xforms with orbeon, e.g. XInclude /
input:instance , but what would be a more portable way? If I could get
the document url (ok, browser document url) I could use the query string
and load an instance using a dynamic submission element.

I'm just curious, I have a solution for now.

/ Mathias

>
> On Fri, Jul 31, 2009 at 2:34 AM, Mathias Picker<[hidden email]> wrote:
> > What would be the right way to get at the document url of the xforms
> > document? I only find fn:document-uri(), but can I get at the xforms
> > document with xpath, or only at instances defined in the model?
> >
> > Do I need to escape into javascript for this?
> >
> >
> >
> > Thanks for any pointers,
> >
> > Mathias
> >
> >
> >
> > --
> > 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
> >
> >
> einfaches Textdokument-Anlage (message-footer.txt)
> --
> 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


--
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
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: How can I get at the document url?

Hank Ratzesberger
> Am Samstag, den 01.08.2009, 16:26 -0700 schrieb Erik Bruchez:

>> Do you mean the URL of the document on the server, e.g.:
>>
>> oxf:/apps/my-app/foo.xhtml
>>
>> Or do you mean the URL as seen by the browser, e.g.:
>>
>> http://example.com/orbeon/my-app/foo
>>
>> -Erik
>
> I mean the url the browser sees, including query string.
>
> I know how to get instance data into xforms with orbeon, e.g. XInclude /
> input:instance , but what would be a more portable way? If I could get
> the document url (ok, browser document url) I could use the query string
> and load an instance using a dynamic submission element.
>
> I'm just curious, I have a solution for now.
I see.  You can get known parameter values with the extended
functions, e.g.:

<xforms:setvalue ref="my-param" value="xxforms:get-request-parameter('myparam')"/>

http://www.orbeon.com/ops/doc/reference-xforms-functions

To get the url, you can use the request generator processor

http://www.orbeon.com/ops/doc/processors-generators-request

in an xpl file with an output param.  And the file is the
model attribute of your page flow.  Then, e.g.:

<xforms:instance src="input:data"/>

(If I have it right this time)

Cheers,
Hank





--
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
Reply | Threaded
Open this post in threaded view
|

Re: How can I get at the document url?

Mathias Picker
Am Sonntag, den 02.08.2009, 13:55 -0700 schrieb Hank Ratzesberger:
[snip]

> I see.  You can get known parameter values with the extended
> functions, e.g.:
>
> <xforms:setvalue ref="my-param" value="xxforms:get-request-parameter('myparam')"/>
>
> http://www.orbeon.com/ops/doc/reference-xforms-functions
> To get the url, you can use the request generator processor
>
> http://www.orbeon.com/ops/doc/processors-generators-request
>
> in an xpl file with an output param.  And the file is the
> model attribute of your page flow.  Then, e.g.:
>
> <xforms:instance src="input:data"/>
Ja, that's what I'm doing right now.

>
> (If I have it right this time)

:-) Thanks for still thinking about it.

I was looking for something not orbeon-specific, but included in xforms,
but maybe there is no such thing.

Cheers, Mathias



PS:

I thought with xforms 1.1 I could do something like

<submission replace="instance" instance="instanceToBeEdited">
    <resource
        value="concat(instance('conf')/path/to/data, string-after(document-uri(/), '?'))"/>
</submission>

and trigger it at xforms-ready. (The "parsing" here obviously sketchy, and it's not tested
and I'm not yet fluent in xforms so the example is probably faulty, but I hope good
enough to show what I thought could work.)

I will test it in a few days, but I hoped I could get an obvious
solution on this list, freeing me from experimenting.


PPS: searching for a solution I found
http://www.ibm.com/developerworks/xml/library/x-xformsdynamic/index.html
which is a javascript way to do it in xforms 1.0. I still hope for
something within xforms.

>
>
>
> Cheers,
> Hank
>
>
>
> einfaches Textdokument-Anlage (message-footer.txt)
> --
> 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


--
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
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: How can I get at the document url?

Erik Bruchez
Administrator
In reply to this post by Mathias Picker
Mathias,

I think what we need is to add some extension XPath functions. We
already have some to get request parameters, headers, etc.

http://www.orbeon.com/ops/doc/reference-xforms-functions#orbeon-extensions

Basically, we need to complete that API. It would be an easy thing for
a contributor to do based on existing functions! See:

http://github.com/orbeon/orbeon-forms/tree/master/src/java/org/orbeon/oxf/xforms/function/xxforms/

-Erik

On Sun, Aug 2, 2009 at 5:05 AM, Mathias Picker<[hidden email]> wrote:

> Am Samstag, den 01.08.2009, 16:26 -0700 schrieb Erik Bruchez:
>> Do you mean the URL of the document on the server, e.g.:
>>
>> oxf:/apps/my-app/foo.xhtml
>>
>> Or do you mean the URL as seen by the browser, e.g.:
>>
>> http://example.com/orbeon/my-app/foo
>>
>> -Erik
>
> I mean the url the browser sees, including query string.
>
> I know how to get instance data into xforms with orbeon, e.g. XInclude /
> input:instance , but what would be a more portable way? If I could get
> the document url (ok, browser document url) I could use the query string
> and load an instance using a dynamic submission element.
>
> I'm just curious, I have a solution for now.
>
> / Mathias
>
>>
>> On Fri, Jul 31, 2009 at 2:34 AM, Mathias Picker<[hidden email]> wrote:
>> > What would be the right way to get at the document url of the xforms
>> > document? I only find fn:document-uri(), but can I get at the xforms
>> > document with xpath, or only at instances defined in the model?
>> >
>> > Do I need to escape into javascript for this?
>> >
>> >
>> >
>> > Thanks for any pointers,
>> >
>> > Mathias
>> >
>> >
>> >
>> > --
>> > 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
>> >
>> >
>> einfaches Textdokument-Anlage (message-footer.txt)
>> --
>> 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
>
>
>
> --
> 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
>
>


--
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