INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

how to copy the value of a dynamic xml generated node to wml/wmlscript

how to copy the value of a dynamic xml generated node to wml/wmlscript

how to copy the value of a dynamic xml generated node to wml/wmlscript

(OP)
hello there, i am writing an online bookstore Wireless aplication.
the dynamic xml file structure is(created by a java servlet):
<cart numItems=" " total = " ">
    <item>
        <productID>
        <quantity>
        <price>
        <title>
        <author>
        <isbn>
    <item>
        <productID>
        <quantity>
        <price>
        <title>
        <author>
        <isbn>

=============================
there is many items as you see, i am trying to copy "productID" value of each item to a variable.
i did this:
<xsl:for-each select =/cart/item">
<onevent type = "onenterforward">
<refresh>
<setvar name = "prodID" value = "{/cart/item/productID}"/>
</refresh>
</onevent>
</xsl:for-each>
===============
it worked but it is always taking the 1st value(not getting other values)
and i need it to loop and get them all.
any help is apreciated, thanks
ps: i dont mind using a wmlscript code if possible, thanks

RE: how to copy the value of a dynamic xml generated node to wml/wmlscript

[0] typo
><xsl:for-each select =/cart/item">
<xsl:for-each select="/cart/item">
[1] main correction
><setvar name = "prodID" value = "{/cart/item/productID}"/>
<setvar name = "prodID" value = "{productID}"/>

RE: how to copy the value of a dynamic xml generated node to wml/wmlscript

(OP)
hello,thanks for your post but,
I've tried what you said, and still it is always printing
the same value N times,where N is the last number in loop.
here is what i did:
<xsl:for-each select = "/cart/item">
<onevent type = "onenterforward">

         <refresh>
            
<setvar name = "prodID" value = "{productID}"/>
$(prodID)
         </refresh>
</onevent>

</xsl:for-each>
=============
on each time it is printing the same Value eg: 4444
while it should be like 4628.
i tried to put $(prodID) after the </onevent> but no works.
in details,what i am trying to do is to send all the productID's to a java servlet using this code:
    <go href =
                  "http://192.168.2.2:80/wbs/servlet/CheckOutServlet"
                  method = "post">
<postfield name = "productID" value = "$(prodID)"/>
</go>
====================
i need to send all the productID values
but in wml there is no arrays to put all values in an array so i need to send them 1 by 1.
any ideas? :(

RE: how to copy the value of a dynamic xml generated node to wml/wmlscript

[2] I actually have nothing to change to what I posted as far as the essential of it. I have no idea of what is the rest of your script. You've made good use of the essential idea and you cannot just jump to some imaginary and wrong conclusion that nothing changed. It functions but you have not made good use of the change (something you didn't show to the forum): that's all.

[3] This is a slight elaboration to get you the corresponding mapping. Now, the name is a list of different names working just like an array or something. I put all the setenv in one "refresh" and postfield under one "go" just for illustration.

<!-- etc etc -->
<xsl:template match="/">
    <!-- etc etc -->
    <wml>
    <!-- etc etc -->
    <refresh>
        <xsl:for-each select ="cart/item">
            <setvar name="prodID_{position()}" value="{productID}" />
        </xsl:for-each>
    </refresh>
    <!-- etc etc -->
    <go>
        <xsl:for-each select="cart/item">
            <postfield name="producdID_{position()}" value="$(prodID_{position()})" />
        </xsl:for-each>
    </go>
    <!-- etc etc -->
    </wml>
</xsl:template>

Beef up the sketch yourself.

RE: how to copy the value of a dynamic xml generated node to wml/wmlscript

(OP)
Hey there,
first of all i would like to apologise in case you felt offended,sure your post helped me,i didn't mean anything else.
please understand that i am new to wml and i am just trying to figure it out.
now your second reply lend me 90 % near to the full solution.
the Request now (from the openwave simulator) is:
URL: http://192.168.2.2:80/wbs/servlet/CheckOutServlet
Request
productID=4&productID=1&productID=5&productID=2
==============
productID is finaly taking all values but, there is 1 problem.
on the other end,the CheckOutServlet takes only 1 parameter which is productID.
so is there a way to make the request like this:
productID=4152  ?
and later i can do some string manipulation in the servlet to seperate the ID's.
see i need to send 1 parameter to the servlet,containing all ID's.
here is the important CheckOutServlet Code:
String productID =  req.getParameter( "productID" );
      int bookElement = cart.contains( productID );
      cart.remove( bookElement );
      session.setAttribute( "cart", cart );
==================
as you can see all what the Servlet does is to delete the book from user cart given its productID.
and i want to delete all products in cart once a user clicks checkout,this is why i want it this way:)
if you have any other ideas i would apreciate it also.
you helped me alot so far, thank you for your time

RE: how to copy the value of a dynamic xml generated node to wml/wmlscript

(OP)
i've finally figured it out.
i found out there is a method getParameterValues()
which gets all the sent values by the request.
i used it in the java servlet code intead of req.getParameter,and with your xsl code which you gave me it worked like a dream.
thanks again, it coudn't work without your help :)

RE: how to copy the value of a dynamic xml generated node to wml/wmlscript

Thanks for the feedback with good news. I was not offended, honestly. I was just being too much "frank-parler" with the pre-conceived idea of what most we can reasonably expected from what we reveal and what we are exposed on the problem. I wouldn't worry about it, so peace to you as well.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close