|
Rank: Newbie
Joined: 3/18/2015 Posts: 1
|
Hi My XML is as follows :
<root> <course> <reg_num>10499</reg_num> <subj>GER</subj> <crse>391</crse> <sect>F</sect> <title>German Thought Postmodrn Era</title> <units>1.0</units> <instructor>Irmscher</instructor> <days>T-Th</days> <time> <start_time>02:40PM</start_time> <end_time>04:00</end_time> </time> <place> <building>ELIOT</building> <room>414</room> </place> </course> <course> ..................... </course> </root>
I need to display
<CourseInstructor instrName="Brightman"> <course>GER</course> <building>ELIOT</building> </CourseInstructor> <CourseInstructor instrName="Makley"> <course>..</course> <building>..</building> </CourseInstructor> <CourseInstructor instrName="Kaplan"> <course>BIOL</course> <building>..</building> </CourseInstructor>
My XQuery is
for $eachInstr in distinct-values(//instructor) return element CourseInstructor { attribute {"instrName"} {$eachInstr}, for $courseName in distinct-values(//course[instructor = $eachInstr]/subj) let $bldg := //course[instructor = $eachInstr and subj = $courseName]/place/building return <course> {$courseName} </course> , <building> {$bldg} </building> }
I get the error variable $bldg is not declared error
If I remove the building part I get proper output with just the course part.
|
|
Rank: Advanced Member
Joined: 12/13/2005 Posts: 2,856 Location: Mauritius
|
This is because the part before , belongs to return statement - whereas after , not
You need to use brackets to fix your issue:
return ( <course> {$courseName} </course> , <building> {$bldg} </building> )
|
|
Rank: Newbie
Joined: 4/13/2016 Posts: 1
|
Hi, I need insert picture with base64. I found some description on manual instruction, but didnt undertood what value needed on xpath field
akulkar wrote:Hi My XML is as follows :
<root> <course> <reg_num>10499</reg_num> <subj>GER</subj> <crse>391</crse> <sect>F</sect> <title>German Thought Postmodrn Era</title> <units>1.0</units> <instructor>Irmscher</instructor> <days>T-Th</days> <time> <start_time>02:40PM</start_time> <end_time>04:00</end_time> </time> <place> <building>ELIOT</building> <room>414</room> </place> </course> <course> ..................... </course> </root>
I need to display
<CourseInstructor instrName="Brightman"> <course>GER</course> <building>ELIOT</building> </CourseInstructor> <CourseInstructor instrName="Makley"> <course>..</course> <building>..</building> </CourseInstructor> <CourseInstructor instrName="Kaplan"> <course>BIOL</course> <building>..</building> </CourseInstructor>
My XQuery is
for $eachInstr in distinct-values(//instructor) return element CourseInstructor { attribute {"instrName"} {$eachInstr}, for $courseName in distinct-values(//course[instructor = $eachInstr]/subj) let $bldg := //course[instructor = $eachInstr and subj = $courseName]/place/building return <course> {$courseName} </course> , <building> {$bldg} </building> }
I get the error variable $bldg is not declared error
If I remove the building part I get proper output with just the course part.
|
|
guest |