473,468 Members | 1,369 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Setting class on child

2 New Member
Hello,

I am trying to set a class attribute of a text.item element to the value of its nearest ancestor. I want to do this in the case that the class of the text.item is currently a blank string.

<text class="read-only">
...
<text.item class=""/> //this element should inherit the class attribute "read-only" from text
<foo class="read-write">
<text.item class="" /> //this element should inherit the class attribute "read-write" from foo
</foo>
<bar class="read-write">
<text.item class="" /> //this element should inherit the class attribute "read-write" from bar
</bar>
<baz class="read-write">
<bar class="">
<text.item class=""/> //this element should inherit the class attribute "read-write" from baz
</bar>
</baz>
...
</text>

The approach I was considering was creating a template for the text.item node like the following. Is this feasible or would I need to consider an alternative approach?

<xsl:template match="text.item">
<xsl:if test="@class =''">
<xsl:attribute name="class">
<!-- determine the nearest ancestor that has the class attribute set to something other than a blank string, and select that value here-->
<xsl:value-of select="<some expression for my nearest ancestor with class attribute set>"/>
</xsl:attribute>
</xsl:if>
<xsl:apply-templates/> <!-- the text.item nodes have other children with templates defined already, so delegate accordingly -->
</xsl:template>

Please let me know if more information is needed to give a clearer picture of what I am trying to describe. I apologize in advance if I have mangled any of the terminology.

Thanks,
Valvalis
Feb 27 '07 #1
3 1462
Valvalis
2 New Member
I found the solution, thanks!

<xsl:value-of select="ancestor[@class][1]"/>
Feb 27 '07 #2
dorinbogdan
839 Recognized Expert Contributor
Hi,
Glad to see your problem solved.
So, I will close the thread since it got answer.
Mar 21 '07 #3
dorinbogdan
839 Recognized Expert Contributor
I re-open the thread in order to allow further comments or suggestions from other members or experts, as per adim request.
Mar 22 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: David McDivitt | last post by:
I need to set tabs on java generated pages. Pages have four sections: header, sidebar, body, and footer. The sidebar and body change dynamically. The tab key must go to anchors, fields, and buttons...
6
by: jalkadir | last post by:
Let's say that I have this class: class Parent{ private: char* str; public: const char* getStr(){return str;} }; And then I create a child class class Child{ private: std::string str;...
4
by: Hollywood | last post by:
I'm using XML serialization to produce the following XML document: <TestDoc xmlns:srd="some-url"> <Additional> <Security> <srd:Login>login_id</srd:Login> <srd:Password>password</srd:Password>...
2
by: Mystery Man | last post by:
We have an MDI application that is not setting always setting focus to the newly corrected MDI. It is creating the form and it is the topmost but it does not have focus. The code we are using to...
0
by: Morten Wennevik | last post by:
Given using a Parent and Child setup in MDI and overriding OnMdiChildActivate in the Parent, how come it seems to active the child I want active only every 2nd time? class Parent { private...
11
by: alex | last post by:
Hi, how can I access / set properties of controls in other forms. i.e. mdi parent of mdi child mdi child of mdi child mdi child of mdi parent Thanks Alex
7
by: msxkim | last post by:
How to execute functions in the parent class first and then functions in the child class? For example, I have a parent class with functions 'ONE' and 'TWO' and child class has a function 'THREE'. ...
10
by: Goran Djuranovic | last post by:
Hi all, Does anyone know how to declare a variable in a class to be accessible ONLY from a classes instantiated within that class? For example: ************* CODE ***************** Public...
6
by: mmcloughlin | last post by:
I'm learning about objects and am trying to figure out how basic inheritance works. I've got into the habit of explicitly setting the prototype object with an object literal as it seems to make the...
1
by: Blau | last post by:
I'm still trying to learn c#, and while doing so I am trying to convert some C++ code to C#. Doing so has kind of challenged my understanding of the way values and references work in C# when i'm...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.