RE: [xsl] xml and xslt to html attribute problems

Subject: RE: [xsl] xml and xslt to html attribute problems
From: "Passin, Tom" <tpassin@xxxxxxxxxxxx>
Date: Wed, 29 Oct 2003 10:39:43 -0500
[ Michael Olszynski]

> Hello, I want to use sth. like
> 
>     <topic name="Mygreatlongword<br>onabeautifulmorning">
> 
>  with following xslt code
> 
> <td>    <xsl:value-of select="@name"/>
> </td>
> 
> to get this html code
> 
> <td>
>     Mygreatlongword
>     <br>
>     onabeautifulmorning
> </td>
> 

I see that no one else has recommended outright that you change the
source so that the text content is not in an attribute but in element
content.  That is what you should be doing if it is at all possible.  If
it is not possible, you have another problem because your example is not
well-formed XML at all (no elements are allowed in the value of an
attribute).

I would make my xml source something like this -

<topic><name>Mygreatlongword<br/>onabeautifulmorning</name>....</topic>

Of course, with this approach you would not really need to put a <br/>
in at all, just an ordinary line break. 

On the other hand,  it would seem that there is some meaning to the
break between the left and right sides of your content, as if "My
greatlongword" is the name and "onabeautifulmorning" is the value.  If
this is correct, you would do better if your xml source reflected the
distinction in the first place.  this would be another reason for
looking to redesign the xml design.  Once the design reflects the
structure of your data, it will be much easier to get a stylsheet to do
things you want to do.

Cheers,

Tom P

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread