?
Solved

XSL urlencode type function?

Posted on 2003-03-18
8
Medium Priority
?
1,548 Views
Last Modified: 2013-11-19
Here's a piece of my code:
<td class="ObjCode">
   <xsl:element name = "div">
   <xsl:attribute name="class">popupLink</xsl:attribute>
   <xsl:attribute name="onclick">'return false;'</xsl:attribute>
   <xsl:attribute name="onmouseout">return !hideCurrentPopup();</xsl:attribute>

   <xsl:attribute name="onmouseover">
   <xsl:value-of select="concat('return !showPopup("nameFieldPopup", event,"',OBJ_DESC,'");')" />

   </xsl:attribute>
   <xsl:value-of select="OBJ"/></xsl:element>
</td>

The part of my code with the onmouseout and the javascript doesn't work right if there are " in the OBJ_DESC.  Is there a function in XML that would do something like URLEncode or something else to fix my problem?
0
Comment
Question by:daverx
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 1

Expert Comment

by:topcat_uk
ID: 8165018
daverx,

Check out this link.
http://www.biglist.com/lists/xsl-list/archives/200102/msg01607.html

It is for an apostrophe, but can be converted for rabbit ears "
0
 
LVL 9

Expert Comment

by:sparkplug
ID: 8172596
Check out my answer to the following question: http://www.experts-exchange.com/Web/Web_Languages/XML/Q_20554822.html

>S'Plug<
0
 
LVL 1

Expert Comment

by:xsl-lsx
ID: 8174381
<xsl:stylesheet>

<xsl:param name="q1">'</xsl:param>
<xsl:param name="q2">"</xsl:param>

...
<xsl:attribute name="onmouseover">
     <xsl:text>return !showPopup("nameFieldPopup", event,</xsl:text>
     <xsl:choose>
          <xsl:when test="contains(OBJ_DESC,$q1)">
               <xsl:value-of select="$q2"/>
               <xsl:value-of select="OBJ_DESC"/>
               <xsl:value-of select="$q2"/>
          </xsl:when>
          <xsl:when test="contains(OBJ_DESC,$q2)">
               <xsl:message terminate="yes">
                    has both " and ' within
                    <xsl:value-of select="OBJ_DESC"/>
               </xsl:message>
          </xsl:when>
          <xsl:otherwise>
               <xsl:value-of select="$q1"/>
               <xsl:value-of select="OBJ_DESC"/>
               <xsl:value-of select="$q1"/>
          </xsl:otherwise>
     </xsl:choose>
     <xsl:text>);</xsl:text>
</xsl:attribute>

</xsl:stylesheet>
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:daverx
ID: 8175782
I tried a couple of these examples out...
xsl-lsx, It looks like your example tests for ' and ", but doesn't do anything with it.
0
 

Author Comment

by:daverx
ID: 8175797
sparkplug,
I tried your example, but it didn't work...  I'm using MSXML...  If I keep everything the same, but add this:
    <msxsl:script language="javascript" implements-prefix="user">
    <![CDATA[
         function escapeQuotes(s)
         {
              return s.replace('\'', '\\\'');
         }
    ]]>
    </msxsl:script>

my stylesheet is no longer valid...  Here's my header (did I do something wrong?):
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882"
    xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
    xmlns:rs="urn:schemas-microsoft-com:rowset"
    xmlns:z="#RowsetSchema">

<xsl:output method="html"/>

    <msxsl:script language="javascript" implements-prefix="user">
    <![CDATA[
         function escapeQuotes(s)
         {
              return s.replace(/\'/g, '\\\'');
         }
    ]]>
    </msxsl:script>
0
 

Author Comment

by:daverx
ID: 8177184
topcat_uk,
that looks like it will work, but what do I do with it?  Do I create a separate file for escape-apo?  If so, how do I transform using it?

Thanks
0
 
LVL 9

Accepted Solution

by:
sparkplug earned 80 total points
ID: 8177957
You need some extra namespaces ('msxml' and 'user) in the stylesheet. e.g.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:user="http://mydomain/scripts">

It should then work...

>S'Plug<
0
 

Author Comment

by:daverx
ID: 8183124
awesome!  Thanks...
0

Featured Post

Tutorial: Introduction to Managing a Linux Server

In this tutorial on systemd, we will explore:
-OS/Distro Adoption
-chkconfig and Other Legacy Commands
-Summary and Key Commands

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question