Subject: Re: [xsl] bat file creation based on xsl /xml From: "Syd Bauman s.bauman@xxxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Mon, 14 Jan 2019 21:40:38 -0000 |
Michele may have hit the nail on the head, here, but some other issues are raised. 0) I don't think the @version and @indent attributes of <xsl:output> make much sense when method=text. (And I'll ask that wiser folks than me post a correction if I'm wrong on that.) 1) The OP's XSLT is not well-formed. (There is an extraneous end-tag for <xsl:variable> lying around.) 2) I'm not 100% sure what `dir` does in Windows, but I'll bet it would list the files that end in '.xml'. This program also tries to *read* and *parse* those files. So whereas `dir` will happy list a file that is not really XML so long as it has a .xml extension, this program will entirely fail if any one of the files found in the same directory as the XSLT program ends in '.xml' but is not well-formed XML. (Which may, of course, be the desired behavior. In which case one might be better off using `xmlwf`. :-) 3) This program spits out the URL of each selected file, not its name (or path & name). On my (GNU/Linux system running Saxon 9 HE) that means that each file's output line will start with "file:". And it also has implications for character escaping (i.e., what happens if a space or solidus or whatever is in the file's name -- here you get %-sign escaping, but I doubt `dir` does that). 4) This program reads in an input file, but then summarily ignores it when choosing the directory to list. I can't help but wonder if OP wants a list of the .xml files in the same directory as the XSLT program (which is what this program gives me when I run it w/ Saxon), or would prefer a list of the .xml files in the same directory as the input document. ========= <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="#all"> <xsl:output method="text" encoding="UTF-8"/> <xsl:template match="/"> <xsl:text>
----- XSLT program file's directory -----</xsl:text> <xsl:for-each select="collection('.?select=*.xml')"> <xsl:text> </xsl:text> <xsl:value-of select="document-uri(.)"/> </xsl:for-each> <xsl:text>

----- XML file's directory -----</xsl:text> <xsl:for-each select="collection( concat( replace( base-uri(/), '/[^/]+$',''),'?select=*.xml'))"> <xsl:text> </xsl:text> <xsl:value-of select="document-uri(.)"/> </xsl:for-each> <xsl:text>
</xsl:text> </xsl:template> </xsl:stylesheet> > If I read this right, it looks like you just want to generate a > list of the XML files in a directory, is that correct? If youbre in > a windows enviroment the bdirb command will do what you want.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] bat file creation based o, Michele R Combs mrro | Thread | Re: [xsl] bat file creation based o, Michele R Combs mrro |
Re: [xsl] bat file creation based o, Michele R Combs mrro | Date | Re: [xsl] bat file creation based o, Michele R Combs mrro |
Month |