XQuery: how to determine scope?
Issues related to W3C XQuery.
-
- Posts: 107
- Joined: Mon Jul 30, 2007 11:31 pm
- Location: College Park, MD, United States
XQuery: how to determine scope?
(Wow, am I really the first poster in the XQuery forum?)
So, conceptually I understand XQuery. And I like its philosophy.
(XSL was my first love, though.
XQuery just has a different “feel”, which has a very different mindset when programming. I want to explore that…and if I’m really lucky, start using eXist seriously instead of just screwing around now and then.)
But one thing that has always driven me absolutely crazy is trying to figure out when I’m in “XQuery” scope versus “XML” scope. I can’t figure it out!
Anybody who can demystify
So, conceptually I understand XQuery. And I like its philosophy.
(XSL was my first love, though.

But one thing that has always driven me absolutely crazy is trying to figure out when I’m in “XQuery” scope versus “XML” scope. I can’t figure it out!
- Sometimes there are curly braces, sometimes there aren’t.
- When inserting a variable or function call into XML, does it get enclosed in curly braces? If you’re already inside open braces, do you (a) close them, insert the value, then re-open them and continue writing XML, or (b) stick in the $value and keep going?
Anybody who can demystify
-- Zearin
-
- Posts: 107
- Joined: Mon Jul 30, 2007 11:31 pm
- Location: College Park, MD, United States
Re: XQuery: how to determine scope?
Whoops…looks like I forgot to delete a partial thought. Ignore that last sentence fragment. Sorry! Couldn’t seem to find an “edit” button…
-- Zearin
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: XQuery: how to determine scope?
Hello,
Well the rule is simple: If you're in XML context(between tags or inside a tag) and want to evaluate an XQuery expression, you have to use curly braces.
Note that you can even have nested braces.
<XML>{
XQuery <XML>{XQuery}</XML> XQuery
}</XML>
e.g.
This yields:
If you're in XML context and you don't use curly braces, the content is considered XML text:
This yields:
No evaluation of the XQuery code.
Regards,
Adrian
The forum is getting reorganized. It's the first time we have an XQuery forum, so most XQuery topics from the past are scattered around. Soon we will gather these topics and move them here.Zearin wrote:(Wow, am I really the first poster in the XQuery forum?)
Well the rule is simple: If you're in XML context(between tags or inside a tag) and want to evaluate an XQuery expression, you have to use curly braces.
Note that you can even have nested braces.
<XML>{
XQuery <XML>{XQuery}</XML> XQuery
}</XML>
e.g.
Code: Select all
<test>{
let $tst := "a test"
return <testing attr="{$tst}">{$tst}</testing>
}</test>
Code: Select all
<test>
<testing attr="a test">a test</testing>
</test>
Code: Select all
<test>{
let $tst := "a test"
return <testing attr="$tst">$tst</testing>
}</test>
Code: Select all
<test>
<testing attr="$tst">$tst</testing>
</test>
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service