|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
newbie: XSL question.
Hi board,
If any of y'all w/ the know how on this can respond I'd be grateful. Ok my question is this.. I'm only playing around with XML and XSL primarily for XSLT transformations on a large publishing industry site. So I have my XML file, a dump of for example a bunch of Sport stories from a newspaper (very short listing): PHP Code:
Ok so that's a brief example of the XML. So using XSL I can successfully transform this into well formatted html with category names in bold followed by the ranked stories etc. I can also take for example a rank='1' story and display it anywhere. However, this is where I'm stuck and unsure as to whether this is possible with XSL. Can I use XSL to extract (dont take me literally) the rank=1 stories and display them before the other categories as 'Top Stories' (which I have done) but then when my XSL works on outputting the individual Categories it omits headlines that appeared in the 'Top Stories' ie html would be like this. TOP STORIES - Big name transfer to UK Club - Baseball legend does something SOCCER - The second ranked story - The third ranked story BASEBALL - The second ranked story - The third ranked story Also, can I apply any sort of 'counter' to this process whereby I would only use 4 rank 1 stories and then for the rest rank 1's appear under their associated category... ? Ok so hopefully you get what I'm trying to do. I don't expect you to write my code but if anyone can indicate if this is possible and indicate how I might do it that would be great. Cheers R ![]() |
|
#2
|
||||
|
||||
|
This is definitely feasible. Basically you want a conditional statement, if rank=1 then... else...
Check out this tutorial: http://www.w3schools.com/xsl/xsl_choose.asp
__________________
Hello, old friend... |
|
#3
|
|||
|
|||
|
Quote:
Thanks khwang, Yes I'm familiar with the choose and have used it in this sucessfully to get those story[rank='1'] which I want. However, for example if Sport has 8 categories I will only want to take four rank 1 stories for my 'Top Stories' section in the HTML. Also if the rank 1 story appeared in Top Stories I do not want to duplicate it under its individual category listing as in the html output ex. above....? |
|
#4
|
||||
|
||||
|
Quote:
You can use a selective position() trick for this: PHP Code:
Quote:
This I could not work out cleanly, but you might want to look into using call-template and with-param, doing a recursive call to increment the param. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > newbie: XSL question. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|