Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Filename wildcard match

Reply
Thread Tools

Filename wildcard match

 
 
Ravi
Guest
Posts: n/a
 
      11-04-2003
My XML looks like:

<role type="Joker">
<Profile id="13">ABC_Organization</Profile>
</role>

My XSL looks like:

<xsl:variable name="prefix">profile_joker_</xsl:variable>
<xsl:variable name="vid"><xsl:value-of select="Profile/@id"/></xsl:variable>
<xsl:variable name="vname"><xsl:value-of select="Profile"/></xsl:variable>
<xsl:variable name="suffix">.xml</xsl:variable>


<xsl:variable name="tmp1"><xsl:value-of
select="concat($prefix,$vid)"/></xsl:variable>
<xsl:variable name="tmp2"><xsl:value-of
select="concat($tmp1,'.')"/></xsl:variable>
<xsl:variable name="tmp3"><xsl:value-of
select="concat($tmp2,$vname)"/></xsl:variable>
<xsl:variable name="tmp4"><xsl:value-of
select="concat($tmp3,$suffix)"/></xsl:variable>

<b>Entity: </b><a><xsl:attribute name="href"><xsl:value-of
select="$tmp4"/></xsl:attribute>
<xsl:value-of select="." /></a><br/>


What I am trying to do is to generate a filename from the element values
(the id Profile attribute and the Profile name) and then create a
hyperlink to that filename. The various files are uniquely identified by
the 'id'. The names of the files look like

profile_joker_<ProfileID>.<ProfileName>.xml

the problem is that the ProfileName may have aliases so if Bill and
William are aliases then

profile_joker_5.Bill.xml and profile_joker_5_William.xml

refer to the same file. However I have only the file
profile_joker_5.Bill.xml in my directory. So if I try to create a link
to profile_joker_5_William.xml it fails as there is no such file in the
directory (though the target really exists and is profile_joker_5_Bill.xml)

I am wondering if there is someway to find the filename in the current
directory which starts with profile_joker_5 and create a hyperlink to
that filename regardless of the profilename (i.e. base the target of the
link only on the ProfileID and make the Profilename a wildcard).

I am not sure how to proceed. Any suggestions will be highly welcome.

Thank you.











 
Reply With Quote
 
 
 
 
Patrick TJ McPhee
Guest
Posts: n/a
 
      11-04-2003
In article <bo8kua$dar$(E-Mail Removed)>,
Ravi <(E-Mail Removed)> wrote:

% <xsl:variable name="tmp1"><xsl:value-of
% select="concat($prefix,$vid)"/></xsl:variable>
% <xsl:variable name="tmp2"><xsl:value-of
% select="concat($tmp1,'.')"/></xsl:variable>
% <xsl:variable name="tmp3"><xsl:value-of
% select="concat($tmp2,$vname)"/></xsl:variable>
% <xsl:variable name="tmp4"><xsl:value-of
% select="concat($tmp3,$suffix)"/></xsl:variable>

You might be interested to know that concat can more than two
arguments. This could be done as

concat($prefix, $vid, '.', $vname, $suffix)

[...]

% I am wondering if there is someway to find the filename in the current
% directory which starts with profile_joker_5 and create a hyperlink to

Not with pure XSL. Depending on your XSLT processor, you might be
able to create an extension function which sorts it out for you.

My suggestion is to throw out the part of the name that's causing
trouble. i.e., rename the file on the server to profile_joker_5.xml
before you invoke XSLT. If that's not possible, my other suggestion
is to create links to all the possible names for the file, so you
don't have to deal with it in the XSLT file.

--

Patrick TJ McPhee
East York Canada
http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Wildcard String Comparisons: Set Pattern to a Wildcard Source chaoticcranium@gmail.com Python 7 10-05-2010 09:26 PM
wildcard match with list.index() Mr.SpOOn Python 4 11-19-2008 12:19 PM
[ ] (Wildcard - Character(s) to Match) ? Bruce Lawson ASP .Net 1 04-19-2006 11:48 AM
Re: partial / wildcard string match in 'in' and 'list.index()' Patrick Hall Python 2 06-04-2004 07:25 AM
partial / wildcard string match in 'in' and 'list.index()' Jon Perez Python 1 05-28-2004 06:47 AM



Advertisments