使用xslt中的属性值修改内容 [英] Modifying contents using attribute values in xslt

查看:83
本文介绍了使用xslt中的属性值修改内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我的XML文件如下.

Hi All,
I have my xml file as below.

<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>



两个标题标签都包含文本A. N. AIYAR''S.但是我需要根据它们的属性值ID = pgfId-1104984&将它们显示为不同的字体大小. pgfId-1104972.



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?

推荐答案

Hello Rahulaaditya,

我强烈建议您查阅任何基本的XSLT教程或书籍(因为您在过去几周中曾问过有关XML,HTML,CSS,XSLT的一些非常基本的问题).
例如. http://www.w3schools.com/xsl/ [
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


< xsl:choose>
< xsl:何时测试="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:何时测试="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>
<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>


这篇关于使用xslt中的属性值修改内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆