Subject: Re: FW: [xsl] FW: 2-step transformation From: "M. David Peterson" <m.david@xxxxxxxxxx> Date: Wed, 07 Jul 2004 06:02:45 -0600 |
But in XSL I have no arrays to iterate over again and again and no global variables.
Any ideas how to solve this truncation thing.
Cheers Robert
-----Original Message-----
From: M. David Peterson [mailto:m.david@xxxxxxxxxx] Sent: Wednesday, July 07, 2004 12:51 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] FW: 2-step transformation
Hey Robert,
While I wouldnt recommend this particular implementation for anything
larger than a "Breadcrumbs" XML source file(unless your mapping the
library of congress most breadcrumb files should be somewhat manageable -- im
guessing yours is as well) here's what I used on the Saxon.NET project
site. Heres the link to see the actual implementation:
http://www.x2x2x.org/x2x2x/home
The genearal idea... Create an XML that maps to your site structure that
starts with a "links" node as the main parent with all underlying
descendants set to the name "link" and an "href" attribute set to the current
directory value (I use a relative reference) and then place the
reference to this file within the document function and place that into a variable called
"links".
<xsl:variable name="links" select="document('links.xml')"/>
I then use a seperate "index.xml" that resides in each directory with an
element that contains the value of the current directory (in the same relative format -- I usually set all of these to the root of the site by
using a preceding "/" such as "/x2x2x/home" instead of "x2x2x/home" but
thats up to you and beyond the scope of your question as to which is more
appropriate for your situation. This index.xml contains all of the
necessary content data the page for this directory correctly. It is passed to the
transformation process as the main data file to be transformed. As such
I can just set the following param (used to compare with the href value of
each "link" element until a match is found) to the location of that
element like so: (Note: This is the same general idea that you are using the id
attribute for although the xml parser will notice the id attribute as a
unique identifier where as my method will not... depending on your future needs
or what else you may use the id attribute for you can decide which is
more appropriate for your particular case)
<xsl:param name="curDir" select="/page/curDir"/>
I chose to reference the above as an xsl:param in case you decide to
pass this value as a parameter via whatever implemenation you are using
to transform your file. It will work either way but if you choose to
implement it the way I did then I would change it to a xsl:variable
instead to ensure a more consistent practice of proper use throughout your projects
development.
The params from above are passed into this code block which outputs the
appropriate bread crumbs and then continues the transforation of the
rest of the stylesheet. As you can see, with an embedded xsl:for-each element
and a reference to all descendant-or-self "link" elements using "//link"
this is definitely not something you want to use with a large data source to
process through :)
<xsl:for-each select="$links/links//link[@href = $curDir]/ancestor-or-self::link"> <xsl:variable name="href">/x2x2x<xsl:for-each select="ancestor-or-self::link">/<xsl:value-of select="@href"/></xsl:for-each></xsl:variable> <a href="{$href}" class="locationA"><xsl:value-of select="@common"/></a> <xsl:if test="position() != last()"> > </xsl:if> // by the way, the @common attribute value used above is the common or friendly name for the directory // using capitalized first letters and spaces between each word in the directory name. Its part of each link element. </xsl:for-each>
And that should do it...
Hope this helps!
Regards,
<M:D/> :: Got a few spare moments to write some C# code for the future of XSLT on the .NET platform? :: :: Visit the Saxon.NET project site found at http://www.x2x2x.org/x2x2x/home/ to learn more ::
Robert Soesemann wrote:
Hello,
what I am trying to do is create a breadcrumb trail based on a current
page id and a sitemap XML document. In my page.xml I have a placeholder
tag:
<?xml-stylesheet type="text/xsl"
href="generate-breadcrumb.xsl"?>
... <add-breadcrumb pageid="ID5"/> <--------- final breadcrumb HTML fragment should go here ...
Based on its @pageid the first XSL(generate-breadcrumb.xsl) generates this XML fragment:
<breadcrumb> <item url=""area1.xml" label="area1"/> <item url=""area2.xml" label="area2"/>
<item url=""areaN.xml" label="areaN"/>
<page label="thisPage"/> </breadcrumb>
To do styling and truncation task based on the page width, I need to
send this fragment through a Second XSL (style-breadcrumb.xsl) which generates the actual HTML fragment which then be should placed in the page.xml.
How can I realise this 2-step transformation. Any ideas are welcome.
Best regards,
Robert
--+------------------------------------------------------------------ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/ or e-mail: <mailto:xsl-list-unsubscribe@xxxxxxxxxxxxxxxxxxxxxx> --+--
--+------------------------------------------------------------------ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/ or e-mail: <mailto:xsl-list-unsubscribe@xxxxxxxxxxxxxxxxxxxxxx> --+--
--+------------------------------------------------------------------ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/ or e-mail: <mailto:xsl-list-unsubscribe@xxxxxxxxxxxxxxxxxxxxxx> --+--
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
FW: [xsl] FW: 2-step transformation, Robert Soesemann | Thread | Re: FW: [xsl] FW: 2-step transforma, M. David Peterson |
How to find out number of elements , Ranjan K. Baisak | Date | Re: [xsl] How to find out number of, M. David Peterson |
Month |