mchoeti Posted February 4, 2015 Share Posted February 4, 2015 HI everybody i have done the xquery tutorial, but i have a question.in the xml document there is an book entry with more then one author,as example i have postet one example here:<book category="Test"><title lang="en">How it works</title><author>Max Mustermann</author><author>Susi Sorglos</author><author>Herbert Bauer</author></book>Now i start a query, with the following code line.for $x in doc("books.xml")/bookstore/bookreturn<name> {data($x/author)}</name>i got all the autors, but in one line,.<name>Max Mustermann Susi Sorglos Herbert Bauer</name> do you have an idea to get a result like this`: <name>Max Mustermann</name> <name>Susi Sorglos</name> <name>Herbert Bauer</name> cheers Christian Link to comment Share on other sites More sharing options...
Ingolme Posted February 4, 2015 Share Posted February 4, 2015 If there's more than one author then another query is needed: for $x in doc("books.xml")/bookstore/bookreturn { for $y in $x/author return <name>{data($y)}</name>} 1 Link to comment Share on other sites More sharing options...
mchoeti Posted February 5, 2015 Author Share Posted February 5, 2015 (edited) If there's more than one author then another query is needed: for $x in doc("books.xml")/bookstore/bookreturn { for $y in $x/author return <name>{data($y)}</name>} hm.. thank you men, but interresting, when i use the code with { } then i got an error message XPST0003: Unexpected token "{" in path expression i used this and now it worked, but do you have an answer to the error code?yes i know, brackets on wrong position :-) {for $x in doc("books.xml") /bookstore/bookreturn for $y in $x/author return <name>{data($y)}</name>} Edited February 5, 2015 by mchoeti Link to comment Share on other sites More sharing options...
Ingolme Posted February 5, 2015 Share Posted February 5, 2015 I'm not all that familiar with XQuery. I assumed each new expression needed a new pair of braces. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now