Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Checking neigboring parent elements for match

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there y'all.
I am using the following stylesheet & source document to output an XML file which contains only those "CCI_RECORD" elements which match the $owner variable (passed to the stylesheet from my servlet container), in descending date order

This all works fine. However, I would like to insert a <YearChange/> element between records when the CCI_RECORD/Year element changes, which I can then use to create headers when transforming this document with another XSL transform.
For example, the desired output if "hc00dw1" is passed to the transform would be:

Thanks for reading (and replying, of course).

------------------
daniel.walker
***i fear that i am ordinary...
...just like everyone...***


[This message has been edited by Daniel Walker (edited October 17, 2001).]
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's your stylesheet with an <xsl:if> element that seems to do what you want. There is an interesting issue that occurs since you're sorting them descending. The preceding-sibling axis is actually pointing to the NEXT element that will be emitted. Other than that, it's pretty straightforward:

------------------
W. Scott Means
author, Strategic XML
smeans@strategicxml.com
[This message has been edited by W. Scott Means (edited October 17, 2001).]
 
Daniel Walker
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there Scott.
Thanks ever so for the assistance - I have now managed to get my transform working properly, and it looks great. I had to use test="not(following::CCI_RECORD/Year = Year)" though, for some reason. I also had to sort and filter in a seperate transform prior to this one, as I was getting erratic results otherwise.
Oh, and those damn smilies got me too!

[This message has been edited by Daniel Walker (edited October 17, 2001).]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic