[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: "Thomas B. Passin" <tpassin@xxxxxxxxxxxx>
Date: Thu, 5 Sep 2002 11:36:36 -0400
xml tag in html
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.
]]

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.

==========================================================
<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


Current Thread
  • RE: HTML in an XML tag
    • Mac Rost - Wed, 4 Sep 2002 18:08:28 -0400 (EDT)
      • Michael Kay - Thu, 5 Sep 2002 04:25:22 -0400 (EDT)
      • Thomas B. Passin - Thu, 5 Sep 2002 11:35:50 -0400 (EDT) <=
      • <Possible follow-ups>
      • Mac Rost - Thu, 5 Sep 2002 08:10:09 -0400 (EDT)
      • Mac Rost - Thu, 5 Sep 2002 12:17:30 -0400 (EDT)
      • Mac Rost - Thu, 5 Sep 2002 14:21:30 -0400 (EDT)

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.