Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8280803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:48:43+00:00 2026-06-08T09:48:43+00:00

I am trying to pass a folder path from XSL to JavaScript. Function is

  • 0

I am trying to pass a folder path from XSL to JavaScript. Function is there in JavaScript and that function is getting called on onClick button of a HTML button in XSL. The path is like “C:\ABC\DEF\GH”. While putting an alert I saw that path is getting sent like: “CABCDEFGH”. All the slashes are removed. Even I removed the function call on OnClick event and just put an alert there with hard coded path, still same thing. It removed all the slashes.

<img class="viewcls" src="images/copy.jpg" title="Copy Profile" onclick="fnCopyProfile({$CurlDPID},'{@T}','{SOURCE/I/@DP}')"/>

Here last parameter in fnCopyProfile function’s last parameter is an XPath whose value will be a file path like C:\ABC\DEF\GH. In JS its coming without slashes.

Even if I put alert in XSL itself like:

<img class="viewcls" src="images/copy.jpg" title="Copy Profile" onclick="alert('{SOURCE/I/@DP}');fnCopyProfile({$CurlDPID},'{@T}','{SOURCE/I/@DP}')"/>

then also it is showing path without slashes.

However if I am doing this:

<xsl:value-of select="SOURCE/I/@DP" />

then it is showing path with slashes, but like this we can’t pass value into JS, I guess.

How to send the exact path with slashes to JavaScript.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T09:48:45+00:00Added an answer on June 8, 2026 at 9:48 am

    Make sure you are escaping all \ characters. When used in a JavaScript string, \ is used to denote a control character (e.g. \n for a newline).

    So what you need to do is replace all \ characters with \\.

    I do not know how you would do that with the inline variables you’re using (hopefully Dimitre will show us).

    However, you could do it like this…

    <img class="viewcls" src="images/copy.jpg" title="Copy Profile">
      <xsl:attribute name="onclick">fnCopyProfile(<xsl:value-of select="$CurlDPID"/>,'<xsl:value-of select="@T"/>','<xsl:value-of select="translate(SOURCE/I/@DP,'\','\\')"/>');</xsl:attribute>
    </img>
    

    UPDATE

    The above cannot work, as translate works by replacing a single character with a single character.

    If you are using XSLT 2.0, then I believe you can do this (w3.org reference)…

    <xsl:value-of select="replace(SOURCE/I/@DP,'\\','\\\\'")/>
    

    The reason for the \\ is that the 2nd and 3rd parameters are regular expressions, so need the \ escaping.

    If you are using XSLT 1.0, then I have just found this post via Google which provides a “search and replace” template

    <xsl:template name="string-replace-all">
      <xsl:param name="text" />
      <xsl:param name="replace" />
      <xsl:param name="by" />
      <xsl:choose>
        <xsl:when test="contains($text, $replace)">
          <xsl:value-of select="substring-before($text,$replace)" />
          <xsl:value-of select="$by" />
          <xsl:call-template name="string-replace-all">
            <xsl:with-param name="text"
            select="substring-after($text,$replace)" />
            <xsl:with-param name="replace" select="$replace" />
            <xsl:with-param name="by" select="$by" />
          </xsl:call-template>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="$text" />
        </xsl:otherwise>
      </xsl:choose>
    </xsl:template>
    

    Which you should be able to call like this (I have put it into a variable to make it clearer)…

    <xsl:variable name="mypath">
      <xsl:call-template name="string-replace-all">
        <xsl:with-param name="text"><xsl:value-of select="SOURCE/I/@DP"/>
        <xsl:with-param name="replace">\</xsl:with-param>
        <xsl:with-param name="by">\\</xsl:with-param>
      </xsl:call-template>
    </xsl:variable>
    <img class="viewcls" src="images/copy.jpg" title="Copy Profile">
      <xsl:attribute name="onclick">fnCopyProfile(<xsl:value-of select="$CurlDPID"/>,'<xsl:value-of select="@T"/>','<xsl:value-of select="$mypath"/>');</xsl:attribute>
    </img>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to pass a .xml file from my res folder to an
i'm trying to pass on sdcard a pdf from my raw folder to open
Trying to pass in a user supplied string which has a path to the
Trying to pass a string argument to a function, which will then be used
im trying to pass two parameters to a function, i being an int value
I'm trying to pass elements from a list to a for loop and of
I'm trying to post a username & password from an HTML form to a
i'm trying to create an LLVM pass using the guide at http://llvm.org/releases/2.9/docs/WritingAnLLVMPass.html but i'm
I'm trying to create an FTP script that will copy a local folder structure
I have been trying for hours to pass a resource from one Activity to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.