[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: HTML in an XML tag

Subject: RE: HTML in an XML tag
From: "Mac Rost" <mrost@xxxxxxxxxxxxx>
Date: Thu, 5 Sep 2002 11:18:33 -0500
mac rost
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.