|
Subject: Re: [xsl] 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 |
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 |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Selecting elements from s, Graydon graydon@xxxx | Thread | Re: [xsl] Selecting elements from s, Michael Kay mike@xxx |
| Re: [xsl] having a template remembe, Joel Kalvesmaki dire | Date | Re: [xsl] Selecting elements from s, Michael Kay mike@xxx |
| Month |