[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Find the number of elements that are prior to the

Subject: Re: Find the number of elements that are prior to the series of elements that match a string?
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 12 Mar 2019 19:53:22 -0000
Re:  Find the number of elements that are prior to the
On 12.03.2019 18:35, Costello, Roger L. costello@xxxxxxxxx wrote:

I have an XML document containing a long list of Byte elements, e.g.,

I have a string of hex values, e.g.,

04000000FF

You can see that the string is contained within this series of Byte elements:


What is an efficient way to solve this problem?

I think it can be done in XQuery 3 with a windowing clause, I am not sure whether you need a sliding or a tumbling window but along the lines of


let $req := '04000000FF'
let $len := string-length($req)
return
    head(
        for sliding window $w in /Bytes/Byte
        start $b1 at $s when $b1 = substring($req, 1, 2)
        end at $e when $e - $s + 1 = $len idiv 2
        where string-join($w) eq $req
        return $s - 1
    )

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.