Invalid URL on otherwise valid eXist queries

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

Invalid URL on otherwise valid eXist queries

HankRatz
I could simplify parts of my application, hopefully improve performance a bit if I
could use the same URL's as an instance src attribute as I do on a browser address.

For example, enter the following in the browser and I get the

http://db.nees.ucsb.edu/exist/rest?_query=doc('/pub/sitechan.xml')//sitechan[sta='GVDA'][matches(chan,'^H')]

and I get the particular subset I need.  The browser translates the url to this:

http://db.nees.ucsb.edu/exist/rest?_query=doc%28%27/pub/sitechan.xml%27%29//sitechan[sta=%27GVDA%27][matches%28chan,%27^H%27%29]

However, the same url, translated or not, cannot be used as an instance src attribute:

<xforms:instance id="gvda-sitechans"
  src="http://db.nees.ucsb.edu/exist/rest?_query=doc%28%27/pub/sitechan.xml%27%29//sitechan[sta=%27GVDA%27][matches%28chan,%27i^H%27%29]"
   xxforms:readonly="true"/>



java.lang.IllegalArgumentException Exception Class java.lang.IllegalArgumentException Message Invalid uri 'http://db.nees.ucsb.edu/exist/rest?_query=doc('/pub/sitechan.xml')//sitechan[sta='GVDA']': Invalid query Servlet Stack Trace
(119 method calls)
Class Name Method Name File Name Line Number
org.apache.commons.httpclient.HttpMethodBase <init> HttpMethodBase.java 222
org.apache.commons.httpclient.methods.GetMethod <init> GetMethod.java 89
org.orbeon.oxf.resources.handler.HTTPURLConnection setRequestMethod HTTPURLConnection.java 78

Is there a way to avoid url checking? Looks like it's part of the apache commons, but
it seems to me this behavior is recent, within the last year.

Thanks,
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: Invalid URL on otherwise valid eXist queries

Alessandro  Vernet
Administrator
Hank,

I am wondering if you get this exception HttpClient exception because  
it wants more characters (such as the brackets) to be encoded. I use  
the _query =... trick a lot, and often use it with encode-for-uri().  
E.g.:

<xforms:submission method="get" action="...?_query={encode-for-uri
(...)}"/>

You can't use an AVT in <xforms:instance src="...">, but you can run a  
submission on xforms-model-construct-done and put the oxfords:readonly  
on that submission.

Alex



On Jan 6, 2010, at 4:45 PM, Hank Ratzesberger  
<[hidden email]> wrote:

> I could simplify parts of my application, hopefully improve  
> performance a bit if I
> could use the same URL's as an instance src attribute as I do on a  
> browser address.
>
> For example, enter the following in the browser and I get the
>
> http://db.nees.ucsb.edu/exist/rest?_query=doc('/pub/sitechan.xml')//sitechan[sta='GVDA'][matches(chan,'^H')]
>
> and I get the particular subset I need.  The browser translates the  
> url to this:
>
> http://db.nees.ucsb.edu/exist/rest?_query=doc%28%27/pub/sitechan.xml%27%29//sitechan[sta=%27GVDA%27][matches%28chan,%27^H%27%29]
>
> However, the same url, translated or not, cannot be used as an  
> instance src attribute:
>
> <xforms:instance id="gvda-sitechans"
>  src="http://db.nees.ucsb.edu/exist/rest?_query=doc%28%27/pub/sitechan.xml%27%29//sitechan[sta=%27GVDA%27][matches%28chan,%27i^H%27%29]
> "
>   xxforms:readonly="true"/>
>
>
>
> java.lang.IllegalArgumentException Exception Class  
> java.lang.IllegalArgumentException Message Invalid uri 'http://db.nees.ucsb.edu/exist/rest?_query=doc('/pub/sitechan.xml')//sitechan[sta='GVDA']':
>  Invalid query Servlet Stack Trace
> (119 method calls)
> Class Name    Method Name    File Name    Line Number
> org.apache.commons.httpclient.HttpMethodBase    <init>    
> HttpMethodBase.java    222
> org.apache.commons.httpclient.methods.GetMethod    <init>    
> GetMethod.java    89
> org.orbeon.oxf.resources.handler.HTTPURLConnection    
> setRequestMethod    HTTPURLConnection.java    78
>
> Is there a way to avoid url checking? Looks like it's part of the  
> apache commons, but
> it seems to me this behavior is recent, within the last year.
>
> Thanks,
> 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


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

Re: Re: Invalid URL on otherwise valid eXist queries

HankRatz

On Jan 8, 2010, at 7:39 PM, Alessandro Vernet wrote:

> Hank,
>
> I am wondering if you get this exception HttpClient exception because it wants more characters (such as the brackets) to be encoded. I use the _query =... trick a lot, and often use it with encode-for-uri(). E.g.:

Indeed that is the issue. Unfortunately for XPath, square brackets are part of the
IP 6 URL specification, but UTF-8 encoding works around this (for now).

[ %5B
] %5D

http://www.ietf.org/rfc/rfc2732.txt

>
> <xforms:submission method="get" action="...?_query={encode-for-uri(...)}"/>
>
> You can't use an AVT in <xforms:instance src="...">, but you can run a submission on xforms-model-construct-done and put the oxfords:readonly on that submission.

Thanks.  It seems a bit counter-intuitive to initialize an instance on the
xforms-model-construct-done, but if that works...

Wind back in the sails, thanks,
Hank



>
> Alex
>
>
>
> On Jan 6, 2010, at 4:45 PM, Hank Ratzesberger <[hidden email]> wrote:
>
>> I could simplify parts of my application, hopefully improve performance a bit if I
>> could use the same URL's as an instance src attribute as I do on a browser address.
>>
>> For example, enter the following in the browser and I get the
>>
>> http://db.nees.ucsb.edu/exist/rest?_query=doc('/pub/sitechan.xml')//sitechan[sta='GVDA'][matches(chan,'^H')]
>>
>> and I get the particular subset I need.  The browser translates the url to this:
>>
>> http://db.nees.ucsb.edu/exist/rest?_query=doc%28%27/pub/sitechan.xml%27%29//sitechan[sta=%27GVDA%27][matches%28chan,%27^H%27%29]
>>
>> However, the same url, translated or not, cannot be used as an instance src attribute:
>>
>> <xforms:instance id="gvda-sitechans"
>> src="http://db.nees.ucsb.edu/exist/rest?_query=doc%28%27/pub/sitechan.xml%27%29//sitechan[sta=%27GVDA%27][matches%28chan,%27i^H%27%29]"
>>  xxforms:readonly="true"/>
>>
>>
>>
>> java.lang.IllegalArgumentException Exception Class java.lang.IllegalArgumentException Message Invalid uri 'http://db.nees.ucsb.edu/exist/rest?_query=doc('/pub/sitechan.xml')//sitechan[sta='GVDA']': Invalid query Servlet Stack Trace
>> (119 method calls)
>> Class Name    Method Name    File Name    Line Number
>> org.apache.commons.httpclient.HttpMethodBase    <init>    HttpMethodBase.java    222
>> org.apache.commons.httpclient.methods.GetMethod    <init>    GetMethod.java    89
>> org.orbeon.oxf.resources.handler.HTTPURLConnection    setRequestMethod    HTTPURLConnection.java    78
>>
>> Is there a way to avoid url checking? Looks like it's part of the apache commons, but
>> it seems to me this behavior is recent, within the last year.
>>
>> Thanks,
>> 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
>
> --
> 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
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: Invalid URL on otherwise valid eXist queries

bsteuhl
In reply to this post by Alessandro Vernet
I am using square brackets as a predicate in an eXist xquery which works bu fails in submission from xForms because of the square bracket.  I found this post but maybe I do not understand something because using encode-for-uri does not do anything.  Here is my submission:

<xforms:submission id="psiSearch" method="get"
action="http://localhost:8600/exist/rest/db/?_query=declare namespace xmldb='http://exist-db.org/xquery/xmldb'; 
let $resources := for $x in xmldb:get-child-resources('/db/CJPSIS/completedPSI')[contains(., '000000029098')]
return &lt;file&gt;{{$x}}&lt;/file&gt;
return &lt;files&gt;{{$resources}}&lt;/files&gt;"
replace="instance" instance="searchResults"  xxforms:username="XXXX" xxforms:password="XXXXXX!" validate="false">

<xforms:message ev:event="xforms-submit-error" level="modal">exist call failed</xforms:message>

</xforms:submission>

How do I escape the square brackets above for the predicate?  Thank you.
Reply | Threaded
Open this post in threaded view
|

Re: Invalid URL on otherwise valid eXist queries

bsteuhl
I used a different query to (where clause) instead if the predicate.  The predicate is more efficient so I would still like to know the solution, but it is no longer an urgent matter.  He is the new xquery:

<xforms:submission id="psiSearch" method="get"
                                action="http://localhost:8600/exist/rest/db/?_query=declare namespace xmldb='http://exist-db.org/xquery/xmldb'; declare namespace fe='http://york.com/forms/probation/xform'; let $resources := for $x in xmldb:get-child-resources('CJPSIS/completedPSI') where starts-with($x, '{instance('search')/fe:offenderID}') return &lt;file&gt;{{$x}}&lt;/file&gt; return &lt;files&gt;{{$resources}}&lt;/files&gt;"
                                        replace="instance" instance="searchResults"  xxforms:username="XXXX" xxforms:password="XXXXX!" validate="false">
                                        <xforms:message ev:event="xforms-submit-error" level="modal">exist call failed</xforms:message>
                        </xforms:submission>

Thank you - BTMSoftwareSolutions.com
Reply | Threaded
Open this post in threaded view
|

Re: Re: Invalid URL on otherwise valid eXist queries

HankRatz
In reply to this post by bsteuhl

On Jan 19, 2010, at 12:51 PM, bsteuhl wrote:

>
> I am using square brackets as a predicate in an eXist xquery which works bu
> fails in submission from xForms because of the square bracket.  I found this
> post but maybe I do not understand something because using encode-for-uri
> does not do anything.  Here is my submission:

I cannot confirm that url-encode will encode square brackets.  I was using
the query on an instance src= attribute.  Manually encoding the brackets
corrected the problem.

[ %5B
] %5D

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