Support » Themes and Templates » Need help toggling multiple XSL style sheets

  • In one of my template pages, I’m using PHP to load an XML doc and transform it with XSL. It displays in a Div just fine.

    My question is: I want to switch among multiple XSL files that transform this same XML doc. The idea is to let the user click a link that loads the appropriate XSL (to display the data in different ways). I was doing this easily when loading the XML with client-side AJAX, but with PHP, the XML is already rendered when the page loads. It’s not dynamic.

    I can probably use JavaScript to toggle visibility of multiple Divs, but that seems too processor-intensive. Any ideas?

    Here’s my PHP that works:

    $processor = new XSLTProcessor;
    $xsl = new DOMDocument;
    $current_dir = get_bloginfo('template_directory');
    $xsl -> load($current_dir . '/xml/myStyles.xsl');
    $processor -> importStyleSheet($xsl);
    $xml = new DOMDocument;
    $xml -> load($current_dir . '/xml/myData.xml');
    $result = $processor -> transformToXML($xml);
    echo "$result";

Viewing 1 replies (of 1 total)
  • In case anyone else is following this……I’ve achieved the effect I was looking for using tabbed panels (using the Spry panels in Dreamweaver, but I suppose jQuery or other panels will work, also). Each panel uses the same code I posted above, except they each call a different XSL file.

    But still: if anyone has a better idea, please speak up.

Viewing 1 replies (of 1 total)
  • The topic ‘Need help toggling multiple XSL style sheets’ is closed to new replies.