• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XSLT: set attribute for all ancestors based on child

 
Timothy Chen Allen
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
  • 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 ]
 
Tony Yan
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • Quote
  • Report post to moderator
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic