Subject:output XML using XSLT Author:Srini Venkat Date:19 Oct 2007 11:17 AM
Hi
I am developing the hotel accomodation search.During the hotel search, I will get multiple xml files(totally different structure but has got common elements) as a response from different sources. These files are stored on the same location. Now I would like to have a XSLT to combine these two xml files and output the results to a single xml file. And from this file the results need to be displayed. Here are my xml response files.
When I tried the above the output is not displaying as an xml file. It simply displays the results in a text. I need the output as a xml file so that I will process it and display the results on the front end. When i have the ouput xml file I can provide the different sort option aswell from the results. (That is sort based on price / Hotel name /Star Rating....etc).
I am new to xml/xslt. I have tried by incuding this on my first.xml
<?xml-stylesheet type="text/xsl" href="combine.xsl"?>
Also I tried this from javascript
var xml = new ActiveXObject("Microsoft.XMLDOM")
xml.async = false
xml.load("first.xml")
var xsl = new ActiveXObject("Microsoft.XMLDOM")
xsl.async = false
xsl.load("combine.xsl")
document.write(xml.transformNode(xsl))
But i am getting the same result..that is results are diplayed with value in text without xml elements.
Could anyone suggest me how to generate the output xml file and how to execute the xsl/xml files to achive that. I am new to this.
Second, with a small modification to your javascript, you can save the transformed XML document using MS's DOM:
function transform() {
var xml = new ActiveXObject("Microsoft.XMLDOM");
xml.async = false;
xml.load("first.xml");
var xsl = new ActiveXObject("Microsoft.XMLDOM");
xsl.async = false;
xsl.load("combine.xsl");
var xml2 = new ActiveXObject("Microsoft.XMLDOM");
var fso = new ActiveXObject("Scripting.FileSystemObject");
var file = fso.CreateTextFile("output.xml", 1);
xml.transformNodeToObject(xsl, xml2);
file.write(xml2.xml);
file.close();
}
Subject:output XML using XSLT Author:Srini Venkat Date:22 Oct 2007 09:53 AM
Thanks all for your help. Jamil, as you mentioned now i am able to write the output to a file. Thanks. My another question to james is how do we use the XSLT processors like styles studio for our xsl/xml operations. These two are going to reside on a specific location in a server and how to integrate these with style studio on the fly. I mean during the search operation in the front end.
Subject:output XML using XSLT Author:(Deleted User) Date:25 Oct 2007 07:48 AM
Hi Srini,
Stylus Studio is not a server-side component that can be invoked "on the fly", it's a development environment. Depending on the server environment you have, you could be interested in adopting server-side components like DataDirect XQuery and/or XML Converters, or just use XSL processors like MSXSL/Saxon/XalanJ.
If you need more guidance, please describe your server application with more details.
Subject:output XML using XSLT Author:Srini Venkat Date:29 Oct 2007 11:58 AM
Hi Alberto
Thanks for your info. Basically I am devloping a search engine for checking availability for hotels/resorts and flights. Mostly this application involves sending data to various data providers and receive responses as an xml file. I am using xml/xslt for these purposes. Do you think I need some tools like style studio for the development.Will that reduce programming time? I have no idea on this.
Subject:output XML using XSLT Author:(Deleted User) Date:31 Oct 2007 01:50 PM
Hi Srini,
a development environment like Stylus Studio will greatly reduce your development time (compared to using Notepad to write the XML/XSLT and command line tools for testing them).