Search

See tl;dr at bottom

Having some unexpected problems creating a new dev version of a live Symphony site.

I moved everything over into a MAMP directory, exported the database from the live site and attached it to the local one (making sure to update the database login credentials and the htaccess to have the appropriate rewrite base) but the front-end is completely failing.

I say the front-end because the backend is absolutely fine. I can log in and browse all of the sections/entries and everything is fine and in place - all the relationships are intact and I can browse the pages/ds/utililties fine and they're all as they should be.

But loading up the homepage throws out more XSLT errors than you can throw a stick at. Everything seems to be an XSLTProcessor::transformToXml(): error, and they show up for pretty much every tag on the page, from param to img.

What's the deal?

EDIT 1:

In case it adds more context the general errors all look like this:

Internal error: Failed to evaluate the AVT of attribute 'content'.
Variable 'OGTitle' has not been declared.
xmlXPathCompiledEval: evaluation failed

EDIT 2:

Ok, so after a lot of experimentation I managed to work-around the issue. Turns out the problem was being caused by declaring param within the templates. But this has never been an issue before. I'm guessing it must be a difference between the MAMP and server environment.

Any clues as to what it might be that's different? I'd rather not have to re-write all of the templates to move the params out of the template and change params within for-each loops to variables - unless I should be doing it this way anyway? I just like to keep things grouped and contextual, and given that it's not an issue in the live environment I'm assuming it's 'OK'.

EDIT 3:

Ok so at least I haven't gone crazy, according to the specs "The parameter is global if it's declared as a top-level element, and local if it's declared within a template." - had me doubting it there for a minute though.

tl;dr What causes an environment to reject param tags within a template?

Params must always be declared first in a template, before any other content. Maybe you missed that?

My feeling is that you made some mistake that was forgiven by your server version of libXSLT but made your local version vomit. Have you looked up the version numbers?

Ah, so they can occur in a template but need to be called at the beginning of the template, i.e. immediately after the template tag?

In which case it sounds like you're right, our server was breeding bad habits in me.

Out of interest how do you create params within for-each statements? Or do you have to use variables?

MAMP libXSLT version is 1.1.26

Server libXSLT version is 1.1.17

create params within for-each statements

I don't exactly know what you mean. You have to declare them at the beginning, and may use them later.

<xsl:template match="lala">
    <xsl:param name="foo"/>
    <div class="bar">
        <xsl:value-of select="foo"/>
    </div>
</xsl:template>

[EDIT]: It's the same with for-each.

So like this?

<xsl:template match="lala">
    <xsl:param name="foo"/>
    <xsl:for-each select="section/entry">
        <xsl:param name="foo" select="value"/>
        <xsl:value-of select="foo"/>
    </xsl:for-each>
</xsl:template>

Actually I'm not entirely sure what my need for that was, bit of dodgy coding going on I think. Unless that is a viable scenario? It's been a long evening.

No, that line doesn't make sense:

<xsl:param name="foo" select="value"/>

More context:

<xsl:for-each select="blog/entry">  
   <xsl:param name="slug" select="title/@handle"/>
</xsl:for-each>

Although this is only really required when you need to repeat the same bit of data and the XPath happens to be a bit unwieldy, thereby making things a bit easier to work with. Although this might be a completely inappropriate workflow that I was accidentally able to use.

As that value wouldn't be changing there's also no point in using a parameter over a variable. So the points probably moot anyway. As you might have noticed I'm still pretty new to XSLT :)

Yep, that won't work. Still I don't really know what you are trying to achieve here, but it's not the right use of params. If you post more code, I can hopefully help you.

@nathanhornby - could you post your XSLT and your XML?

@bzerangue

I sorted the problem way back up the thread, I just needed to clear parameters out of for-each loops, I was basically using them like variables - and an older version of libXSLT allowed me to do so as demonstrated above. I was just asking what the correct approach to that scenario would be, but I'm guessing you'd just use a variable, I wasn't insisting it would work, just that it did work on 1.1.17, causing me to pick up a bad habit.

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