# [web] Text styling with XSLT

This topic is 4863 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I am making a web page in XSLT and I want to be able to style text by using <i></i> tags (or something like that) but when I put them in the xml file nothing changes. How can I style my text (I want to be able to bold and do italics and stuff). This is where the stuff goes. I would like to be able to style the description.
. . .<table width="200" border="1">
<xsl:for-each select="namelist/names/item">
<tr>
<td height="55"><a href="{link}"><xsl:value-of select="name"/></a> - <xsl:value-of select="description"/></td>
</tr>
</xsl:for-each>
. . .

This is what the xml file is like:
<?xml version="1.0"?>
<people>
<item>
<name>Glockasnobbieshcan</name>
<description>This is a descriptiodk fjkjfkkjdkljv,m</description>
</item>

<item>
<name>Glockasnobbieshcan</name>
<description>This is a descriptiodk fjkjfkkjdkljv,m</description>
</item>

<item>
<name>Glockasnobbieshcan</name>
<description>This is a descriptiodk fjkjfkkjdkljv,m</description>
</item>
. . .
</people>

Any help would be greatly appreciated. (I'm pretty sure I can't spell)

##### Share on other sites
Try using "& lt ;em & gt ;" (spaces inserted to prevent HTMLization) instead of <em>, it should work (too lazy to check though). When you insert pure HTML into XML you're making more nodes (I'd think).

##### Share on other sites
I tried it but it doesn't work.

EDIT: I also tried that but it just ends up putting <em> </em> around the text.

##### Share on other sites
Yes it does if you use a DTD (best solution) or specify your XSL to transform them.

Here's an XSL solution, too lazy to look up DTD since it's been ages since I worked with XML transformations.

http://www.biglist.com/lists/xsl-list/archives/200209/msg00749.html

Edit, apparently I like Googling. Here's how you do the DTD:

http://www.thescarms.com/XML/DTDTutorial.asp

##### Share on other sites

<xsl:for-each select="people/item">

rather than

<xsl:for-each select="namelist/names/item">

or am i missing something?

##### Share on other sites
Quote:
 Original post by 6shouldn't your select statement read  rather thanor am i missing something?
Oh, yeah it should. I just forgot to change them. They were from an old project because I don't have the stuff I'm working on now with me and I was too lazy to open 2 files (yet, for some reason, I was suddenly un-lazy enough to type up the first item and copy and paste it).

##### Share on other sites
I think you might need something like <xsl:output method="text/html"/> or something like that near the beginning of your file...perhaps :)

##### Share on other sites
I already had something like that in the file so that can't be it...

<xsl:output method="html" encoding="iso-8859-1" doctype-public="-//W3C//DTD HTML 4.01 Strict//EN" doctype system="http://www.w3.org/TR/html4/strict.dtd"/>

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 14
• 12
• 29
• 11
• 44
• ### Forum Statistics

• Total Topics
634856
• Total Posts
3019661
×