This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: ordering of output in menu rendering system


Tushar,

> (note the out-of-order 'tit3' title). Can someone please explain
> why this is happening, and what I need to do to fix it!.....

It doesn't happen in Saxon 5.5.1 or MSXSL(Release).  I see you're
using Cocoon - I haven't installed Xalan on my new machine yet, but
make sure you've got the most recent version: if you have, I guess
it's a bug.

> Also, on the same theme, Ideally I would like to say in one xml
> document: 'this page relates to the menu item x', and separately
> in an XSL stylesheet I would like to describe the menu and
> process it according to the menu that was selected in the xml source.
>
> I haven't tried this yet, but I'm presuming I can do something
> like compare the node string-value in the xml with the menu items
> and determine which matches and continue from there. If anyone
> would like to offer an example of how to do this I would be grateful! :)

Well, let's say you use a 'page' attribute on the 'doc' element of
your XML document to indicate what page you're on:

<doc page="contacts">
  ...
</doc>

And your menu holds the item 'contacts':

<menu>
  ...
  <item>
    <title>contacts</title>
    ...
  </item>
  ...
</menu>

You can hold the menu either within a variable in your XSLT stylesheet
and access its value through the node-set extension function (I think
called nodeset in Xalan), or by holding it in a separate file and
accessing it with the document() function.  I think the latter is
probably better in this case - if you call your menu document menu.xml
you can access it with:

  document('menu.xml')

You can find the selected menu item by finding the item whose title
child element is the same as the page attribute on the doc element.
So, get the menu into a variable for ease of access:

<xsl:variable name="menu" select="document('menu.xml')/menu" />

And then find the selected item with:

<xsl:variable name="selected-item"
              select="$menu//item[title = /doc/@page]" />

I hope that sets you on your way,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/



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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]