4.3.5 Queries embedded in documents
When using queries embedded in documents together with variants, usually you will want to limit the query results to variants with the same branch and language as the one containing the query. You could specify these explicitly, as in:
select id, name where <conditions> and branch='my_branch' and language='my_lang'
However, this means that you will need to adjust these queries when adding new variants to the document. Especially if you are adding a certain branch to a set of documents, this is not something you want to do. Therefore, it should be possible to refer to the branch and language of the containing document. This can be done as follows:
select id, name where <conditions> and branchId = ContextDoc(branchId) and languageId = ContextDoc(languageId)