Search

Sorry if this is a dumb question, but I'm going to ask it anyway. Been searching around and can't quite get clarity around XML within variables.

I know its possible to create a variable with XML within it, like this:

<xsl:variable name="months">
    <month number="01">January</month>
    <month number="02">February</month>
    <month number="03">March</month>
    <month number="04">April</month>
    <month number="05">May</month>
    <month number="06">June</month>
    <month number="07">July</month>
    <month number="08">August</month>
    <month number="09">September</month>
    <month number="10">October</month>
    <month number="11">November</month>
    <month number="12">December</month>
</xsl:variable>

But then is it possible to perform a select statement kinda like this?

<xsl:value-of select="$months/month/@number = $month"/>

I think so; however it would look more like this

<xsl:value-of select="$months/month[@number = $month]"/>

Hmmm, I just tried that without success. That line errors out and says "Invalid type: XPath evaluation returned no result"

You need to make use of exsl:node-set functionality, so it might look like this:

exsl:node-set($months)/month[@number = $month]

Edit: Removed typo ;)

You need to make use of exsl:node-set functionality, so it might look like this:

And don't forget to include the common namespace.

Great, got it to work by using exsl:node-set instead of exslt:node-set, not sure if that was a typo or if I set up my namespaces differently. Either way, thanks for the help.

Researching the namespaces landed me here, good to learn more about exsl, I've never known much about it while using Symphony.

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