Jump to content

XML, XSLT, and ASP.NET?


gsmith

Recommended Posts

I currently have an XML file that I format and display with XSLT. I would like to incorporate some ASP.NET abilities into the displaying of this XML file though. Since I have most of the work already done (with the XSLT file) is there some way to include reference to an .aspx file as well that contains subroutines that could also run on this page?

Link to comment
Share on other sites

Instead of using ASP.NET inside XSLT you can do the opposite: use XSLT inside ASP.NET. How? By executing two or more XSLTs with ASP.NET and put the actual ASP.NET script(s) between.

Link to comment
Share on other sites

Instead of using ASP.NET inside XSLT you can do the opposite: use XSLT inside ASP.NET. How? By executing two or more XSLTs with ASP.NET and put the actual ASP.NET script(s) between.

Thank you. I'm pretty new to using ASP.NET though. On the actual webpage, I call the .xml file which uses the .xslt to format and display the data. To do what you're saying, would I reference the .aspx page instead of .xslt inside my XML document, and then have another reference the .xslt from within the .aspx?
Link to comment
Share on other sites

The best thing to do is to start the .aspx file which will reference the XML and the XSLT(s). It will execute the transformation then. In other words: instead of seeing the source XML and/or XSLT, the end-user will see the XHTML. This is really useful, scince Opera 8 and below, doesn't support XML.An ASP file that should execute the transformation can be found here. As said in the above post, you may execute several XSLTs in one ASP file. Then just create the ASP script itself. When the .aspx file is executed, it will transform the first XSLT, make the ASP script and continue with transforming the second XSLT and so on.Example:

<%'Load XMLset xml = Server.CreateObject("Microsoft.XMLDOM")xml.async = falsexml.load(Server.MapPath("cdcatalog.xml"))'Load XSLset xsl = Server.CreateObject("Microsoft.XMLDOM")xsl.async = falsexsl.load(Server.MapPath("cdcatalogHEADER.xsl"))'Transform fileResponse.Write(xml.transformNode(xsl))%>If you want, you can place pure XHTML content here...<%'The ASP.NET content goes here%>...or here.<%'Load XMLset xml = Server.CreateObject("Microsoft.XMLDOM")xml.async = falsexml.load(Server.MapPath("cdcatalog.xml"))'Load XSLset xsl = Server.CreateObject("Microsoft.XMLDOM")xsl.async = falsexsl.load(Server.MapPath("cdcatalogFOOTER.xsl"))'Transform fileResponse.Write(xml.transformNode(xsl))%>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...