i have a XML file which begins like this :
<tpinfos xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="schemaTP.xsd">
<jour id="lundi">
<salle id="A11">
<creneau debut="8:00" fin="10:00">
<formation>M1 Info</formation>
<enseignant>ME Voge</enseignant>
<matiere>ACT</matiere>
</creneau>
<creneau debut="10:00" fin="12:00">
<formation>M1 Miage</formation>
<enseignant>AC Caron </enseignant>
<matiere>ED</matiere>
</creneau>
<creneau debut="12:00" fin="13:30">
<formation>M1 Info</formation>
<enseignant>ME Voge</enseignant>
<matiere>ACT</matiere>
</creneau>
<creneau debut="15:20" fin="17:20">
<formation>M1 Info</formation>
<enseignant>ME Voge</enseignant>
<matiere>ACT</matiere>
</creneau>
</salle>
I am supposed to take every < creneau > that will match the < formation > with the parameter of this function :
declare function local:filtreFormation($f as xs:string) as element(tpinfos)
My problem is the dataType I am supposed to return, the "element(tpinfos)". All my attempt failed because of this datatype, i really don't get how i am supposed to do it without getting an error.
My last try was :
declare function local:filtreFormation($f as xs:string) as element(tpinfos)
{
for $cr in doc("planningTP.xml")/jour/salle/creneau
where $cr/formation = $f
return element tpinfos {$cr}
};
But it returns the error "Wrong occurrence to match required sequence type"
Can anyone explain to me what is wrong please?