Problems by generation a new XML-file with XQuery

hi there! would be really great, if someone could take a short look at my code!:slight_smile: i got the following error-message: Error on line 7 column 5 of file:/E:/path/aufgabe2a.xpath: XPST0003: XQuery syntax error in #…gory{“test”}} { if#: expected “)”, found “{” Failed to compile query the passage, where the error raises is the following:

<books> { for $x in //book return ( element { node-name($x) }{attribute category{"test"}} { if(contains(string($x/title),"XML")) then (

so… now i have two possibles… 1. delete the ‘{attribute category{“test”}}’ passage… or 2. delete all the inner content

if(contains(string($x/title),"XML")) then (

both variants work fine… 1. only with the element and not attributs but with inner elements or 2. with element and attribute, but without more inner elements… :frowning: has someone an idea?? thanx a lot!

problem solved!!!

the fault was, that i hadn’t to close the last braket ‘}’ after the attribute, because on that position the content has to follow…

<books>
	{
		for $x in //book 
		return
		(
			element { node-name($x) }{attribute category{"test"},
				
			 		if(contains.........

greetinx