Search

I have this: http://pastie.org/3567908

I am confused on how to refer to attributes and values in conditionals.

Can anyone provide some insight?

Second, does anyone have a tutorial that might help explain these types of items?

How familiar are you with XPath? You'll need to start there from what you are trying to accomplish.

I am only guessing what the XML output looks like. I've given you examples of how to select the text nodes and attribute nodes with XPath to output the values you are hoping to test. Use the same XPath expressions to test for various criteria.

XPathr: Code | Result

The reason your XSLT for Device Categorizr works and your Useragent Details XSLT doesn't is that Device Categorizr outputs a parameter where as Useragent Details outputs its own data source XML. To see the difference, append ?debug when viewing the frontend page when logged in as an admin and look at the structure of the extensions' XML.

For parameters, you can use {$parameter-name} anywhere in your XSLT templates without worrying about where in the XML the parameter appears. (Though you can also use XPath to access /data/params/parameter-name.)

For data sources, you must use XPath to get to the XML output. So for Useragent Details, if the XML is:

<data>
    <useragent-details mobile="no" chromeframe="no" robot="no">
        <browser version="5.2" handle="safari">Safari</browser>
        <operating-system handle="mac-os-x-lion" platform="Apple">Mac OS X Lion</operating-system>
        <ip-address>127.0.0.1</ip-address>
    </useragent-details>
</data>

You can do:

<xsl:choose>
    <xsl:when test="/data/useragent-details/browser = 'Safari'">
        ...
    </xsl:when>
    <xsl:otherwise>
        ...
    </xsl:otherwise>
</xsl:choose>

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