xsl-list
[Top] [All Lists]

Re: [xsl] another beginner question - strip directory info from variable

2018-10-15 07:41:58
Hi Dave, Try this using xsl:value-of to bring the strings together as one and 
use them in xsl:analyse-srting to create a group for each item you want.
<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
xmlns:xs="http://www.w3.org/2001/XMLSchema"; exclude-result-prefixes="xs" 
version="2.0"> <xsl:param name="string-1" 
as="xs:string">dir1/jpg001.jpg</xsl:param> <xsl:param name="string-2" 
as="xs:string">dir2/jpg002.jpg</xsl:param> <xsl:param name="string-3" 
as="xs:string">dir3/jpg003.jpg</xsl:param> <xsl:variable name="string" 
select="$string-1, $string-2, $string-3"/> <xsl:variable name="string-all"> 
<xsl:value-of select="$string"/> </xsl:variable> <xsl:template name="main"> 
<main> <xsl:analyze-string select="$string-all" 
regex="(([a-z0-9]*)/([a-z0-9\.]*) ?)"> <xsl:matching-substring> <group> <path> 
<xsl:value-of select="regex-group(2)"/> </path> <file> <xsl:value-of 
select="regex-group(3)"/> </file> </group> </xsl:matching-substring> 
</xsl:analyze-string> </main> </xsl:template></xsl:stylesheet>
Terry BadgerXML DeveloperRochester, NY(585)-781-0789



 
 
 On Sunday, October 14, 2018, 2:43:17 PM EDT, B Tommie Usdin 
btusdin(_at_)mulberrytech(_dot_)com 
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote: 





Hi Dave —

It looks like the list is being helpful to you. There is something you could do 
in the future to be helpful to the list: focus your subject lines on the topic 
of the question. In this case, "strip directory info from variable" would have 
been a far better subject line than "another beginner question - strip 
directory info from variable”. This is because many people refer to the list 
archives and third-party list archives by scanning subject lines to find 
discussions that may help them. By making the subject line about you and not 
about your topic you make reuse of the discussion much more difficult. 

It seems to me that many people may have your question and this discussion 
would be helpful to them, too. 

Thanks for making a moment to think about subject lines before your future 
posts to XSL-list. 

— Tommie 


On Oct 13, 2018, at 9:49 PM, Dave Lang emaildavelang(_at_)gmail(_dot_)com 
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:

Hi again everyone - back with another beginner question.

I'm working in Oxygen and am using Saxon.

I'm searching through a bunch of xml files in search of jpg names. I'm 
creating variables as follows:

<xsl:variable name="allxml" 
select="collection('..//xml/?select=*.xml;recurse=yes')"/>
<xsl:variable name="jpgs" select="$allxml//element/@n"/>

$jpgs looks like:

dir1/jpg001.jpg dir1/jpg002.jpg dir1/jpg003.jpg

etc.

I want to strip away the dir info, but am having a hard time. I've tried 
using tokenize and substring-after but both return similar errors.

"A sequence of more than one item is not allowed as the first argument of 
fn:tokenize() ("dir1/jpg001.jpg", "dir1/jpg002.jpg")."

Because I don't know what I'm doing, I don't know what I'm doing wrong. :)

Can anyone help me figure out how to solve this problem?

thanks!
dave


====================================================================== 
B. Tommie Usdin                        
mailto:btusdin(_at_)mulberrytech(_dot_)com
Mulberry Technologies, Inc.              https://www.mulberrytech.com
17 West Jefferson Street                          Phone: 301/315-9631 
Suite 207                                    Direct Line: 301/315-9634 
Rockville, MD  20850                                Fax: 301/315-8285 
----------------------------------------------------------------------
Mulberry Technologies: A Consultancy Specializing in XML and SGML              

======================================================================
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--
<Prev in Thread] Current Thread [Next in Thread>