XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old November 25th, 2003, 05:02 PM
annadeus annadeus is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Location: Wisconsin
Posts: 4 annadeus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question style not working in lists

I can't seem to make my underline (or bold) style work in an ordered or unordered list.

This is in the XSL Stylesheet:

<xsl:template match="utxt">
<u>
<xsl:apply-templates />
</u>
</xsl:template>



And this is the xml document:

<alphalist>
<item><utxt>I want this underlined</utxt> - But it won't do it. I really wish it would.</item>
</alphalist>

I have also tried this in the XSL stylesheet with no success:

<xsl:template match="utxt">
<span style="text-decoration:underline">
<xsl:apply-templates />
</span>
</xsl:template>


I'm going nuts. Please help.

Reply With Quote
  #2  
Old November 25th, 2003, 09:51 PM
tsprings tsprings is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Location: Seattle, WA
Posts: 55 tsprings User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 20 sec
Reputation Power: 5
Hello annadeus. I put your code into an xml and xsl files, and both worked fine. Perhaps there is something wrong with the link between the XML and the XSL? I'll include the example files I created.

u.xml

Code:
<?xml version="1.0" ?>
<?xml-stylesheet type="text/xsl" href="u.xsl" ?>
<alphalist>
    <item>
        <utxt>I want this underlined</utxt>
         - But it won't do it. I really wish it would.
    </item>
</alphalist>


u.xsl

Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="utxt">
   <u>
      <xsl:apply-templates />
   </u>
</xsl:template>
</xsl:stylesheet>


If you want to post the actual files I'll take a look at them.

Reply With Quote
  #3  
Old November 26th, 2003, 10:03 AM
annadeus annadeus is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Location: Wisconsin
Posts: 4 annadeus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hmmm...still doesn't work here.

Here are the relevant parts of my files:

test.xsl -
--------------------------------------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<html>
<head>
<style>
ol {margin-top:0px; margin-bottom:10px}
li {margin-top:4px; font-weight:normal}
</style>
</head>
<body>
<xsl:apply-templates />
</body>
</html>
</xsl:template>

<xsl:template match="section">
<div style="margin:0px 18px 12px 12px">
<xsl:apply-templates />
</div>
</xsl:template>

<xsl:template match="underline">
<u>
<xsl:apply-templates />
</u>
</xsl:template>

<xsl:template match="alphalist">
<ol type="a">
<xsl:apply-templates select="./*"/>
</ol>
</xsl:template>

<xsl:template match="item">
<li>
<xsl:value-of select="."/>
</li>
</xsl:template>

</xsl:stylesheet>
--------------------------------------------------------------

test.xml -
--------------------------------------------------------------
<?xml version="1.0" ?>
<?xml-stylesheet type="text/xsl" href="test.xsl" ?>
<!DOCTYPE topic SYSTEM "test.dtd">

<topic>
<section>

<alphalist>
<item>
<underline>I want this underlined</underline>
- But it won't do it. I really wish it would.
</item>
<item>
<underline>I want this underlined</underline>
- Still nothing.
</item>
</alphalist>

</section>
</topic>
--------------------------------------------------------------


Is there any special way I need to treat <underline> in the DTD?

Sorry, I'm new and dumb at this forum and don't know how to post my code all nice-like as you did!

Last edited by annadeus : November 26th, 2003 at 10:27 AM.

Reply With Quote
  #4  
Old November 26th, 2003, 10:57 AM
tsprings tsprings is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Location: Seattle, WA
Posts: 55 tsprings User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 20 sec
Reputation Power: 5
Hello again annadeus. Just a note, if your document doesn't exactly match up to what you have defined in your DTD, nothing will work. The underlining shouldn't have anything to do with the DTD - that should be done in the XSL document. I didn't have your DTD, so I don't know if it's correct, but after some tinkering I got your XSL to work. You will know if your DTD and your XML file match up by opening your XML file in IE - you will get an error if it is incorrect.

Ok, so using the same xml document you posted (minus the DTD reference, I rewrote your XSL to this: (Oh and by the way, to get the code to show up "all cool", put "["code"]" and "["/code"]", minus the quotation marks, on both ends of your code.)

Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!--I changed the formatting on this a bit, just because
    this is what I am used to, and for what you're doing 
    here it really cuts down on the code.
    
    Remember that periods select all the content that
    hasn't already been grabbed...  I think that is 
    probably where your problems were coming in. -->
<xsl:template match="/">
<html>
<head>
<style>
  ol {margin-top:0px; margin-bottom:10px}
  li {margin-top:4px; font-weight:normal}
</style>
</head>
 <body>
   <div style="margin:0px 18px 12px 12px">
     <ol type="a">
         <xsl:for-each select="/topic/section/alphalist/item"> 
             <li>
                 <!--Grab the underlined text and then
                     add all the rest of the content for 
                     item (using the .) -->
                 <u><xsl:value-of select="underline" /></u>
                 <xsl:value-of select="." />
             </li>
         </xsl:for-each>
     </ol>
   </div>
 </body>
</html>
</xsl:template>
</xsl:stylesheet>


I use the site W3 Schools when I'm trying to do anything with XML. You should check it out - it's very helpful.

Reply With Quote
  #5  
Old November 26th, 2003, 01:37 PM
annadeus annadeus is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Location: Wisconsin
Posts: 4 annadeus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I had to tweak your tweak to fit into my grand scheme of things, and the funny thing was that the underlined text would appear twice in a row.

I did, fortunately, manage to figure it out through mulitple incarnations of XSL file tinkering. It ended up being stupid, really.

I had this:

Code:
<xsl:template match="item">
   <li>
      <xsl:value-of select="."/>
   </li>
</xsl:template>


...when I should have had this:

Code:
<xsl:template match="item">
   <li>
      <xsl:apply-templates />
   </li>
</xsl:template>


Thanks a ton for your help, tsprings. I'm just starting to learn this stuff.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > style not working in lists


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway