[web] Text styling with XSLT

Started by
7 comments, last by Xipe 18 years, 4 months ago
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>
        <link>http://www.google.com/</link>
    </item>

    <item>
        <name>Glockasnobbieshcan</name>
        <description>This is a descriptiodk fjkjfkkjdkljv,m</description>
        <link>http://www.google.com/</link>
    </item>

    <item>
        <name>Glockasnobbieshcan</name>
        <description>This is a descriptiodk fjkjfkkjdkljv,m</description>
        <link>http://www.google.com/</link>
    </item>
. . .
</people>
Any help would be greatly appreciated. (I'm pretty sure I can't spell)
F-R-E-D F-R-E-D-B-U-R...G-E-R! - Yes!
Advertisement
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).
--There is only one basic human right and that is the right to do as you damn well please, and with that right comes the only human duty; the duty to take the consequences.-- P.J. O'Rourke
I tried it but it doesn't work.

EDIT: I also tried that but it just ends up putting <em> </em> around the text.
F-R-E-D F-R-E-D-B-U-R...G-E-R! - Yes!
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
--There is only one basic human right and that is the right to do as you damn well please, and with that right comes the only human duty; the duty to take the consequences.-- P.J. O'Rourke
shouldn't your select statement read

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


rather than

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


or am i missing something?
----------------------------------------------------
Check out my casual TBS game blog
----------------------------------------------------
Quote:Original post by 6
shouldn't your select statement read

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


rather than

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


or 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).

F-R-E-D F-R-E-D-B-U-R...G-E-R! - Yes!
I think you might need something like <xsl:output method="text/html"/> or something like that near the beginning of your file...perhaps :)
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"/>
F-R-E-D F-R-E-D-B-U-R...G-E-R! - Yes!
How about you read my posts and either define your XML or transform it. ;)
--There is only one basic human right and that is the right to do as you damn well please, and with that right comes the only human duty; the duty to take the consequences.-- P.J. O'Rourke

This topic is closed to new replies.

Advertisement