IMPORTANT:
this is not a Support Forum! Experienced users might answer from time to time questions posted here. If you need a professional and reliable answer, or if you want to report a bug, please contact Altova Support instead.

XQuery Options · View
akulkar
Posted: Wednesday, March 18, 2015 10:52:20 PM
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.

vlad
Posted: Thursday, March 19, 2015 11:16:11 AM
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> )
Vaidas
Posted: Wednesday, April 13, 2016 10:51:14 AM
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.

Users browsing this topic
guest

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Use of the Altova User Forum(s) is governed by the Altova Terms of Use.