Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 5th, 2006, 09:54 AM
Authorized User
 
Join Date: Sep 2006
Location: Cologne, , Germany.
Posts: 92
Thanks: 0
Thanked 0 Times in 0 Posts
Default Opening with a parameter ...

I have an XSL template that needs to call other XSL files. At the moment the scenario looks like this (classic parent-child relationships):

Two XML files exist:
A. Team.xml (select team, display customers)
B. Customer.xml (Select customer, display orders)

Each file has an XSL template (e.g. customer.xsl) declared in the header and both work fine at the moment.

However, I would like to do the following ...

1. A user browses a list of teams (team.xml, with team.xsl declared in the header of the xml file)
2. The user selects a team and views the customers for that team (view provided by team.xsl)
3. The user clicks on a customer and the customer.xml opens with the customer.xsl automatically applying a filter for the selected customer.

I can include hot-links (href) in my xml/xsl which will open the other xml (customer.xml) but I need to pass over a parameter and kick off the filter which selects the required customer.

So my question is whether I am following the right approach? Or maybe this is all a bit too 'sequential' and I should instead be using XSL in a different way?

Any tips on how I should best structure this and whether I can call up XML/XSL files with a parameter would be very helpful.

Regards and many thanks,
Alan Searle

PS: This must be an issue which comes up quite often so maybe someone can point me towards a good HOWTO or tutorial?

Reply With Quote
  #2 (permalink)  
Old October 5th, 2006, 10:00 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

You don't actually say whether you're running the transformations client side or server side, but at this level of abstraction, the design is fine either way.

The only thing is that when invoking a transformation using the <?xml-stylesheet?> PI, you can't supply parameters. So you'll have to write some script to do the invocation. The details then depend on what environment(s) you want it to run in.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
  #3 (permalink)  
Old October 5th, 2006, 10:10 AM
Authorized User
 
Join Date: Sep 2006
Location: Cologne, , Germany.
Posts: 92
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Michael,

> You don't actually say whether you're running the transformations
> client side or server side

The files will be on a server but the server will play no part in the processing. So I imagine that's 'client side', isn't it?

> but at this level of abstraction, the design is fine either way.

Great. Thanks for confirming that.

> The only thing is that when invoking a transformation using the <?
> xml-stylesheet?> PI, you can't supply parameters. So you'll have to
> write some script to do the invocation. The details then depend on
> what environment(s) you want it to run in.

My XSL contains javascript to activate filtering and other functions. Is this the script that you mean? Can I hang a command in there somewhere? Or is there another method/language that should be used?

Thanks very much for your help.

Regards,
Alan.

Reply With Quote
  #4 (permalink)  
Old October 5th, 2006, 11:07 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

You stated in your post that a user browses a list of teams (team.xml) and team.xsl is declared in the header. Does that mean you're using a processing instruction, xsl-stylesheet, or not?

Either way you need to call customer xsl programatically, you can't use another processing-instruction. You can then add a parameter before the actual transform. There is no way to do this that works across all browsers so you need to specify which browsers you are targeting before I can give you any more details.

For example you can use zXml from Nicholas Zakas to target the latest IE, Mozilla, Safari and Opera although some advanced features of XSLT, such as the document() function, won't all work.


--

Joe (Microsoft MVP - XML)
Reply With Quote
  #5 (permalink)  
Old October 6th, 2006, 02:52 AM
Authorized User
 
Join Date: Sep 2006
Location: Cologne, , Germany.
Posts: 92
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Joe,

>You stated in your post that a user browses a list of teams
>(team.xml) and team.xsl is declared in the header. Does that mean
>you're using a processing instruction, xsl-stylesheet, or not?

Yes, that's the way I'm doing it.

>Either way you need to call customer xsl programatically, you can't
>use another processing-instruction. You can then add a parameter
>before the actual transform. There is no way to do this that works
>across all browsers so you need to specify which browsers you are
>targeting before I can give you any more details.

The pages will be used internally and so every user will have IE 6.0 SP2.

You say I need to call the XML/XSL files programmatically? How would this look? For example, I might have a href clause calling the second XML (customer.xml) file (linked to customer.xsl). So how would the programmatic call of customer.xml apply or initiate the filter (for example 'Smith & Co.')?

Maybe you have a little 'mini example' of such a call?

Many thanks,
Alan Searle

Reply With Quote
  #6 (permalink)  
Old October 6th, 2006, 06:43 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

I can give some pseudo code, to fill in the blanks see the msxml sdk. As i said you cannot use a linked transform. You need to create something like customer.html and call it passing the filter, e.g. customer.html?teamId=3.
Code:
functions:
getCustomerDoc - retrieves msxml2.domdocument.3.0 and loads cutomer.xml
getCustomerXslt - loads customer.xsl into another dom document and creates Msxml2.XSLTemplate.3.0 for processing

code:
getCustomerDoc()
getCustomerXslt()
parse location.search to the teamId
use addParameter on Xslt to set teamId
Perform transform
Apply results to suitable part of page using innerHTML.
--

Joe (Microsoft MVP - XML)
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Opening with C# indhusundaram BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 August 2nd, 2008 01:57 AM
Parameter object malfunction - out parameter dash dev C# 2005 6 December 4th, 2007 12:58 PM
Before the opening Yulon ASP.NET 1.0 and 1.1 Basics 0 October 25th, 2005 05:19 AM
opening other fiels? vb certified Pro VB.NET 2002/2003 5 June 14th, 2005 05:30 PM



All times are GMT -4. The time now is 02:19 AM.


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