[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: one XML file, two XSLT style sheets

Subject: Re: one XML file, two XSLT style sheets
From: Jörg Heinicke <joerg.heinicke@xxxxxx>
Date: Thu, 20 Sep 2001 22:50:12 +0200
one xml two xsl
According to your explanations (processing-instructions) I assume that you
want to use Cocoon 1. But I must point out, that there is Cocoon 2 - better,
easier and very stable, although it's still in beta-status. But this Beta 2
is more stable than MS-products after SP 2 - my tutor said it. And my
experiences with it are very good too. I work on such a system.

With Cocoon 2 it's very easy to realize your wish. You have a Sitemap in
Cocoon 2, where something like the following can be written.

<map:match pattern="mypage.summary">
    <map:generate src="mypage.xml"/>
    <map:transform src="summary.xsl"/>
    <map:serialize type="html"/>

<map:match pattern="mypage.detail">
    <map:generate src="mypage.xml"/>
    <map:transform src="detail.xsl"/>
    <map:serialize type="html"/>

Another version using the wildcard-matcher does the same:

<map:match pattern="mypage.*">
    <map:generate src="mypage.xml"/>
    <map:transform src="{1}.xsl"/>
    <map:serialize type="html"/>

Also you can give parameters to a stylesheet or do multiple transformations:

<map:match pattern="mypage.*">
    <map:generate src="mypage.xml"/>
    <map:transform src="{1}.xsl"/>
    <map:transform src="another.xsl">
        <map:param name="anything" value="test"/>
    <map:serialize type="html"/>

The value for the parameter can be something from the URL too.

These are only the most important facts. You can do much more like
browser-identification (without javascript!!) or something else basing on
the information of the request-header. For more information

Hope this helps a bit,


----- Original Message -----
From: "Ines Robbers" <conceptMe@xxxxxx>
To: <XSL-List@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Thursday, September 20, 2001 9:35 PM
Subject:  one XML file, two XSLT style sheets

> dear list,
> this is for my final project which i have to hand in tomorrow... urgh. if
anyone could help me with this problem i'd be utterly greatful!!!
> background info: i am working on cocoon, want to build an xml website and
am looking for a server-side solution for the following problem:
> problem: you have one xml file with say a list of
> <item>
> </title>
> <moreinfo/>
> </item>
> <item>
> </title>
> <moreinfo/>
> </item>
> ...
> now, on one webpage you only want to display the titles (with summary.xsl)
which are links and lead to a new page that display the detailed information
(with detail.xsl) of that requested item. how do you switch between your two
stylesheets? how do you link from one version of the xml file to the other
version of that same xml file?
> apparent crystal clear solution from my tutor which i don't understand at
> "The way I have delt with this in the past, is to have 3 stylesheets
> The first one (refered to from your XML file) chooses which of the other
> two to do the job, depending on some input parameter.
> This is a template snippet that does this trick.
> <!--
>   <xsl:template match="doc">
>       <xsl:variable name="style">
>           <xsl:choose>
>         <xsl:when test=" $as != '' "><xsl:value-of
>               <xsl:otherwise><xsl:value-of
>           </xsl:choose>
>       </xsl:variable>
>       <xsl:processing-instruction
> name="xml-stylesheet">href="/stylesheet/<xsl:value-of
> select="$style"/>.xsl" type="text/xsl"</xsl:processing-instruction>
>       <xsl:processing-instruction
> name="cocoon-process">type="xslt"</xsl:processing-instruction>
> <doc>
>           <!-- templates to copy all the document -->
>       </doc>
>   </xsl:template>
> -->
> It sets up a variable called $style, either from the contents of the 'as'
> request parameter ie. 'mypage.xml?as=list', or from the 'style' attribute
> of the document being processed (acts as the default).
> Next the StyleSheet generates a 'processing instruction' telling the
> processor to transform the output of this StyleSheet with another. Your
> first StyleSheet then should copy over all that the subsequent StyleSheets
> require for their job."
> i have just really started on xml and don't understand how something works
before i have seen it work - well, if that makes any sense. so maybe, if
someone has the nerves and time, could i possibly send them my files because
i just don't know how to integrate this solution into my particular case.
> many thanks and kind regards,
> ines

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.