Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1551
  • Last Modified:

XSL urlencode type function?

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
daverx
Asked:
daverx
1 Solution
 
topcat_ukCommented:
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
 
sparkplugCommented:
Check out my answer to the following question: http://www.experts-exchange.com/Web/Web_Languages/XML/Q_20554822.html

>S'Plug<
0
 
xsl-lsxCommented:
<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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
daverxAuthor Commented:
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
 
daverxAuthor Commented:
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
 
daverxAuthor Commented:
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
 
sparkplugCommented:
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
 
daverxAuthor Commented:
awesome!  Thanks...
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now