• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

XSLT: set attribute for all ancestors based on child

 
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using XSLT to transform an XML document to HTML. I would like to have an attribute "wripple up" a hierarchy. The easiest way to explain this is an example (the real case is super complex, so I'm using an example that captures the essence of my problem).
I'm laying out this email list as a "tree" of ULs. The emails can have an attribute "unread" which can be set to "T". If unread is T, I want the email and all its ancestors to be displayed in bold:

Here is the XSLT I use:

As you can see, this XSLT only sets the lowest level (email) to bold. What I want is for the Sender of that email to have its style attribute set the same way as the unread email's (that is, a Sender is bold if one or more of its children is bold)
In real life, this hierarchy will be deeper, but the number of levels is always constant.
Does anyone know how to make the parent levels "inherit" this attribute from their children? Thanks in advance.
--
Tim Allen
Especialista General
[ October 02, 2003: Message edited by: Tim Allen ]
 
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
replace

with


The test checks if you have any nodes of email that has 'T' as attribute.
 
Timothy Chen Allen
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Tony,
That works great! I see that I tried to solve the problem from the wrong direction. I did not realize that I could reference the children of a node in the test.
Thanks again.
 
Timothy Chen Allen
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A little update:
I was able to implement this solution in a much deeper hierarchy by placing code like this in the template for each hierarchy level:

Tony, you are the man.
[ October 03, 2003: Message edited by: Tim Allen ]
 
Tony Yan
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
The harder I work, the luckier I get. -Sam Goldwyn So tiny. - this ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic