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

fixing XSL search using values from a variable against

Subject: fixing XSL search using values from a variable against multiple XML files
From: "Dave Lang emaildavelang@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 4 Oct 2018 01:15:58 -0000
 fixing XSL search using values from a variable against
Hi this is my first post here - looking for help - apologies if there's something I've overlooked!

I have a tokenized variable that contains list of filenames from a .txt of a directory listing. I want to look for those filenames in a number of xml files in a number of subdirectories. If the filename is found, I want to output that "filename" was found in "xmlfile".

There are a lot of xml directories and they are not static. Same with xml files. The filenames are not tagged in the xml, so I'm just looking for their plain text occurence in the file.

Any help would be appreciated.

to make the examples easier - I want to use

$filenames_to_find (tokenized list of filenames from a .txt directory listing)

to search against

dir1/*.xml
dir2/*.xml
with the output being

filename was found in xmlfilename

I'm using an academic version of Oxygen XML so I think I have Saxon through that and I have the standalone Saxon file for running this from the command line.

I've gotten this far, but it doesn't work. I know it's broken, but I don't know how to fix it!

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
B B B  xmlns:xs="http://www.w3.org/2001/XMLSchema"
B B B  xmlns:h="http://www.w3.org/1999/xhtml"
B B B  exclude-result-prefixes="xs"
B B B  version="3.0"
B B B  expand-text="yes"
B B B  >

B B B <xsl:variable name="filenames_from_directory_listing" as="xs:string" select="unparsed-text('filenames_from_directory_listing.txt')"/>
B B B <xsl:variable name="filenames_to_find" select="tokenize($filenames_from_directory_listing, '\s+')"/>


B B B  <xsl:template match="/">
B B B B B B B  <xsl:for-each select="collection('.?select=*.xml;recurse=yes')"/>
B B B B B B B B B B B  <xsl:variable name="xml_filenames" select="."/>
B B B B B B B B B B B B B B B  <xsl:for-each select="$filenames_to_find">
B B B B B B B B B B B B B B B B B B B  <xsl:if test="(contains($t, .))">
<xsl:message>{document-uri($xml_filenames)} contains {.}</xsl:message>
B B B B B B B B B B B B B B B B B B B  </xsl:if>
B B B B B B B B B B B B B B B  </xsl:for-each>
B B B  </xsl:template>
</xsl:stylesheet>

Any suggestions? Clearly I am an XSL novice. Thanks for your patience.

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.