RE: [xsl] HTML in an XML tag

Subject: RE: [xsl] HTML in an XML tag
From: "Mac Rost" <mrost@xxxxxxxxxxxxx>
Date: Thu, 5 Sep 2002 11:18:33 -0500
Tom]

[[That is because I made an slightly incorrect assumption about the form
of
your escaped characters.  Here is a tiny modification that does work
with
your full xml example.  It also puts out html (which the previous
stylesheet
did not).  Note that (if I understand what you want to do), that you do
not
need to use disable-output-escaping, as someone suggested.]]


Thank you for that example... how can I modify it to actually insert the
'break'into the html output? That way when it's displayed it wouldn't be
one long line?
Thank you in advance,
Mac


Mac Rost]

[[
Tom,
I have tried this solution but was unable to make it work... here is the
whole xml file that's being used.
]]



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

<xsl:template match="/HotelInfo">
<html>
 <xsl:apply-templates/>
</html>
</xsl:template>

<xsl:template match='areaInformation'>
<div>

<!-- Call the recursive string splitter -->
 <xsl:call-template name='break-at-string'>
    <xsl:with-param name='data' select='.'/>
    <xsl:with-param name='separator' select='"&lt;br&gt;"'/>
 </xsl:call-template>

</div>
</xsl:template>

<xsl:template name='break-at-string'>
   <xsl:param name='data'/>
   <xsl:param name='separator'/>

  <xsl:variable name='first'
select='substring-before($data,$separator)'/>
  <xsl:variable name='rest' select='substring-after($data,$separator)'/>

 <xsl:choose>
     <!-- When there is a separator in the string, display
            the first part followed by a <br/>, then call ourself to
process
the rest  -->
    <xsl:when test='$rest'>
       <xsl:value-of select='$first'/><br/>
       <xsl:call-template name='break-at-string'>
            <xsl:with-param name='data' select='$rest'/>
            <xsl:with-param name='separator' select='$separator'/>
       </xsl:call-template>
   </xsl:when>

   <!-- If there are no more separators, we are done -->
   <xsl:otherwise>
       <xsl:value-of select='$data'/>
   </xsl:otherwise>
 </xsl:choose>
</xsl:template>

<!-- Suppress output from the default template-->
<xsl:template match='*'/>

</xsl:stylesheet>
===================================================

[[
<HotelInfo>
  <hotelID>122352</hotelID>
  <propertyType>H</propertyType>
  <rating>3.0</rating>
<!-- other elements deleted to save space - tpb -->
  <areaInformation>Area Attractions: -Cherry Creek State Park 1 Block
&lt;br&gt; -Aurora Mall 2 Miles &lt;br&gt; -Movie Theaters 4 Miles
&lt;br&gt; -Fidlers Green 10 Miles &lt;br&gt; -Park Meadows Mall 15
Miles &lt;br&gt; -Downtown Denver 20 Miles</areaInformation>
  </HotelInfo>
]]



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


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


Current Thread