Subject: [xsl] navigate to my next node or previous node for an attribute.. From: "Peter Gibbons-BU" <peter.gibbons.01@xxxxxxxxx> Date: Mon, 24 Mar 2003 18:02:36 -0000 |
Here's the xslt fragment I'm using. I have an xml tree of 'DBI/RESLUTSET/ROW/PAGES/'etc. I'm interested in processing the 'PAGE' nodes. I can receive an number of 'DBI/RESLUTSET/ROW/PAGES/' not just the two highlighted in my example. Whilst processing a Pages node, ie _name="1116" I need to calculate, the next Pages nodes value, ie _name="1115" and my previous value ie _name="1114". The problem is complicated slightly by the fact that if it's the last node, there will not be a next node so I need to get the first node ie name="1116", and similar for the first node. When I am processing this one, there will not be a previous node so I need to return the last node, ie name="1114" .I have struggled how to do this in xslt, can some one help me out here. I tried using following & preceeding but failed to get it working correctly <xsl:for-each select="/DBI/RESULTSET/ROW/Pages"> <xsl:variable name="SceneId2">t1_dt_<xsl:value-of select="@scene_name" /></xsl:variable> <xsl:variable name="PreviousSceneId">t1_dt_<xsl:value-of select="preceding::Pages/@scene_name"/></xsl:variable> <xsl:variable name="NextSceneId">t1_dt_<xsl:value-of select="following::Pages/@scene_name"/></xsl:variable> </xsl:for-each> Here's my xml structure: <DBI> <RESULTSET statement="SELECT items.id, items.title FROM items WHERE items.node_id='0111'" scene_name="T1_dt_News_MainHeadlines"> <ROW> <Pages scene_name="1116" type="story"> <Page >Mo Mowlam Set To Attend Anti-War Rally<LineBreak/><Style Colour="16">Former Northern Ireland Secretary Mo Mowlam has said she is planning to attend next week's Stop the War rally.<LineBreak/><LineBreak/>Ms Mowlam told Sky TV that she was hoping to join the 400,000 people due to march to Hyde Park next Saturday.</Style><LineBreak/></Page> <Page>Bid To Protect Coral Reef From Fishing<LineBreak/><Style Colour="16">Concerns have been growing over the effects of increased deep-sea trawling by French and Irish fishermen.<LineBreak/><LineBreak/>New EU rules let states take action to protect eco-systems, not just fisheries.</Style><LineBreak/></Page> </Pages> <title>Bid To Protect Coral Reef From Fishing </title> </ROW> <ROW> <Pages scene_name="1115"> <Page>Mo Mowlam Set To Attend Anti-War Rally<LineBreak/><Style Colour="16">Earlier, Lib Dem leader Charles Kennedy told BBC1's Breakfast with Frost that he was also willing to go.<LineBreak/><LineBreak/>The protest, organised by various groups, was recently given the go-ahead by Culture Secretary Tessa Jowell.</Style><LineBreak/></Page> <Page>Mo Mowlam Set To Attend Anti-War Rally<LineBreak/><Style Colour="16">Former Northern Ireland Secretary Mo Mowlam has said she is planning to attend next week's Stop the War rally.<LineBreak/><LineBreak/>Ms Mowlam told Sky TV that she was hoping to join the 400,000 people due to march to Hyde Park next Saturday.</Style><LineBreak/></Page> </Pages> <title>Mo Mowlam Set To Attend Anti-War Rally </title> </ROW> <ROW> <Pages scene_name="1114"> <Page>Mo Mowlam Set To Attend Anti-War Rally<LineBreak/><Style Colour="16">Earlier, Lib Dem leader Charles Kennedy told BBC1's Breakfast with Frost that he was also willing to go.<LineBreak/><LineBreak/>The protest, organised by various groups, was recently given the go-ahead by Culture Secretary Tessa Jowell.</Style><LineBreak/></Page> <Page>Mo Mowlam Set To Attend Anti-War Rally<LineBreak/><Style Colour="16">Former Northern Ireland Secretary Mo Mowlam has said she is planning to attend next week's Stop the War rally.<LineBreak/><LineBreak/>Ms Mowlam told Sky TV that she was hoping to join the 400,000 people due to march to Hyde Park next Saturday.</Style><LineBreak/></Page> </Pages> <title>Mo Mowlam Set To Attend Anti-War Rally </title> </ROW> </DBI> </RESULTSET Peter Gibbons BBCi at http://www.bbc.co.uk/ This e-mail (and any attachments) is confidential and may contain personal views which are not the views of the BBC unless specifically stated. If you have received it in error, please delete it from your system, do not use, copy or disclose the information in any way nor act in reliance on it and notify the sender immediately. Please note that the BBC monitors e-mails sent or received. Further communication will signify your consent to this. XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] apply-templates and XHTML, Passin, Tom | Thread | [xsl] any good online examples for , Robert P. J. Day |
[xsl] apply-templates and XHTML's <, Gan Uesli Starling | Date | [xsl] any good online examples for , Robert P. J. Day |
Month |