Filename wildcard match

R

Ravi

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.
 
P

Patrick TJ McPhee

% <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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top