You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Jean-Baptiste REURE <jb...@allette.com.au> on 2003/03/20 05:46:34 UTC

[JXPath] simple question on containers

Hi all,
A quick question from a newbie here.
I wanted to use JXPath in my application and I was looking for a way to use
Containers on dynamic data.
The only way to use a DocumentContainer now is to provide a URL of the xml
file containing the data.
I wanted to know if it was possible (maybe it is hidden somewhere...) to
provide a stream of some kind or a String as the xml data.
My application is generating XML data dynamically and the use of JXPath
could be very useful for me in this case. Right now, I have implemented the
saving of the dynamic data in a temporary file and use a DocumentContainer
object. It works fine but is a bit heavy.

Thanks for your response,

Jean-Baptiste REURE


RE: [HttpClient] sample code for form post

Posted by Greg Dunn <gr...@nisc.cc>.
I need to post a set of form values to an authorization service.  I couldn't
locate any example code that does this, does anyone know where I could find
some?

My initial attempts have been thwarted by the server's returning an HTTP
100 - Continue response.

This is the relevant part of what I have via trial and much error:


try {
    HttpClient client = new HttpClient();
    client.setConnectionTimeout(5000);

    PostMethod post = new PostMethod(paymentServerURL);
    post.setFollowRedirects(false);
    post.setStrictMode(true);
    post.setRequestHeader("Content-Type",
"application/x-www-form-urlencoded");

    // Add the form values
    NameValuePair[] data = {
        new NameValuePair("x_First_Name", x_First_Name),
        new NameValuePair("x_Last_Name", x_Last_Name),
        new NameValuePair("x_Card_Num", x_Card_Num),
        new NameValuePair("x_Exp_Date", x_Exp_Date)
    };

    post.setRequestBody(data);
    client.executeMethod(post);

    try {
        responseContent = post.getResponseBodyAsString();
    } catch (NullPointerException e) {
        // do graceful stuff
    }

    responseCode = post.getStatusCode();
    responseMess = post.getStatusText();

    if (responseCode != 200) {
        // do graceful stuff
    }

    post.releaseConnection();

} catch (MoreExceptions me) {
    // do graceful stuff
}


Greg


Re: [JXPath] simple question on containers

Posted by Dmitri Plotnikov <dp...@yahoo.com>.
Jean-Baptiste,

You only need to use DocumentContainer if the XML is loaded lazily from
a file or a URL.  In all other cases you simply use the DOM/JDOM
document or element itself without wrapping it into a
DocumentContainer. The document/element can be the root of the tree,
supplied to JXPath as the argument of the newContext() method, or it
can be a value of a property, variable etc.

I hope this helps.

- Dmitri Plotnikov


--- Jean-Baptiste REURE <jb...@allette.com.au> wrote:
> Hi all,
> A quick question from a newbie here.
> I wanted to use JXPath in my application and I was looking for a way
> to use
> Containers on dynamic data.
> The only way to use a DocumentContainer now is to provide a URL of
> the xml
> file containing the data.
> I wanted to know if it was possible (maybe it is hidden somewhere...)
> to
> provide a stream of some kind or a String as the xml data.
> My application is generating XML data dynamically and the use of
> JXPath
> could be very useful for me in this case. Right now, I have
> implemented the
> saving of the dynamic data in a temporary file and use a
> DocumentContainer
> object. It works fine but is a bit heavy.
> 
> Thanks for your response,
> 
> Jean-Baptiste REURE
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 


__________________________________________________
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
http://platinum.yahoo.com