Subject: FW: [xsl] FW: 2-step transformation From: "Robert Soesemann" <rsoesemann@xxxxxxxxxxx> Date: Wed, 7 Jul 2004 13:25:16 +0200 |
-----Original Message----- From: Robert Soesemann Sent: Wednesday, July 07, 2004 13:21 PM To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx' Subject: RE: [xsl] FW: 2-step transformation Thanks a lot David for the long answer. But this doesn't solve my problem. I already had implemented a similar logic for the breadcrumb you are describing. The problem is that i need to truncate the length of this breadcrumb to a maxlength. (A thing you code does not do!) Truncating the item depending on a maxLength and the total length of thge breadcrumb string following the algorithm on http://www.webspace-journey.de/breadcrumb_truncation.gif would be easy if i would work with javascript arrays but I need to stay with XSL only. 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> --+--
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] FW: 2-step transformation, M. David Peterson | Thread | Re: FW: [xsl] FW: 2-step transforma, M. David Peterson |
Re: [xsl] FW: 2-step transformation, M. David Peterson | Date | How to find out number of elements , Ranjan K. Baisak |
Month |