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
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Mehran ZiadlooSubject: Applying more than one XSLT on the same XML
Author: Mehran Ziadloo
Date: 03 Nov 2005 09:56 AM
Hi
I had a question I hope I can find its answer here. I was wondering if it's possible to apply two (or more) XSLTs on the same XML file at the same time!!
Consider a situation that my XML file is created on-the-fly, and different parts of it requires different XSLT files to be displayed correctly as an XHTML. I might be able to create those XSLT files to apply and match the correct XML tags, and I know that I can have an XSLT file to be included in another XSLT file to combine their capabilities.
But my problem is that since my XML file could have different parts, the only time I know which XSLT files I need for renderring my XML correctly, is when I create the XML. So having an XSLT file to include all the necessary XSLTs, is not a solution to what I ask because there could be so many different combinations. I'm seeking for a way to specify more than one XSLT for my XML.

Any solution is appreciated, thanks
Mehran Ziadloo

Postnext
Ivan PedruzziSubject: Applying more than one XSLT on the same XML
Author: Ivan Pedruzzi
Date: 03 Nov 2005 11:27 AM

XSLT is designed to handle those case pretty well, you just need to master the art of apply-templates.

Post a more concrete example and we will show you how.

Ivan Pedruzzi
Stylus Studio Team

Postnext
(Deleted User) Subject: Applying more than one XSLT on the same XML
Author: (Deleted User)
Date: 03 Nov 2005 10:03 PM
Without more information of your exact problem, it is hard to give advice, but perhaps this will help.

You can chain two .xsl files together. The first one reads the .xml file and processes some of the nodes, and creates an output file. The second .xsl file reads the output of the first and processes more of the nodes. Each .xsl file processes whatever nodes it recognizes and copies the rest to the output unchanged. I have attached an example. There is an input.xml with 2 different types of elements, and there are 2 .xsl files, each of which processes 1 type of elements. You can chain as many together as you like.


Unknowninput(5).xml
The input .xml file

Unknownpass1(1).xsl
the first pass .xslt

Unknownpass2(1).xsl
the second pass .xslt

Postnext
Mehran ZiadlooSubject: Applying more than one XSLT on the same XML
Author: Mehran Ziadloo
Date: 04 Nov 2005 04:06 AM
Ok, I'm sorry. You're right I had to explain my problem more specificly.
Here's an example of what I mean, it's so close to what Clyde understood, but I don't see how it suppose to work!!
Consider the files Clyde sent, but I would like to change the XML file like so:

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="pass1.xsl"?>
<?xml-stylesheet type="text/xsl" href="pass2.xsl"?>
<root>
<elem1>data item 1-1</elem1>
<elem1>data item 1-2</elem1>
<elem2>data item 2-3</elem2>
<elem2>data item 2-4</elem2>
</root>

I know it's not working and I'm looking for an alternative way. As the Clyde said I want to apply a chain of XSLT files on my XML. So is it possible?

Postnext
(Deleted User) Subject: Applying more than one XSLT on the same XML
Author: (Deleted User)
Date: 04 Nov 2005 05:54 AM
Can you please tell us a little more about why you can't chain the .xsl files one after another?

How much control do you have in your environment? Can you change the way the .xsl is started? Can you pass parameters to the .xsl? Can you change or rewrite the .xsl files? Can you change (slightly) the format of the .xml files?

Thanks much.

Postnext
Mehran ZiadlooSubject: Applying more than one XSLT on the same XML
Author: Mehran Ziadloo
Date: 04 Nov 2005 08:32 AM
The fact is I'm trying to create a PHP Web Application Framework for my company. And right now I'm researching to understand how can I use XML to present the framework's front-end.
I want my code to create an XML output, based on the user input and other stuff and then use XSLT to render it. My problem is, since I would like to have as the most consistency as possible, I want to create stand-alone packages. Somehow that if I had to reuse a package, it requires the lowest possible effort.
As the conclusion, I need each package to have its own XSLT files. But these XSLT files are not about to create a complete HTML file becuase they are created to present a part of a page, not all of it, perhaps like a TABLE tag. And then with combining package's XML with other information, which they have XML structure too, I'll have an XML containing all the necessary information. But this XML requires different XSLT files to render correctly.
I know it's getting too long, but perhaps a practical example fixes everything:
Consider the user management package, there's a page to show the list of all users. Also there will be a page to show a single user info. I would like to design two XSLT files just to render the user list and user's info, I name them UserList.xsl and UserInfo.xsl, but their output's root tag will be a TABLE tag not HTML tag. I need an extra XSLT file to add the complemental tags, like HTML, lets name it PageDesign.xsl. Now think of the time you're about to see the list of users. There will be three files engaged, two of them we have already created, UserList.xsl and PageDesign.xsl. The third one, we have to create on-the-fly since its content depends on user input, and it's an XML file containing the actual information of user list.
But the time we are about to see the user info page, there will be a different set of pages engaged. UserInfo.xsl, PageDesign.xsl and on-the-fly created XML file of user info.
If you're reading this part of my letter, then you must be bored by now. That's all I'm asking, so can you please help me and give a clue how it's possible? One XML file and two XSLT files!!

Thanks alot for your patience,
Mehran Ziadloo

Postnext
(Deleted User) Subject: Applying more than one XSLT on the same XML
Author: (Deleted User)
Date: 04 Nov 2005 09:58 PM
Can you do this? When you create the .xml file on the fly, also create a master .xsl file on the fly which has 1 <xsl:include.../> for each of the .xsl modules required. In your examle, you would be creating:

<xsl:stylesheet....
<xsl:include href="pageDesign.xsl"/>
<xsl:include href="userlist.xsl"/>
....
</xsl:stylesheet>

Then, you only need to run the .xml file through one .xsl file: the master .xsl file.

Clyde

Posttop
Mehran ZiadlooSubject: Applying more than one XSLT on the same XML
Author: Mehran Ziadloo
Date: 04 Nov 2005 10:18 PM
Well, that was something I thought too but practically it has some problems. The XML request and the XSLT request are not the same, so it's a little hard and strange to keep this connectivity. But if that's the only way you can think of, then thank you for your time. Becuase I'm sure if you can't do anything about it, then no one else can..

Thanks alot,
Mehran Ziadloo

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
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.