Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 12th, 2006, 10:14 AM
Authorized User
 
Join Date: Sep 2006
Posts: 92
Thanks: 0
Thanked 0 Times in 0 Posts
Default Merging two templates ... is there an easy method?

Hallo everyone,

I have two XSL templates that are declared at the start of an XML file. For example ...

<?xml-stylesheet href="repbase.xsl" type="text/xsl"?>
<?xml version="1.0" encoding="UTF-8"?>
<dataroot>
... etc.

Both templates are quite complicated (including filtering functionality) and both work fine.

At the moment I am exporting the XML data file twice and forcing my export program to declare each of the XSL templates at the top of the XML file.

This works but of course is very cumbersome so what I now need to do is to get both XSL files to work with the same XML file. I know that this can be done (I have examples) but I was wondering if there is an easy method to switch? Or will I have to do a re-design and merge the two?

Most comfortable for me would be to add a button to each template so that, on demand, the user could switch from one to the other one.

Any tips on how best to do this or any pointers to userful HOWTOs would be a great help.

Many thanks,
Alan Searle.

 
Old October 12th, 2006, 11:07 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

I'm not sure what you mean by "templates" - perhaps you mean "stylesheets" - but I don't see two of anything declared in your XML file, which is in fact not well-formed, because the XML declaration must come first.

The simple answer is that if you want to use different stylesheets with the same data file on different occasions, that's fine, but you can't use the <?xml-stylesheet?> processing instruction to control it. You'll need some kind of application code, perhaps in Java or Javascript, which invokes the XSLT processor's API to transform a particular XML document with a particular stylesheet.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Merging files ajindal General .NET 2 January 10th, 2007 06:42 AM
Merging Tables Charlotte89 Access 5 November 22nd, 2006 12:49 AM
merging projects Bill_Thompson Beginning VB 6 1 April 26th, 2006 04:58 PM
Merging two xslts into one...help!! nrane26 XSLT 1 January 7th, 2005 04:21 PM
Merging Data Mitch SQL Server 2000 0 January 2nd, 2004 05:42 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.