Comments (2)
The reason I left out numeric subscripting is that it's not clear whether it should return a single member or an array of members.
You would probably expect
let $array := [1, 2, 3, 4, 5] return $array?[3]
to return 3 rather than [3].
Overloading filtering and subscripting works for sequences because an item is the same thing as a sequence of length 1. That equivalence doesn't exist for arrays, so if you overload the operator there's immense scope for confusion.
As the spec says:
Unlike filter expressions for sequences, there is no special treatment of numeric predicate values. This is because it would be unclear whether such an expression should return the member at the specified position, or a singleton array containing that member. Numeric values for the predicate are disallowed to avoid any possible confusion.
from qtspecs.
Unlike filter expressions for sequences, there is no special treatment of numeric predicate values. This is because it would be unclear whether such an expression should return the member at the specified position, or a singleton array containing that member. Numeric values for the predicate are disallowed to avoid any possible confusion.
Iโve seen the comment, but I donโt find it persuasive. [$n]
and [position() = $n]
have always been equivalent; if we believe that this syntax could be immensely confusing for arrays and possibly maps, we should definitely drop positional access in array/map predicates in general. Next, now that we allow EXPR[$n1, $n2, ...]
, the single integer is just a special case.
My preference, however, would be to make predicates completely symmetric, no matter if they are part of XPath steps, Filter Expressions or Array/Map Filters.
from qtspecs.
Related Issues (20)
- XSLT: system-property('xsl:xpath-version')
- fn:format-dateTime: Properties
- fn:json-to-xml: `number-parser` option HOT 1
- `??type(T)` in lookup expressions - shortcuts
- for member allowing empty HOT 2
- Allow sequence constructor in extension instructions that are implemented with named templates HOT 1
- Add a new function `fn:html-doc` HOT 2
- XSLT: add xsl:switch to list of instructions within which whitespace is ignored
- Add decimal-divide function
- fn:apply() - contradiction in spec
- Could the labeling of grammar productions be improved? HOT 2
- Schema validation in XPath HOT 1
- Add xsl:value-of/@as attribute HOT 2
- Generalize for-each-pair to work with any number of input sequences HOT 2
- Further refinement of fn:round() HOT 1
- Declare named record types
- Line endings in unparsed-text-lines() HOT 1
- invisible-xml() return type HOT 1
- Build issue: Unsupported specref to [streamability-fn-distinct-ordered-nodes] HOT 4
- Appendix H of F&O should mention change for unrecognised option parameters
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from qtspecs.