Dear BaseX team, perhaps I hear an opinion about the following idea. (1) The function xquery:parse is already immensely useful as it allows to *validate* XPath expressions, as for example used in configuration data. (A practical example: the XPath expressions used in JMeter [1] test plans in order to extract message data and define test assertions.) (2) Given the XSDs of a Web Service (or other application), it is possible to determine all valid data paths (e.g. /a/b/c is valid, /a/b/C is not valid). (3) If there were a reliable way to map the output of xquery:parse to the implied data paths, then one could use xquery:parse to validate xpath expression not only for syntactic correctness (which is already very much!), but also for consistency with application XSDs. This would be extremly usefuly as XSDs evolve and a checking if configuration-based XPath expressions must be adapted is otherwise very difficult to achieve in any systematic way. (4) Looking at the xquery:parse output, it seems certainly feasible to write such a mapping (xquery:parse output => data paths); but the problem I see is that the format is not guaranteed to be stable, as it is no standard. (And it is probably not described.) If BaseX provided such a functionality as an additional extension function (e.g. xquery:data-paths($query as xs:string)) you would simply be - heros. Cheers,Hans-Jürgen
[1] http://jmeter.apache.org/ PS: Illustrative example. let $query := "/descendant::OutboundFlight[Status = 'Booked'][1]/FlightDeparture/DepartureTime"return xquery:parse($query)=><MainModule updating="false"> <QueryPlan compiled="false"> <CachedPath> <Root/> <IterPosStep axis="descendant" test="OutboundFlight"> <CmpG op="="> <CachedPath> <IterStep axis="child" test="Status"/> </CachedPath> <Str value="Booked" type="xs:string"/> </CmpG> <Int value="1" type="xs:integer"/> </IterPosStep> <IterStep axis="child" test="FlightDeparture"/> <IterStep axis="child" test="DepartureTime"/> </CachedPath> </QueryPlan> </MainModule>
let $query := "/descendant::OutboundFlight[FlightDeparture/DepartureDate][1]/FlightDeparture/DepartureDate"return xquery:data-paths($query)=>//OutboundFlight/FlightDeparture/DepartureTime,//OutboundFlight/Status