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:
  #1  
Old January 6th, 2003, 10:05 AM
marron79's Avatar
marron79 marron79 is offline
Rut row Raggy!
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jul 2001
Location: Tornado Alley
Posts: 558 marron79 User rank is Private First Class (20 - 50 Reputation Level)marron79 User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 9 h 41 sec
Reputation Power: 8
Question Spaces and HTML links in XSL

I have an XML document that I'm trying to convert to HTML w/a XSL stylesheet. I've got everything to work, but am having trouble w/two things.

Number one, how do you create a space in XSL? In HTML you use the non-breaking space symbol. This, of course, is not recognized by the XML parser.

Number two, how do you create a http link in XSL, and include the value of a XML document entity in the link? In PHP, I accomplish this by doing something like this:

echo "<a href=\"audio/$clipid\">mp3 clip</a>";

Here's my XML document:

Code:
<?xml version="1.0"?>
<?xml:stylesheet type="text/xsl" href="test.xsl"?>

<album>
	<artist>Rippingtons</artist>
	<title>Weekend In Monaco</title>
	<year>1992</year>
	<label>GRP Records</label>
	<rating>5</rating>
	<comments>Nothing.</comments>
	<song>
		<title>Indian Summer</title>
		<clipid>rippindi</clipid>
		<composer>R. Freeman</composer>
		<length>2:00</length>
	</song>
</album>


And here's my XSL document:

Code:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
	<font face="arial" size="2">
		<b>Artist:</b>  <xsl:value-of select="album/artist" /><br />
		<b>Title:</b>  <xsl:value-of select="album/title" /><br />
		<b>Year:</b>  <xsl:value-of select="album/year" /><br />
		<b>Label:</b>  <xsl:value-of select="album/label" /><br />
		<b>Comments:</b>  <xsl:value-of select="album/comments" /><br />
		<b>Song Title:</b> <xsl:value-of select="album/song/title" /><br/>
		<a href="<xsl:value-of select="album/song/clipid" />"mp3 clip</a> <--[this obviously won't work--it's just an example of what I'm trying to do]
	</font>
</xsl:template>

</xsl:stylesheet>
__________________
Matt

Last edited by marron79 : January 6th, 2003 at 10:07 AM.

Reply With Quote
  #2  
Old January 6th, 2003, 01:35 PM
MJEggertson MJEggertson is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2002
Location: Seattle WA
Posts: 863 MJEggertson User rank is Corporal (100 - 500 Reputation Level)MJEggertson User rank is Corporal (100 - 500 Reputation Level)MJEggertson User rank is Corporal (100 - 500 Reputation Level)MJEggertson User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 22 sec
Reputation Power: 8
Define a space in a dtd.
Code:
<!ENTITY nbsp " ">

For defining anchors, use something like this:
Code:
<xsl:element name="a">
  <xsl:attribute name="href">
    <xsl:value-of select="album/song/title" />
  </xsl:attribute>
</xsl:element>

Reply With Quote
  #3  
Old January 6th, 2003, 11:21 PM
marron79's Avatar
marron79 marron79 is offline
Rut row Raggy!
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jul 2001
Location: Tornado Alley
Posts: 558 marron79 User rank is Private First Class (20 - 50 Reputation Level)marron79 User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 9 h 41 sec
Reputation Power: 8
Thanks, but the link thing doesn't work. It doesn't display anything.

Reply With Quote
  #4  
Old January 7th, 2003, 12:58 PM
MJEggertson MJEggertson is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2002
Location: Seattle WA
Posts: 863 MJEggertson User rank is Corporal (100 - 500 Reputation Level)MJEggertson User rank is Corporal (100 - 500 Reputation Level)MJEggertson User rank is Corporal (100 - 500 Reputation Level)MJEggertson User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 22 sec
Reputation Power: 8
Put some content in the link.
Code:
<xsl:element name="a">
  <xsl:attribute name="href">
    <xsl:value-of select="album/song/clipid" />
  </xsl:attribute>
  <xsl:value-of select="album/song/title" />
</xsl:element>

Last edited by MJEggertson : January 7th, 2003 at 01:00 PM.

Reply With Quote
  #5  
Old January 7th, 2003, 01:52 PM
marron79's Avatar
marron79 marron79 is offline
Rut row Raggy!
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jul 2001
Location: Tornado Alley
Posts: 558 marron79 User rank is Private First Class (20 - 50 Reputation Level)marron79 User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 9 h 41 sec
Reputation Power: 8
It worked! Thanks!!

Reply With Quote
  #6  
Old February 7th, 2004, 12:07 AM
khwang's Avatar
khwang khwang is offline
Über nübe
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Babylon 4
Posts: 240 khwang User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 m 27 sec
Reputation Power: 6
Quote:
Originally posted by MJEggertson
Define a space in a dtd.
Code:
<!ENTITY nbsp " ">



finally, I can add multiple spaces!
__________________
Hello, old friend...

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > Spaces and HTML links in XSL


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 5 hosted by Hostway
Stay green...Green IT