Subject: [xsl] one XML file, two XSLT style sheets From: "Ines Robbers" <conceptMe@xxxxxx> Date: Thu, 20 Sep 2001 21:35:28 +0200 |
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 all: "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 select="$as"/></xsl:when> <xsl:otherwise><xsl:value-of select="@style"/></xsl:otherwise> </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 cocoon 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 _______________________________________________________________________ 1.000.000 DM gewinnen - kostenlos tippen - http://millionenklick.web.de IhrName@xxxxxx, 8MB Speicher, Verschluesselung - http://freemail.web.de XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] xpath expression needed, Michael Kay | Thread | Re: [xsl] one XML file, two XSLT st, Jörg Heinicke |
Re: [xsl] xpath expression needed, Jörg Heinicke | Date | RE: [xsl] xpath expression needed, Corey Spitzer |
Month |