Search

I have a good question about an xPath query I need to complete.

I am trying to concatenate values in a Reflection Field, one being a Parent value, and the other being a Name value. What I currently have is:

{normalize-space(entry/parent)} {entry/name/@handle}

The normalize-space trims any whitespace for me so that my strings don't begin with a space.

Has anyone spotted the flaw, and the reason for this question? Well, anyway, I will explain... If there is no parent, then the string result always starts with a space, as that is what the expression tells it to do.

What I need to achieve is an xPath expression that will only add a space if the parent has a value. I've heard of the Becker Method but I have no idea how to apply this.

Any smarty-pants people out there know the answer?

Hmmm... dunno if this works but

{normalize-space(concat(normalize-space(entry/parent),' ',entry/name/@handle)}

Now why couldn't I see that!

There's a ) missing at the end, but that is definitely it! Cheers Nils...

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