How to apply XSLT to XML on the server in JSP or ASP without DOM?
-
Hi All! Basically all my question is in title: how to apply XSLT to XML on the server in JSP or ASP without DOM? I have data.xml file and style.xsl file. If user access my page (either JSP or ASP or doesn't matter) with browser that supports _full_ XML + XSLT, than I just send to user file data.xml, user's browser processes it, finds reference to style.xlt, retrieves it and process both to the end result. If user uses outdated browser (no XML/XSLT or old versions), I do the same on the server. Example of such script on server side: <% dim xmlMenu dim xslMenu 'Get the source XML set xmlMenu = server.CreateObject("Msxml2.DOMDocument.4.0") xmlMenu.async = false xmlMenu.load server.MapPath("data.xml") 'Get the XSLT to transform the XML set xslMenu = server.CreateObject("Msxml2.DOMDocument.4.0") xslMenu.async = false xslMenu.load server.MapPath("style.xsl") 'Transform the source XML using XSLT Response.Write xmlMenu.transformNode(xslMenu) set xmlMenu = nothing set xslMenu = nothing %> I want to have exactly the same but without DOM, because it takes a lot of memory (well, I personally didn't notice that. The above script processed 8MB file with 16,000+ nodes in 25 sec on my development PC (256MB Ram, P4 1.4, Personal Web Server + MSXML) to table-like HTML. But people say 4MB file takes > 100MB of RAM and is slow. May be they mean "stress testing"?). I cannot use anything except ASP or JSP - no COM, C++, ActiveX or other stuff. Not that _I_ don't want to, but that's an in-house rules :((((((( Thanks a lot for answer! SY- Kosta.
-
Hi All! Basically all my question is in title: how to apply XSLT to XML on the server in JSP or ASP without DOM? I have data.xml file and style.xsl file. If user access my page (either JSP or ASP or doesn't matter) with browser that supports _full_ XML + XSLT, than I just send to user file data.xml, user's browser processes it, finds reference to style.xlt, retrieves it and process both to the end result. If user uses outdated browser (no XML/XSLT or old versions), I do the same on the server. Example of such script on server side: <% dim xmlMenu dim xslMenu 'Get the source XML set xmlMenu = server.CreateObject("Msxml2.DOMDocument.4.0") xmlMenu.async = false xmlMenu.load server.MapPath("data.xml") 'Get the XSLT to transform the XML set xslMenu = server.CreateObject("Msxml2.DOMDocument.4.0") xslMenu.async = false xslMenu.load server.MapPath("style.xsl") 'Transform the source XML using XSLT Response.Write xmlMenu.transformNode(xslMenu) set xmlMenu = nothing set xslMenu = nothing %> I want to have exactly the same but without DOM, because it takes a lot of memory (well, I personally didn't notice that. The above script processed 8MB file with 16,000+ nodes in 25 sec on my development PC (256MB Ram, P4 1.4, Personal Web Server + MSXML) to table-like HTML. But people say 4MB file takes > 100MB of RAM and is slow. May be they mean "stress testing"?). I cannot use anything except ASP or JSP - no COM, C++, ActiveX or other stuff. Not that _I_ don't want to, but that's an in-house rules :((((((( Thanks a lot for answer! SY- Kosta.
You want to apply XSL to XML, without an XSL parser of any kind ? How, exactly ? I don't think it's possible unless you write your own, and if your management insists you do it this way, I suggest you look for another job, and use the word 'morons' liberally in your resignation letter. I'm sorry, I don't see how it can be done. Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002 Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002 Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
-
You want to apply XSL to XML, without an XSL parser of any kind ? How, exactly ? I don't think it's possible unless you write your own, and if your management insists you do it this way, I suggest you look for another job, and use the word 'morons' liberally in your resignation letter. I'm sorry, I don't see how it can be done. Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002 Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002 Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
Well, I could use MSXML. In fact, posted ASP script uses MSXML (I corrected my original question by adding some performance test numbers). But, if I right understand (may be I'm wrong here? - I'm complete novice with XML and ASP :)), that script creates DOM object by calling "CreateObject" method. And I've seen posts in this forum that DOM is slow and takes a lot of memory. I found out that SAXON might be solution, but again - I cannot use any 3rd party software :(. I try to rephrase queastion - is it any way to run XSLT processor withing ASP or JSP without using "CreateObject" method? And by the way - they are not morons. They are US government :). Well, may be they are after all :) Tssss.
-
Well, I could use MSXML. In fact, posted ASP script uses MSXML (I corrected my original question by adding some performance test numbers). But, if I right understand (may be I'm wrong here? - I'm complete novice with XML and ASP :)), that script creates DOM object by calling "CreateObject" method. And I've seen posts in this forum that DOM is slow and takes a lot of memory. I found out that SAXON might be solution, but again - I cannot use any 3rd party software :(. I try to rephrase queastion - is it any way to run XSLT processor withing ASP or JSP without using "CreateObject" method? And by the way - they are not morons. They are US government :). Well, may be they are after all :) Tssss.
Kosta Cherry wrote: Well, I could use MSXML. MSXML is a COM object, it requires CreateObject and is based on the DOM. Kosta Cherry wrote: that script creates DOM object by calling "CreateObject" method. Correct. Kosta Cherry wrote: And I've seen posts in this forum that DOM is slow and takes a lot of memory. Every idiot has an opinion. Yes, DOM is bigger than SAX, but I don't see what option you have. I dunno if there are SAX XSL processors, but either way, you need a processor to do the processing. Kosta Cherry wrote: I try to rephrase queastion - is it any way to run XSLT processor withing ASP or JSP without using "CreateObject" method? Yes, write one yourself in ASP. Kosta Cherry wrote: And by the way - they are not morons. They are US government LOL - now THAT speaks for itself. :-) Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002 Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002 Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
-
Well, I could use MSXML. In fact, posted ASP script uses MSXML (I corrected my original question by adding some performance test numbers). But, if I right understand (may be I'm wrong here? - I'm complete novice with XML and ASP :)), that script creates DOM object by calling "CreateObject" method. And I've seen posts in this forum that DOM is slow and takes a lot of memory. I found out that SAXON might be solution, but again - I cannot use any 3rd party software :(. I try to rephrase queastion - is it any way to run XSLT processor withing ASP or JSP without using "CreateObject" method? And by the way - they are not morons. They are US government :). Well, may be they are after all :) Tssss.
Kosta Cherry wrote: is it any way to run XSLT processor withing ASP or JSP without using "CreateObject" method? Yes, Look at the Apache XML code XALAN http://xml.apache.org/. For large processing it does not require the resources for a DOM implementation. That is the real issue (IMO), if you are having to go to disk to handle a DOM implementation and not for a SAX. If you know you have the resources I find that DOM works just as well. A warning though, The processing can be different between the two. A XSL file for one will not always give the same results when applied to the other. If that is not acceptable. MSXML does have a SAX implementation. See http://www.perfectxml.com/msxmlSAX.asp Kosta Cherry wrote: I cannot use any 3rd party software . I have always been intrigued by this statement. MSXML is not 3rd party but XALAN / Xerces is, but the Apache code I can down load and look through. "I will find a new sig someday."
-
Kosta Cherry wrote: Well, I could use MSXML. MSXML is a COM object, it requires CreateObject and is based on the DOM. Kosta Cherry wrote: that script creates DOM object by calling "CreateObject" method. Correct. Kosta Cherry wrote: And I've seen posts in this forum that DOM is slow and takes a lot of memory. Every idiot has an opinion. Yes, DOM is bigger than SAX, but I don't see what option you have. I dunno if there are SAX XSL processors, but either way, you need a processor to do the processing. Kosta Cherry wrote: I try to rephrase queastion - is it any way to run XSLT processor withing ASP or JSP without using "CreateObject" method? Yes, write one yourself in ASP. Kosta Cherry wrote: And by the way - they are not morons. They are US government LOL - now THAT speaks for itself. :-) Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002 Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002 Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
Kosta Cherry wrote: And by the way - they are not morons. They are US government Christian Graus wrote: LOL - now THAT speaks for itself. Yes, To be honest I do not think the US is unique. I do have experience working with the Australian government also.:) "I will find a new sig someday."
-
Hi All! Basically all my question is in title: how to apply XSLT to XML on the server in JSP or ASP without DOM? I have data.xml file and style.xsl file. If user access my page (either JSP or ASP or doesn't matter) with browser that supports _full_ XML + XSLT, than I just send to user file data.xml, user's browser processes it, finds reference to style.xlt, retrieves it and process both to the end result. If user uses outdated browser (no XML/XSLT or old versions), I do the same on the server. Example of such script on server side: <% dim xmlMenu dim xslMenu 'Get the source XML set xmlMenu = server.CreateObject("Msxml2.DOMDocument.4.0") xmlMenu.async = false xmlMenu.load server.MapPath("data.xml") 'Get the XSLT to transform the XML set xslMenu = server.CreateObject("Msxml2.DOMDocument.4.0") xslMenu.async = false xslMenu.load server.MapPath("style.xsl") 'Transform the source XML using XSLT Response.Write xmlMenu.transformNode(xslMenu) set xmlMenu = nothing set xslMenu = nothing %> I want to have exactly the same but without DOM, because it takes a lot of memory (well, I personally didn't notice that. The above script processed 8MB file with 16,000+ nodes in 25 sec on my development PC (256MB Ram, P4 1.4, Personal Web Server + MSXML) to table-like HTML. But people say 4MB file takes > 100MB of RAM and is slow. May be they mean "stress testing"?). I cannot use anything except ASP or JSP - no COM, C++, ActiveX or other stuff. Not that _I_ don't want to, but that's an in-house rules :((((((( Thanks a lot for answer! SY- Kosta.
i would transfrom the xml - and output it to a text file or session variable. then when you get a request check the date of the xslt & xml file - if either are new regenerate the output. otherwise just return the file/session variable as the output.
"When the only tool you have is a hammer, a sore thumb you will have."
-
Hi All! Basically all my question is in title: how to apply XSLT to XML on the server in JSP or ASP without DOM? I have data.xml file and style.xsl file. If user access my page (either JSP or ASP or doesn't matter) with browser that supports _full_ XML + XSLT, than I just send to user file data.xml, user's browser processes it, finds reference to style.xlt, retrieves it and process both to the end result. If user uses outdated browser (no XML/XSLT or old versions), I do the same on the server. Example of such script on server side: <% dim xmlMenu dim xslMenu 'Get the source XML set xmlMenu = server.CreateObject("Msxml2.DOMDocument.4.0") xmlMenu.async = false xmlMenu.load server.MapPath("data.xml") 'Get the XSLT to transform the XML set xslMenu = server.CreateObject("Msxml2.DOMDocument.4.0") xslMenu.async = false xslMenu.load server.MapPath("style.xsl") 'Transform the source XML using XSLT Response.Write xmlMenu.transformNode(xslMenu) set xmlMenu = nothing set xslMenu = nothing %> I want to have exactly the same but without DOM, because it takes a lot of memory (well, I personally didn't notice that. The above script processed 8MB file with 16,000+ nodes in 25 sec on my development PC (256MB Ram, P4 1.4, Personal Web Server + MSXML) to table-like HTML. But people say 4MB file takes > 100MB of RAM and is slow. May be they mean "stress testing"?). I cannot use anything except ASP or JSP - no COM, C++, ActiveX or other stuff. Not that _I_ don't want to, but that's an in-house rules :((((((( Thanks a lot for answer! SY- Kosta.
OK, I finally found answer (sort of) to my question and it is "SAX Parser with ASP" article at http://www.experts-exchange.com/Web/Web\_Languages/XML/Q\_20150239.html Here is copy of code from there (in case anyone interested): <%Response.ContentType = "text/xml" Dim generator, ch ' instantiate XML generator class Set generator = Server.CreateObject("XMLFilesVBSAX.CGenerator") Set ch = Server.CreateObject("XMLFilesVBSAX.CSerializer") ch.RegisterOutputStream Response generator.generateXML ch %> Then -> <%Response.ContentType = "text/xml" Dim reader, ch ' instantiate XMLReader class Set reader = Server.CreateObject("MSXML2.VBSAXXMLReader.3.0") ' instantiate class that implements IVBSAXContentHandler Set ch = Server.CreateObject("XMLFilesVBSAX.CSerializer") ch.RegisterOutputStream Response ' turn off namespace prefixes reader.putFeature "http://xml.org/sax/features/namespace-prefixes", False ' register ContentHandler implementation Set reader.contentHandler = ch ' begin processing document reader.parseURL "file://c:\temp\whatever.xml" %> And lastly -> <% Dim reader, ch ' instantiate XMLReader class Set reader = Server.CreateObject("MSXML2.VBSAXXMLReader.3.0") ' instantiate class that implements IVBSAXContentHandler Set ch = Server.CreateObject("XMLFilesVBSAX.CInvoice2HTML") ' turn off namespace prefixes reader.putFeature "http://xml.org/sax/features/namespace-prefixes", False ' register ContentHandler implementation Set reader.contentHandler = ch ' begin processing document reader.parseURL "file://c:\temp\whatever.xml" %> Thanks for everybody!
-
OK, I finally found answer (sort of) to my question and it is "SAX Parser with ASP" article at http://www.experts-exchange.com/Web/Web\_Languages/XML/Q\_20150239.html Here is copy of code from there (in case anyone interested): <%Response.ContentType = "text/xml" Dim generator, ch ' instantiate XML generator class Set generator = Server.CreateObject("XMLFilesVBSAX.CGenerator") Set ch = Server.CreateObject("XMLFilesVBSAX.CSerializer") ch.RegisterOutputStream Response generator.generateXML ch %> Then -> <%Response.ContentType = "text/xml" Dim reader, ch ' instantiate XMLReader class Set reader = Server.CreateObject("MSXML2.VBSAXXMLReader.3.0") ' instantiate class that implements IVBSAXContentHandler Set ch = Server.CreateObject("XMLFilesVBSAX.CSerializer") ch.RegisterOutputStream Response ' turn off namespace prefixes reader.putFeature "http://xml.org/sax/features/namespace-prefixes", False ' register ContentHandler implementation Set reader.contentHandler = ch ' begin processing document reader.parseURL "file://c:\temp\whatever.xml" %> And lastly -> <% Dim reader, ch ' instantiate XMLReader class Set reader = Server.CreateObject("MSXML2.VBSAXXMLReader.3.0") ' instantiate class that implements IVBSAXContentHandler Set ch = Server.CreateObject("XMLFilesVBSAX.CInvoice2HTML") ' turn off namespace prefixes reader.putFeature "http://xml.org/sax/features/namespace-prefixes", False ' register ContentHandler implementation Set reader.contentHandler = ch ' begin processing document reader.parseURL "file://c:\temp\whatever.xml" %> Thanks for everybody!
Thanks for this info. I've never used SAX, and I did not know it could parse XSL. However, I note you've had to call 'CreateObject', I thought you were not allowed to ? :P Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002 Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002 Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
-
Thanks for this info. I've never used SAX, and I did not know it could parse XSL. However, I note you've had to call 'CreateObject', I thought you were not allowed to ? :P Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002 Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002 Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
:) I am not allowed to create my own objects, but I could call existing ones :) As far as I understand, government want to have all their projects to be written in one - two languages, so they could get rid of contractors after project finished and hire some idiots fresh from college to support all this trash :)
-
:) I am not allowed to create my own objects, but I could call existing ones :) As far as I understand, government want to have all their projects to be written in one - two languages, so they could get rid of contractors after project finished and hire some idiots fresh from college to support all this trash :)
Kosta Cherry wrote: I am not allowed to create my own objects, but I could call existing ones Fair enough. In that case, I don't understand why you could not use the DOM, although it's certainly the case that SAX is more lightweight. I'm glad you asked this, I will use SAX myself in future in places where I've used to DOM. Kosta Cherry wrote: As far as I understand, government want to have all their projects to be written in one - two languages, so they could get rid of contractors after project finished and hire some idiots fresh from college to support all this trash *grin* I see. In that case, I can see why 'no C++' was a requirement. Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002 Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002 Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002