|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
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. |
|
#2
|
|||
|
|||
|
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>
|
|
#3
|
||||
|
||||
|
Thanks, but the link thing doesn't work. It doesn't display anything.
|
|
#4
|
|||
|
|||
|
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. |
|
#5
|
||||
|
||||
|
It worked! Thanks!!
|
|
#6
|
||||
|
||||
|
Quote:
finally, I can add multiple spaces! ![]()
__________________
Hello, old friend... |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > Spaces and HTML links in XSL |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|