i wanna to use the info from faculty as my element tag without created manually, like:
<Faculties>
<information-technology>
<test></test>
</information-technology>
<law>
<test></test>
</law>
</Faculties>

My xquery is like below:
<Faculties>
{
for $r in doc("researchnet.xml")/db
for $f in distinct-values($r/staff/row/faculty)
for $faculty in name($f)
order by $faculty
return
<$faculty>
</$faculty>
}
</Faculties>

but the output gaves me an error of it:
Error on line 7 column 1 of file:/C:/saxonb8-9j/faculty.xq:
XPST0003: XQuery syntax error in $... by $faculty return <$faculty>#:
Invalid element name <$faculty>
Static error(s) in query