XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
- XSLT Help and Discussion (7625)
-> + Remove leading Zeros from a st... (4)
-> + how to parse a html element fo... (2)
-> + Add namespaces to target messa... (2)
-> + XSLT Transformation - insertin... (3)
-> + Convert binary xml (9)
-> + XSLT Transformation (4)
-> + Generating hyperlinks (3)
-> + XSLT to PDF problem (with JAVA... (2)
-> + how to add onclick_ with try/c... (2)
-> + Keep table in one page. xsl-fo... (4)
-> + Cannot find a matching 2-argum... (3)
-> + Creating one string from a sub... (2)
-> + XSLT: Traversing XML twice for... (6)
-> + Copy element without namespace... (5)
-> + Create dynamic elemant name (2)
-> + XSLT: Traversing XML twice for... (3)
-> + Problem including Javascript (2)
-> + Looping through attributes (4)
-> + Transform values into elements... (4)
-> + Problem with deep node copy an... (2)
-> + Comparing Dates With ASP.NET 2... (3)
-> + Converting tree structure to h... (4)
-> + Attributes to element transfor... (2)
-> + XSLT transformation (2)
-> + XSLT transformation (5)
-> + xsl:character-map not working (2)
-> + Removing duplicates entries. (2)
-> + Image issues. (2)
-> + xsl transformation (4)
-> + XSL Question (5)
-> + how to insert xml file as an n... (2)
-> + Document Function (2)
-> + convert seconds to hh:mm:ss (5)
-> + how to remove attribute while ... (3)
-> + XSL-FO question (2)
-> + EDI 997 creation. (7)
-> + Line break within a tag in XML... (2)
-> + Contact Help Needed (2)
-> + ACK 997 (2)
-> + XSLT to output XML( which conf... (11)
-> + Retrieving all nodes where a c... (6)
-> + Verifying XML and XSD within X... (4)
-> + How to validate date format in... (3)
-> + XSLT question (2)
-> + Muenchian grouping (2)
-> + How to remove specific text en... (8)
-> + If Else Condition along with L... (2)
-> + SAXON Problem (2)
-> + comapring global variable valu... (2)
-> + copying the value of xsl in va... (2)
-> + Urgent:XSLT element value sel... (2)
-> + Ignoring first element using f... (2)
-> + EDI X12 to XML (4)
-> + XSLT FOR-EACH HELP (2)
-> + Sorting Help Needed (3)
-> + XSLT help with linking (2)
-> + selecting data into node set b... (2)
-> + Watch and Variable in Debug no... (4)
-> + Transforming XML to XML - grou... (2)
-> + Saxon 9.0 B support in debug m... (2)
-> + Repeating element question (2)
-> + Newly Purchased Version Not La... (2)
-> + xsl:include not finding file (5)
-> + JAXP and XSLT 2.0 / XPATH 2.0 (2)
-> + ASP:DropDownList trigger in Xs... (2)
-> + Auto-Skip empty values (2)
-> + retrieving a javascript functi... (2)
-> + need help (2)
-> + html tag ignored (2)
-> + Quick reply needed (8)
-> + xslt to remove namespaces but ... (2)
-> - Using a WSDL definition in an ... (1)
-> + XSL logic issue for simple inp... (6)
-> + Regarding XML namespace prefix... (4)
-> + Mapper reoganizes itself. (8)
-> + XSL Substring Removal (2)
-> + Regarding XSLT logic for a sim... (3)
-> + XSLT Transform documentation (2)
-> + XSLT stack trace in case of er... (3)
-> + No New Line (2)
-> - No New Line (1)
-> + howto loop through a sequence (2)
-> + xml and xsl and whitespace in... (2)
-> + XSL Date formatting (4)
-> + XSL to XSL Mapping using custo... (4)
-> + flat xml to nested xml comvers... (4)
-> + Including schema in scenario (2)
-> + DTDs and traversing (2)
-> + Help with transformation (2)
-> + Problem running XSLT against X... (2)
-> + Carriage return in the output (5)
-> + Generating XSLT to match a sch... (3)
-> + WYSIWYG editor (2)
-> + Grouping without For-Each (3)
-> - output XML using XSLT (8)
-> ->output XML using XSLT
-> ->output XML using XSLT
-> ->output XML using XSLT
-> ->output XML using XSLT
-> ->output XML using XSLT
-> ->output XML using XSLT
-> ->output XML using XSLT
-> + Help configuring Xalan-j proce... (8)
-> + Convert Existing HTML pages to... (2)
-> + Generating Transformation - XS... (4)
-> + DOCTYPE public and system info... (2)
-> + Using EXSLT str:tokenize funct... (5)
-- Previous [661-680] [681-700] [701-720] Next
+ XQuery Help and Discussion (2017)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
Topic  
Postnext
Srini VenkatSubject: 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.

first.xml
---------

<?xml version="1.0" encoding="UTF-8"?>
<hotelList1>
<hotel>
<name>ABC</name>
<starRating>5 Star</starRating>
<roomType>Standard</roomType>
<status>Yes</status>
<boardBasis>Breakfast</boardBasis>
<currency>USD</currency>
<totalPrice>350</totalPrice>
</hotel>
<hotel>
<name>XYZ</name>
<starRating>3 Star</starRating>
<roomType>Standard</roomType>
<status>Yes</status>
<boardBasis>Breakfast</boardBasis>
<currency>USD</currency>
<totalPrice>171</totalPrice>
</hotel>
</hotelList1>

second.xml
---------
<?xml version="1.0" encoding="UTF-8"?>
<hotelList2>
<ServiceHotel>
<Currency code="USD">DOLLAR U.S.A.</Currency>
<HotelInfo>
<Code>12744</Code>
<Name>Venetian(BAR)</Name>
<Category>5 STARS</Category>
</HotelInfo>
<AvailableRoom>
<HotelRoom>
<Board>ROOM ONLY</Board>
<RoomType>DOUBLE DELUXE</RoomType>
<Status>Yes</Status>
<Price>
<Amount>1023.890</Amount>
</Price>
</HotelRoom>
</AvailableRoom>
</ServiceHotel>
<ServiceHotel>
<Currency code="USD">DOLLAR U.S.A.</Currency>
<HotelInfo>
<Code>12743</Code>
<Name>Tuscany Suites &amp; Casino(BAR)</Name>
<Category>3 STARS AND A HALF</Category>
</HotelInfo>
<AvailableRoom>
<HotelRoom>
<Board>ROOM ONLY</Board>
<RoomType>DOUBLE 2 DOUBLE BEDS</RoomType>
<Status>Yes</Status>
<Price>
<Amount>485.760</Amount>
</Price>
</HotelRoom>
</AvailableRoom>
</ServiceHotel>
</hotelList2>


Here is my XSLT file

combine.xsl
-----------

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="UTF-8"/>
<xsl:template match="/">
<Results>
<xsl:apply-templates select="document('first.xml')/hotelList1" />
<xsl:apply-templates select="document('second.xml')/hotelList2" />
</Results>
</xsl:template>
<xsl:template match="hotelList1">
<xsl:for-each select="hotel">
<Hotel>
<Name><xsl:value-of select="name" /></Name>
<StarRating><xsl:value-of select="starRating" /></StarRating>
<Price><xsl:value-of select="totalPrice" /></Price>
</Hotel>
</xsl:for-each>
</xsl:template>
<xsl:template match="hotelList2">
<xsl:for-each select="ServiceHotel">
<Hotel>
<Name><xsl:copy-of select="HotelInfo/Name" /></Name>
<StarRating><xsl:copy-of select="HotelInfo/Category" /></StarRating>
<Price><xsl:copy-of select="AvailableRoom/HotelRoom/Price/Amount" /></Price>
</Hotel>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

The output xml I need is

<Results>
<Hotel>
<Name>.....</Name>
<StarRating>....</StarRating>
<Price>....</Price>
</Hotel>
<Hotel>
<Name>....</Name>
<StarRating>....</StarRating>
<Price>....</Price>
</Hotel>
.......
........
</Results>

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.

Please help.

Thanks
Svan

Postnext
James DurningSubject: output XML using XSLT
Author: James Durning
Date: 19 Oct 2007 04:27 PM
IE will display the resulting XML as html, so it ignores all the elements and simply outputs the text.

Use an actual XSLT processor to get the result XML. (eg Stylus Studio)

Postnext
Jamil TaylorSubject: output XML using XSLT
Author: Jamil Taylor
Date: 20 Oct 2007 04:50 AM
Actually, IE has support for XSLT 1.0. You can use it to perform this transformation.

All you have to do is add the following line right below the declaration of the XML document you wish to transform:

<?xml-stylesheet type="text/xsl" href="combine.xsl"?>

Postnext
Jamil TaylorSubject: output XML using XSLT
Author: Jamil Taylor
Date: 20 Oct 2007 02:25 PM
Here's a couple of things that may help you out:

First, Microsoft has a small utility that will validate and show XML content via context menus in IE. You can grab it here: http://www.microsoft.com/downloads/details.aspx?FamilyId=D23C1D2C-1571-4D61-BDA8-ADF9F6849DF9&displaylang=en

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();
}

Postnext
Srini VenkatSubject: 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.

Postnext
(Deleted User) 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.

Alberto

Postnext
Srini VenkatSubject: 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.

Thanks
Srini

Posttop
(Deleted User) 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).

Alberto

   
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.