Last active
December 16, 2015 08:08
-
-
Save uniquelau/5403147 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Lets give it a go. | |
/// Why could this fail? API offline, API outputing invalid XML, XSLT file missing/invalid. | |
try | |
{ | |
/// <summary> | |
/// Passes the parameters into a XSL file, that is run against in memory XML | |
/// </summary> | |
string xsltFilePath = Server.MapPath("~/XSLT/getProduct.xsl"); | |
// Load XML from our Global Variable | |
XPathNavigator nav = Data.CreateNavigator(); | |
// Stream for the transformed XML | |
MemoryStream stream = new MemoryStream(); | |
XsltArgumentList argsList = new XsltArgumentList(); | |
argsList.AddParam("refID", "", refID); | |
argsList.AddParam("subRefID", "", subRefID); | |
// Load XSLT & transform | |
XslCompiledTransform transformer = new XslCompiledTransform(); | |
transformer.Load(xsltFilePath); | |
transformer.Transform(nav, argsList, stream); | |
// Write output | |
using (StreamReader reader = new StreamReader(stream)) | |
{ | |
stream.Position = 0; | |
Response.Write(reader.ReadToEnd()); | |
reader.Close(); | |
} | |
} | |
/// fail | |
catch { } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment