This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Continued problems with XSLT (Ser
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: [xsl] Continued problems with XSLT (Ser
- From: "Serdar Kilic" <serdar at skilic dot com>
- Date: Sun, 6 May 2001 22:38:16 +1000
- Reply-To: xsl-list at lists dot mulberrytech dot com
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&CAT2=Bridges/Routers&CAT3=NORTEL NETWORKS">linkit</a>
</someURLFile>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list