Filename wildcard match

Discussion in 'XML' started by Ravi, Nov 4, 2003.

  1. Ravi

    Ravi Guest

    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.
     
    Ravi, Nov 4, 2003
    #1
    1. Advertising

  2. In article <bo8kua$dar$>,
    Ravi <> 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
     
    Patrick TJ McPhee, Nov 4, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bruce Lawson

    [ ] (Wildcard - Character(s) to Match) ?

    Bruce Lawson, Apr 19, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    463
    Karl Seguin [MVP]
    Apr 19, 2006
  2. Jon Perez
    Replies:
    1
    Views:
    1,118
    Peter Otten
    May 28, 2004
  3. Patrick  Hall
    Replies:
    2
    Views:
    2,154
    Josiah Carlson
    Jun 4, 2004
  4. Mr.SpOOn

    wildcard match with list.index()

    Mr.SpOOn, Nov 10, 2008, in forum: Python
    Replies:
    4
    Views:
    307
    Sion Arrowsmith
    Nov 19, 2008
  5. Replies:
    7
    Views:
    885
Loading...

Share This Page