2

When trying to use the oXygen editor to comment out a node inside of an element oXygen simply wrapped it into (:<foo>foo 1</foo>:), but I then found out that that way the node did not get commented out but was rather prefixed by a text node with (: and suffixed by a text node with :).

Then I looked up the syntax and found out you need to use an enclosed expression {(:<foo>foo 1</foo>:)} instead to have access to the comment syntax.

However, while BaseX and Saxon 9.8 happily accept {(:<foo>foo 1</foo>:)}, Altova complains and needs an additional empty sequence {(:<foo>foo 1</foo>:)()}.

https://www.w3.org/TR/xquery-31/#doc-xquery31-EnclosedExpr suggests in XQuery 3.1 the expression inside curly braces is optional and defaults to ().

Does this also mean that in XQuery 3.1 it should suffice to use simply the comment inside of the curly braces, without an empty sequence?

So to summarize, Saxon and BaseX allow me to use <root>{(:<foo>foo 1</foo>:)}</root> while Altova complains about incorrect syntax, forcing me to use <root>{(:<foo>foo 1</foo>:)()}</root>.

Is that still necessary in XQuery 3.1?

Martin Honnen
  • 160,499
  • 6
  • 90
  • 110

1 Answers1

0

Sounds like a bug in their commenter, which is pretty common in XQuery editors. Within in an element - and assuming you are using direct element constructors, not computed element constructors - use XML comments:

<hello>world
  <!-- Don't print me -->
</hello>

Computed element constructors still use XQuery comments:

element hello {
  'world' (: Don't print me :)
}
wst
  • 11,681
  • 1
  • 24
  • 39
  • Sorry, I hadn't finished the question and it got posted unintentionally while adding the tags, my aim is to comment out a node, not to put a comment into the constructed content. – Martin Honnen Dec 20 '17 at 15:43
  • @MartinHonnen My read of the spec is the same as yours, that the empty sequence is optional and implied by the use of curly braces (MarkLogic behaves this way too). I assume Altova's parser is wrong. But note that this is only an issue if you insist on XQuery comments - you can avoid this problem altogether by using XML comments inside of that element. i.e.: `` – wst Dec 20 '17 at 16:07
  • Well, the XQuery comment ensures the part commented out is not part of the created document, if I use XML comments then I insert a comment into the created document. – Martin Honnen Dec 20 '17 at 21:47