Search

I cannot het my output to indent, even when set to html. I use php5/libxslt.

Is it impossible to indent on a life site? Or does it depend on your host (libxslt@host1 != libxslt@host2 ?) How do you get it working?

does this mean anything?

Note that if you want to use an XSLT feature such as <xsl:output method="html">orindent="yes", you can’t use transformToDoc(), because the DomDocument cannot retain this information.

Also my scripts

<script type="text/javascript">//<![CDATA[

do indent…

I’ve never got code to indent when method is html, and put this down to a libXSLT bug. It should indent fine when using xml as the output type.

Additionally I’ve found some libXSLT versions add the CDATA inside script tags when in xml mode (and maybe even in xml mode). I negated this using the xsl:comment method.

It’s not a bug. The specification notes that implementation of indentation can be up to the processor vendor – libXSLT simply do not support indentation with HTML.

I’ve read somewhere – although requires verification – that it’s to do with HTML’s general lack of symmetry which causes indentation headaches.

That being said, both Saxon and Sablotron support HTML indentation.

So in conclusion, all symphonians who have life sites (using libxslt, the only out of the box option) have messy xhtml sourcecode without indention?

The big noob seems to have indented code… so does this site. What are you runnign and how?
If I run into symphony sites with indented code it means they have some special hosting setup?

In that case the web host recommendations over here would better mention what kind of processors they have, just libxslt, or sablotron or…. what are the options for shared VPS or dedicated use?

what about pear or this

Maybe it would be cool to have a poll, ‘what are u using’, or can it be read from stats?

So in conclusion, all symphonians (…) have messy xhtml sourcecode without indention?

No, all Symphonians use XML as output method!

<xsl:output method="xml"
    doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
    doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
    omit-xml-declaration="yes"
    encoding="UTF-8"
    indent="yes" />

PHP 5 will come with LibXSLT by default. But you simply don’t need to use the HTML output option. XHTML is XML anyway.

So in conclusion, all symphonians who have life sites (using libxslt, the only out of the box option) have messy xhtml sourcecode without indention?

All Symphonians who have live sites and have indenting use XML as their output method. Take a look at the default theme’s xsl:output instruction, as Michael-e has kindly pointed out.

Maybe it would be cool to have a poll, ‘what are u using’, or can it be read from stats?

Anyone using Symphony 2 is on LibXSLT, which happens to also be Webkit’s choice of processor. Saxon is JAVA-based and Sablotron does not support PHP 5.

Aha thanks for clearing that up.

The reason I used html output is because I have inline-block styled elements and they need a xhtml comment in between them, to ensure that they stack up; in regular static xhtml this is solved with the comment eating up all space entities.

However, I sure would like to use xml. But cannot succeed in creating a comment right after the closing tag and right before the openign tag. There are always spaces in between the tags and the comment. I tried this:

   <xsl:strip-space elements="xsl:comment" />
   <li class="inline"></li><xsl:comment>gapless</xsl:comment></li>

but it doesnt give me the desired:

 <li class="inline"></li><!--gapless--></li>

because these lists are hardcoded, not fetched from nodes, I cannot use strip space.
Maybe <xsl:text> is an option?

http://www.xmlplease.com/whitespace

/me smells an attempt at Internet Explorer 6 compatibility :p

yes reading trough inline block again it seems the comment was a hack and is not needed for the betetr browsers.

yet it remains an interesting topic on how to place comments inline without spaces surounding them….

Ok I have indenting working on 1 site, but on another it just doesnt indent.
What could be the cause (error on my part) of indenting not working?
I read once that you need all your text in a xsltext tag otherwise it might upset the indention?

The code in my main template (match data) indents, but all the code in the other templates, like the one below doesn’t.

    <xsl:template match="h2" mode="arrow">
    <xsl:variable name="handle" select="@id" />
    <h2 class="arrow"><xsl:text>&#9;</xsl:text>
        <div class="gutter">
            <b class="aw"></b>
            <a href="{$root}/{$current-page}/{$language}/{@id}/#id{count(preceding-sibling::*[name() = 'h2' or name() = 'h3' or name() = 'h4'])}" title="?">    

                    <xsl:call-template name="getthumbnail"/>

                <span>
                    <xsl:copy-of select="text()"/>
                    <small>
                    <xsl:apply-templates select="key('immediate-nodes', generate-id())" mode ="short" />
                    </small>    
                </span>
            </a>
        </div>
    </h2>   
</xsl:template>

imho, i’d drop the IE6 support. Look at how much time you’ve spent trying to get one thing to work in IE6 when you could be improving the already (and i’m sure excellent!) functionality/usability of the site(s) you’re working on.

wdtan, as explained before the comment hack was left into the design from before, I realise now I dont need it, Im fine and move on, but….

Another indent problem popped up, on either browser, no indent from the code created by my templates, like the one pasted here.
I am clueless as to why ident doesnt work on them, bit does work on my match data template.

@newnomad. i guess i didn’t fully understand that comment. thanks for the clarification. is your output one long string that doesn’t break at all? or does it break into new lines?

intelligent question wdtan;

Indeed it does brake into new lines, blocks of lines with a lot of space between them. but these lines all start at the left of the page, no indent at all

BTW if you would know a way to force indentation on external datasources…. when setting them to choose the ‘last child elements of a feed, they result is one long unindented string, very nasty to debug ;-)

i was going to say if it’s one long string with no line breaks, then it’s usually some sort of html formatting issue. I know i’ve run into those in the past where something in my markup wasn’t formatted correctly so it wouldn’t indent or break where it needed to be…similar to your feed issue.

Thread closed — discussion continued at limited indenting.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details