I have recently been working on a project for Uni using the eXist xmldb and of course xquery.
What I have been trying to do is search for a customer by the id attribute value.
For example
---------------------------
xquery version "1.0";
<ul>
{
let $x := data(doc("customer.xml")//customers/customerid[@id="02"])
return
<li>{data($x)}</li>
}
</ul>
--------------------------------
This returns a value as the whole thing is hard coded.
But I essentially have to have a user input data into an xhtml form which will pass the data into a variable.
I want to search for the customer with a variable from the input form.
However, when I use a variable, example below:
-------------------------------------------------
xquery version "1.0";
let $y := 02
<ul>
{
let $x := data(doc("customer.xml")//customers/customerid[@id=$y])
return
<li>{data($x)}</li>
}
</ul>
This outputs an error.
Note that this is only testing to see if I can input a variable the in path and there have been a few variations of this but none seems to output anything.
Could anybody help me?!
Any advice would be appreciated.
P.s please excuse by newbie syntax
What I have been trying to do is search for a customer by the id attribute value.
For example
---------------------------
xquery version "1.0";
<ul>
{
let $x := data(doc("customer.xml")//customers/customerid[@id="02"])
return
<li>{data($x)}</li>
}
</ul>
--------------------------------
This returns a value as the whole thing is hard coded.
But I essentially have to have a user input data into an xhtml form which will pass the data into a variable.
I want to search for the customer with a variable from the input form.
However, when I use a variable, example below:
-------------------------------------------------
xquery version "1.0";
let $y := 02
<ul>
{
let $x := data(doc("customer.xml")//customers/customerid[@id=$y])
return
<li>{data($x)}</li>
}
</ul>
This outputs an error.
Note that this is only testing to see if I can input a variable the in path and there have been a few variations of this but none seems to output anything.
Could anybody help me?!
Any advice would be appreciated.
P.s please excuse by newbie syntax