RE: XML\XSL Transformation

Here's the MS Active Server Pages (ASP) scripting I use for server-side transforms, pared down to the core of it.  ASP is the predecessor to .NET, so some of these server objects and methods and attributes may carry-over there.  No claim the below code is flawless or ideal--I had to wrestle with ASP object naming/versioning quite a bit to get the results I wanted.  I really liked Shaun's draft, thanks for this work!  --Dave Porter

'**************** Create source and destination XMLDOM objects **********
set objXML = Server.CreateObject("Microsoft.XMLDOM")
set objOutput = Server.CreateObject("Microsoft.XMLDOM")

'**************** Load XML file for transform *******************
objXML.load(Server.MapPath("foo.xml"))

'****************** Load stylesheet ****************
set objXSL = Server.CreateObject("MSXML2.FreeThreadedDOMDocument")
objXSL.load(Server.MapPath("foo.xsl"))

'****************** Create transform processor
set xslTemplate = Server.CreateObject("MSXML2.XSLTemplate")
xslTemplate.stylesheet = objXSL
set xslProc = xslTemplate.createProcessor()

'****************** Do the transform
xslProc.input = objXML
xslProc.output = objOutput
xslProc.transform()

'****************** Write transformed result to client
Response.Write(objOutput.xml)



________________________________
From: public-svg-ig-request@w3.org [mailto:public-svg-ig-request@w3.org] On Behalf Of Dailey, David P.
Sent: Monday, December 14, 2009 5:39 AM
To: mcampbell@svgsystems.net
Cc: SVG IG List; Shaun Roe
Subject: RE: XML\XSL Transformation

Hello -  and welcome to the SVGIG and my apologies for the delay in my response - it is that time of the semester at my University and I am completely swamped with end-of-the-semester stuff.

Thanks for your recommendation - Originally, I had rather steered clear of all the server-side technologies, in part because there are so many of them and in part because I know so little about the topic. However, given that we're now planning a document with many contributors, this makes sense to me.

Helder's recommendation of client-side stuff and yours of something in the .Net world both seem important.

Cheers
David

From: mcampbell@svgsystems.net [mailto:mcampbell@svgsystems.net]
Sent: Tuesday, December 08, 2009 1:34 PM
To: Dailey, David P.
Subject: XML\XSL Transformation

Hi David,

I am new to the SVG Interest Group; I thought I would send my thoughts on Shaun's page to you first, if you think it has merit I or you can forward the email to the full group.

Shaun mentioned Oracle which is a proprietary database and it opens the door to other transformation techniques that are used with those products.   Normally we draw a line between proprietary and non-proprietary databases but Oracle's purchase of MySql creates questions about how we look at these databases.

I would like to request that one of the Sun transformation techniques be used in an example for Java Server Page (JSP).  I tend to use Xerces in all of my web pages, but Saxson or Xalan would be acceptable.   I could argue that we also need to have an example of a Microsoft .NET transformation to make the coverage of transformation topic complete.

If you think that the information above is worth passing to the SIG group, please let me know or forward the email to them.  I have attached the logic for a Xerces JSP transformation below.

Xerces JSP Transformation
<%@ page language="java" contentType="text/html" %><%@ page pageEncoding="UTF-8"%><%@ page import="javax.xml.transform.*"%><%@ page import="javax.xml.transform.stream.*"%><%! String FS = System.getProperty("file.separator"); %><%String xmlFile = request.getParameter("webpage.xml");String xslFile = request.getParameter("webpage.xsl");String ctx = getServletContext().getRealPath("") + FS;xslFile = ctx + xslFile;xmlFile = ctx + xmlFile;TransformerFactory tFactory = TransformerFactory.newInstance();Transformer transformer = tFactory.newTransformer(new StreamSource(xslFile));transformer.transform(new StreamSource(xmlFile), new StreamResult(out));
%>

Received on Monday, 14 December 2009 16:39:42 UTC