开发者

XSL / XSLT making text and <xsl:for-each> bold

I have a XSL template, within that , I need a section to be bold or at least a heavier weight font / larger font.

Your name -
    &开发者_开发技巧lt;xsl:for-each select="date">
    <xsl:value-of select="substring(.,1,25)"/>
    </xsl:for-each>

So "Your Name" needs to be bold, but so does the dynamically generated "date" .

Ive tried wrapping the bold tags around etc. , but understand thats not how XSL really works. I cannot find a solution though. Thanks in advance.


May be complete example can be helpful.

XML:

<t>
    <date>2010-10-02</date>
    <date>2010-10-02</date>
    <date>2010-10-02</date>
    <date>2010-10-02</date>
    <date>2010-10-02</date>
    <date>2010-10-02</date>
</t>

XSL:

<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="html"/>

    <xsl:template match="/t">
        <strong>
            <xsl:text>Your name - </xsl:text>
            <xsl:for-each select="date">
                <xsl:value-of select="substring(.,1,25)"/>
            </xsl:for-each>
        </strong>
    </xsl:template>     
</xsl:stylesheet>

Output as source code (linebreak for clarity only):

<strong>Your name - 
2010-10-022010-10-022010-10-022010-10-022010-10-022010-10-02</strong>

Output as rendered:

Your name - 2010-10-022010-10-022010-10-022010-10-022010-10-022010-10-02


is this going to be rendered in HTML?

i am not an XSLT expert but I don't see anything wrong with wrapping the bold tags.

<h1>
Your name -
    <xsl:for-each select="date">
    <xsl:value-of select="substring(.,1,25)"/>
    </xsl:for-each>
</h1>


I think you mean sth like:

Your name -
    <span style="font-weight:900">
       <xsl:for-each select="date">
          <xsl:value-of select="substring(.,1,25)"/>
       </xsl:for-each>
    </span>

The 900 is the maximum. There are plenty of other possible values for the font-weight CSS attribute. However from your question, I suspect the font-weight in parent element(s) is impacting the rendering of the whole excerpt.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜