[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Continued problems with XSLT (Ser

Subject: Continued problems with XSLT (Ser
From: "Serdar Kilic" <serdar@xxxxxxxxxx>
Date: Sun, 6 May 2001 22:38:16 +1000
xsl server.urlencode
Hi All,
  Chris Bayes sometime ago kindly took the time to offer a solution to use
the ASP Server.URLEncode method in XSL (see:
http://www.biglist.com/lists/xsl-list/archives/200104/msg00849.html) this
really put me on the right path, but I'm still having problems with this.

The link that is getting generated from the code is:
<a
href="http%3A%2F%2Flocalhost%3A81%2Fcatalog%5Fsub%5F2%2Easp%3FCAT1%3DNetwork
ing+Hardware%26CAT2%3DBridges%2FRouters%26CAT3%3DNORTEL+NETWORKS"
xmlns:ServerFuncs="urn:Server-urlencode">linkit</a>

What I need it to be is:
<a href="
http://bsd06:81/catalog_sub_2.asp?CAT1=Networking%20Hardware&CAT2=Bridges/Ro
uters&CAT3=NORTEL%20NETWORKS
">linkit<a>
(minus the wrapping, off course)

I'd like to know:
  a) how to get this to work that way I thought it would
  b) OT: what is the VBScript equivalent of the "var myObject = new
Object();" line
  c) and finally, what actually addObject does? (MSXML4 docs says "Adds
objects into a style sheet".. yeah, thanks.)

Sorry for the longish email.. Many thanks in advance,
Serdar

-------------------- The ASP File --------------------------------------
<%@ LANGUAGE="JSCRIPT" %>
<%
 var tem = new ActiveXObject("MSXML2.XSLTemplate");
 var xsl = new ActiveXObject("MSXML2.FreeThreadedDOMDocument");
 var xml = new ActiveXObject("MSXML2.FreeThreadedDOMDocument");

 xsl.async = false;
 xml.async = false;

 xml.load(Server.MapPath("urlEnc.xml"));
 xsl.load(Server.MapPath("urlEnc.xslt"));


 tem.stylesheet = xsl;
 var proc = tem.createProcessor();

 var myObject = new Object();
 myObject.urlencode = function(par){return Server.URLEncode(par);};
 proc.addObject(myObject, "urn:Server-urlencode");
 proc.input = xml;
 proc.transform();
 Response.write(proc.output);
%>

----------------------- The XSLT File --------------------------------------
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 version="1.0"
 xmlns:ServerFuncs="urn:Server-urlencode">

 <xsl:output
  omit-xml-declaration = "yes"
  method = "html" />

 <xsl:template match="/" >
  <xsl:apply-templates />
 </xsl:template>


 <xsl:template match="a">
  <a>
   <xsl:attribute name="href"><xsl:value-of
select="ServerFuncs:urlencode(string(@href))" /></xsl:attribute>
   <xsl:value-of select="text()" />
  </a>
 </xsl:template>
</xsl:stylesheet>

------------------- Sample XML
ile  ----------------------------------------
<someURLFile>
 <a href="http://localhost:81/catalog_sub_2.asp?CAT1=Networking
Hardware&amp;CAT2=Bridges/Routers&amp;CAT3=NORTEL NETWORKS">linkit</a>
</someURLFile>




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.