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

RE: why no indent here

Subject: RE: why no indent here
From: Roelof Wobben <rwobben@xxxxxxxxxxx>
Date: Mon, 12 Dec 2011 12:25:37 +0000
RE:  why no indent here
I found a answer here
(http://www.dpawson.co.uk/xsl/sect2/N7240.html#d10122e376) but it seems no to
work here.

So I have this xslt :

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"

     method=" xml"
     doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
     indent="yes" />

<xsl:template match="/">
     <xsl:apply-templates select="data/params" mode="top" />
             <div id="outer">
                 <div id="container">
                     <div id="search">
                         <form method="get" id="searchform"
                             <input type="text" value="" name="s" id="s"
class="txtField" />
                             <input type="submit" id="searchsubmit"
class="btnSearch" value="Find It " />
                         <div id="title">
                             <h2><xsl:text>Tamara Wobben</xsl:text></h2>
                     <div id="content">
                        <div class="col01">
                             <xsl:apply-templates select="data/section/entry"
                         <div class="side-columns">
                             <div class="col02">
                                 <div class="pages">
                                     <!-- hier komen de losse pagina's -->
                                 <div class="categories">
                                    <!-- hier komt het menu  -->
                             <div class ="col03">
                                <!-- hier komen de recente posts -->

<xsl:template match="data/params" mode="top"  >
           <xsl:value-of select="root"/>
       <link rel="stylesheet"
s" type="text/css" media="screen" />

<xsl:template match="section/entry">
     <div class="post">
        <h3><xsl:value-of select="title"/> </h3>
             <div class="post-inner">
                 <xsl:apply-templates select="data/section/entry/body/text()"

<xsl:template match="body//text()">
    <xsl:call-template name="make-verbatim">
       <xsl:with-param name="text" select="."/>

   <xsl:template name="make-verbatim">
     <xsl:param name="text" select="''"/>

     <xsl:variable name="starts-with-space"
                   select="substring($text, 1, 1) = ' '"/>

     <xsl:variable name="starts-with-nl"
                   select="substring($text, 1, 1) = '&#xA;'"/>

     <xsl:variable name="before-space">
       <xsl:if test="contains($text, ' ')">
         <xsl:value-of select="substring-before($text, ' ')"/>

     <xsl:variable name="before-nl">
       <xsl:if test="contains($text, '&#xA;')">
   select="substring-before($text, '&#xA;')"/>

       <xsl:when test="$starts-with-space">
         <xsl:call-template name="make-verbatim">
           <xsl:with-param name="text"

       <xsl:when test="$starts-with-nl">
         <xsl:call-template name="make-verbatim">
           <xsl:with-param name="text"

       <!-- if the string before a space
   is shorter than the string before
            a newline, fix the space...-->
       <xsl:when test="$before-space != ''
                       and ((string-length($before-space)
                             &lt; string-length($before-nl))
                             or $before-nl = '')">
         <xsl:value-of select="$before-space"/>
         <xsl:call-template name="make-verbatim">
           <xsl:with-param name="text"
   select="substring-after($text, ' ')"/>

       <!-- if the string before a newline
   is shorter than the string before
            a space, fix the newline...-->
       <xsl:when test="$before-nl != ''
                       and ((string-length($before-nl)
                             &lt; string-length($before-space))
                             or $before-space = '')">
         <xsl:value-of select="$before-nl"/>
         <xsl:call-template name="make-verbatim">
           <xsl:with-param name="text"
   select="substring-after($text, '&#xA;')"/>

       <!-- the string before the newline and the string before the
            space are the same; which means they must both be empty -->
         <xsl:value-of select="$text"/>


And this is my full xml :

<?xml version="1.0" encoding="utf-8" ?>
<website-name>Tamara Wobben</website-name>
<item handle="1">&lt;span class=&quot;order&quot;&gt;1&lt;/span&gt;</item>
<events />
<section id="6" handle="sections">Sections</section>
<entry id="9">
 <title handle="even-voorstellen">Even voorstellen</title>
 <body>Naam : Tamara Wobben
         Geboorte gewicht : 2000 gram
         Geboorte lengte : 44 cm.
         Geboortedatum : 1 september 2005

But no not a single character is shown.


> Date: Mon, 12 Dec 2011 09:15:56 +0000
> From: mike@xxxxxxxxxxxx
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re:  why no indent here
> >So I can't preserve the linebreaks in the xml file into the html file ?
> If you do "view source" you'll see that the line breaks are indeed
> present in your HTML. The problem is that line breaks in HTML aren't
> displayed as line breaks by the browser. To get a line break in the
> browser output, you need a <br> element in the HTML.
> The question "how do I convert linebreaks into <br> elements" is FAQ
> and you should be able to find an answer by googling.
> Michael Kay
> Saxonica

Current Thread


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.
First Name
Last Name
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.