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

Re: Selecting elements from source document based on

Subject: Re: Selecting elements from source document based on matches to a second document
From: "Liam R. E. Quin liam@xxxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 6 Mar 2023 05:36:29 -0000
Re:  Selecting elements from source document based on
On Mon, 2023-03-06 at 03:12 +0000, Trevor Nicholls
trevor@xxxxxxxxxxxxxxxxxx wrote:
>
>
> I would like to produce an output document which consists of a log
> containing all the log entries where at least one of the logentry
> paths
> matches a path in the checkpaths document, and where the paths for
> each
> output logentry are limited to the matching paths.

I'm thinking these are filesystem paths, not XPath expressions. So
here's some first thoughts:

So, given
<xsl:variable name-"paths-to-match" as="xs:string*"
  select="doc('checkpaths.xml')/checkpaths/path" />

you can use
/log/logentry[paths/path = $paths=to-match]

This is O(nB2) on the number of paths, so if you have a lot of paths in
the checkpaths document, you'll want to do something smarter probably,
but this is a start.

To get only the matching paths,

<xsl:apply-templates select="/log/logentry[paths/path = $paths=to-
match]"/>

then have an identity template (assuming XSLT 2; in XSLT 3 use
<xsl:mode on-no-match="shallow-copy"/> instead), and a template
<xsl:template match="path">
  <xsl:if test=". = $paths-to-match">
    <xsl:copy-of select="." />
  </xsl:if>
</xsl:template/>


liam

--
Liam Quin,B https://www.delightfulcomputing.com/
Available for XML/Document/Information Architecture/XSLT/
XSL/XQuery/Web/Text Processing/A11Y training, work & consulting.
Barefoot Web-slave, antique illustrations: B http://www.fromoldbooks.org

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.