Click here to Skip to main content
15,894,017 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,
I have my xml file as below.

XML
<XML>
    <DIV>
        <Title>
            <A ID="pgfId-1104972"/>
            A. N. AIYAR’S	
        </Title>
    </DIV>
    <DIV>
        <Title>
            <A ID="pgfId-1104984"/>
            A. N. AIYAR’S
        </Title>
    </DIV>
</XML>


Both the title tags contains text A. N. AIYAR'S. But I need to display them in different font sizes based on their attribute values ID=pgfId-1104984 & pgfId-1104972.
Is it possible?
Posted
Updated 9-Jul-12 20:52pm
v2

Hello Rahulaaditya,

I strongly suggest to consult any basic XSLT tutorial or book (since you did ask in the last few weeks some very basic questions on XML, HTML, CSS, XSLT).
E.g. http://www.w3schools.com/xsl/[^] is a valuable source for getting answers on HTML, XML, XSLT, XPATH, et.al.

It seems to me that you try to swollow a chunk that is a bit too big for your current knowledge.

E.g. what you need to know for this is the following XSLT constructs:
- xsl:apply-template (for the title nodes)
- xsl:choice (to decide on the ID node on what font to apply)

If you are not familiar with how to apply a font in HTML or CSS, also consult w3schools for that.

Cheers
Andi
 
Share this answer
 
Comments
rahulaaditya 13-Jul-12 1:01am    
Dear Andi,

I tried it all way but could not find a better solution for my query. Could you please help me out from this?.
Andreas Gieriet 17-Jul-12 10:32am    
1) Let's start with the font settings: show in HTML or CSS how you want it to be. Write a simple HTML/CSS that sets the font of some text. Show the resulting HTML text here.
2) Once you have that, write a small XSLT file that does some processing on all Title elements (e.g. make text red) of the XML file in your original post (xsl:apply-template...). Show the result here.
3) Finally enhance the XSLT with a xsl:choice construct apply red text for one of the IDs and green for the others. Show the results here.

Now, instead of red and green, set the different fonts accordingly (as you found out in item 1 obove on how to do it in HTML/CSS).

If you want to do anything reasonable yourself in XSLT, these pieces above are the very basics you need to master *yourself*. Did w3schools didn't help in sorting the things out?

Cheers
Andi
rahulaaditya 20-Jul-12 7:57am    
Thank you very much for your suggestion and guide. :)
Andreas Gieriet 21-Jul-12 12:06pm    
You are welcome!
Cheers
Andi
<xsl:choose>
<xsl:when test ="A[@ID='pgfId-1104972']">
<div style="text-align:center;font-family:verdana;font-size:12px">
<div style="text-align:center;font-family:verdana;font-size:12px">
<b>
<xsl:value-of select ="Bold"/>
</b>
<xsl:value-of select ="text()"/>
</div>
</div>
</xsl:when>
<xsl:when test ="A[@ID='pgfId-1104984']">
<div style="text-align:center;font-family:verdana;font-size:12px">
<div style="text-align:center;font-family:verdana;font-size:14px">
<b>
<xsl:value-of select ="Bold"/>
</b>
<xsl:value-of select ="text()"/>
</div>
</div>
</xsl:when>
</xsl:choose>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900