Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: formatting text with XSLT

From: Richard Light <richard@-----.-----.--.-->
To: NULL
Date: 4/1/2005 9:13:00 AM
The specific problem is that this code:

        <xsl:value-of select="."/>
        <p/>

outputs the text of your <song> element, followed by an empty paragraph. 
If you want the text _inside_ the paragraph, do:

        <p>
          <xsl:value-of select="."/>
        </p>

However, this won't get you a lot further: the basic markup of each song 
is a bit on the light side.  If you had e.g.:

<verse>
<l>I'm not a perfect person</l>
<l>As many things I wish I didn't do</l>
...
</verse>
<verse>
<l>I've found a reason for me</l>
...

it would be possible to make much better use of the information, and 
specifically it would make it easy to format it nicely using XSLT.

Richard

In message <1112341386.324916.126000@o...>, 
Steven <steven.beckham@g...> writes
>-------------------XML File-----------------------
>
><?xml version="1.0"?>
><?xml-stylesheet type="text/xsl" href="/BBN/songs.xsl"?>
>
><data>
>       <artist>Hoobastank</artist>
>       <album>The Reason</album>
>       <release>2004</release>
>       <song title="The Reason" track="08">
>       I'm not a perfect person
>       As many things I wish I didn't do
>       But I continue learning
>       I never meant to do those things to you
>       And so I have to say before I go
>       That I just want you to know
>
>       I've found a reason for me
>       To change who I used to be
>       A reason to start over new
>       And the reason is you
>       </song>
></data>
>
>^^^^^^^^^^^^^^^^^^^^^^^^^^XML File^^^^^^^^^^^^^^^^^^
>
>----------------------XSL File----------------
>
><?xml version="1.0"?>
><xsl:stylesheet version="1.0"
>xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
><xsl:template match="data">
>       <html>
>               <head>
>                       <title>
>                               <xsl:value-of select="artist"/> -
><xsl:value-of select="album"/>
>                       </title>
>               </head>
>               <body bgcolor="#FFFFCC">
>                       <table border="0" width="835" cellspacing="3"
>cellpadding="2">
>                               <tr>
>                                       <td align="center">
>                                               <font size="5"><i>
>                                                       <xsl:value-of
>select="artist"/> - <xsl:value-of select="album"/>
>                                               </i></font>
>                                       </td>
>                               </tr>
>                                       <xsl:for-each select="song">
>                                       <xsl:sort select="./@track"/>
>                                               <tr>
>                                                       <td>
>
><xsl:apply-templates select="."/>
>                                                       </td>
>                                               </tr>
>                                       </xsl:for-each>
>                       </table>
>               </body>
>       </html>
></xsl:template>
>
><xsl:template match="song">
>       <font size="4"><b>
>               <xsl:value-of select="@title"/>
>       </b></font>
>       <br/>
>       <xsl:value-of select="."/>
>       <p/>
></xsl:template>
>
></xsl:stylesheet>
>^^^^^^^^^^^^^^^^^^^^^^^^XSL File^^^^^^^^^^^^^^^^^^^^^^^
>

-- 
Richard Light
SGML/XML and Museum Information Consultancy
richard@l...



transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent