Is it possible to open 2 documents from an xQuery and do a join on them?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes, here is an example from the XQuery spec.:
‘Joins, which combine data from multiple sources into a single result, are a very important type of query. In this section we will illustrate how several types of joins can be expressed in XQuery. We will base our examples on the following three documents:
parts.xmlthat contains manypartelements; eachpartelement in turn containspartnoanddescriptionsubelements.suppliers.xmlthat contains manysupplierelements; eachsupplierelement in turn containssuppnoandsuppnamesubelements.catalog.xmlthat contains information about the relationships between suppliers and parts. The catalog document contains manyitemelements, each of which in turn containspartno,suppno, andpricesubelements.A conventional (‘inner’) join returns information from two or more related sources, as illustrated by the following example, which combines information from three documents. The example generates a ‘descriptive catalog’ derived from the catalog document, but containing part descriptions instead of part numbers and supplier names instead of supplier numbers. The new catalog is ordered alphabetically by part description and secondarily by supplier name.*
The previous query returns information only about parts that have suppliers and suppliers that have parts. An outer join is a join that preserves information from one or more of the participating sources, including elements that have no matching element in the other source. For example, a left outer join between suppliers and parts might return information about suppliers that have no matching parts.’
Do note that XQuery does not have a standard document() function (it is an XSLT function) and instead has the doc() function, which is part of the ‘XQuery 1.0 and XPath 2.0 Functions and Operators‘.
There are at least two errors in the answer by Chris:
fn‘ prefix.