xsl-list
[Top] [All Lists]

[xsl] Cannot mix nodes and atomic values - how comes?

2016-11-11 04:30:13
Hi experts,

We ran into an error that made me think about the idea of mixed data types in 
sequences. Take this instance:

<?xml version="1.0" encoding="UTF-8"?>
<bars>
  <bar foo="x"/>
  <bar/>
</bars>

We need to process all <bar> and want to have a default value if @foo is not 
present. When trying this XPath:

for $i in //bar/(@foo, 'no-foo')[1] return $i

we get the error "XPath failed due to: Cannot mix nodes and atomic values in 
the result of a path expression"

When building the XPath the following way it runs fine and creates a sequence 
of an attribute and a string:

for $b in //bar return for $i in $b/(@foo, 'no-foo')[1] return $i

What is the difference? Did I miss something in the specification?

Thanks,

- Michael

(Tested with Saxon 9.2/Kernow, 9.6/OxygenXML)
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>