2
我應該編寫一個基於XQuery的SQL腳本來將來自3個不同XML文件的數據合併爲一個統一格式 。 輸出應該是以下格式:XQuery - 需要幫助
<Courses>
<Course school="NYU">
<Number>30144</Number>
<Title>C‐PAC II</Title>
<Instructor>Lewis</Instructor>
</Course>
...
<Course school="Harvard">
<Number>4949</Number>
<Title>Computer Science 50. Introduction to Computer Science I</Title>
<Instructor>Michael D. Smith</Instructor>
</Course>
...
</Courses>
我寫了下面的腳本來實現上述:
SELECT catalog.query('
<Courses>
{
(<Course school = "NYU">
{
for $x in (/nyu/Course)
return
<Number> {$x/CallNo/text()} </Number>
<Title> {$x/Name/text()} </Title>
<Instructor> {$x/Instructor/text()} </Instructor>
}
</Course>)
union
(<Course school = "Harvard">
{
for $y in (/harvard/Course)
return
<Number> {$y/Number/text()} </Number>
<Title> {$y/Title/text()} </Title>
<Instructor> {$y/Instructor/text()} </Instructor>
}
</Course>)
union
(<Course scool = "Umich">
{
for $z in (/umich/Course)
return
<Number> {$z/@catalognumber} </Number>
<Title> {$z/name/text()} </Title>
}
</Course>)
}
</Courses>
')
from catalogs
誰能請告訴我在哪裏我都去錯了嗎?