Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 16th, 2003, 10:14 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default XSLT Templates

Hello,

I have the following XML:

<Documents>
  <Section Title="Documentation" Sidebar="false">
    <Document>...</Document>
    <Document>...</Document>
    <Document>...</Document>
  </Section>
  <Section Title="Business Information" Sidebar="false">
    <Document>...</Document>
    <Document>...</Document>
    <Document>...</Document>
  </Section>
  <Section Title="Policy" Sidebar="true">
    <Document>...</Document>
    <Document>...</Document>
    <Document>...</Document>
  </Section>
</Documents>

What I want to do is trigger a different response when the sidebar is true then when false. In my stylesheet, I had did this:

<xsl:template match="Documents">
  <table>
    <tr>
      <td>
        <xsl:apply-templates select="Section[@Sidebar != 'true']"/>
      </td>
      <td width="20%">
        <xsl:apply-templates select="Section[@Sidebar = 'true']"/>
      </td>
    <tr>
  </table>
</xsl:template>

<xsl:template match="Section[@Sidebar = 'true']">
  ...
</xsl:template>

<xsl:template match="Section[@Sidebar != 'true']">
  ...
</xsl:template>

The sections where sidebar = true is supposed to be on the right side, and the rest in the main page. I couldn't get this to work. Any ideas what is wrong? How do I render content differently based on the sidebar parameter?

Thanks,

Brian Mains
__________________
Brian
 
Old December 16th, 2003, 10:53 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Works for me. What do you mean doesn't work? Can you post the full stylesheet?

--

Joe
 
Old December 16th, 2003, 02:36 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hello,

I found out the problem I had both a template for:
<template match="Section">
  which had defined in it
    <for-each select="Document">

However, I had also defined:

<template match="Document">

Which caused a "No result set could be returned" MSXML parser error.

Sorry for any inconvenience.

Thanks,

Brian





Similar Threads
Thread Thread Starter Forum Replies Last Post
C++ templates in XSLT paulo2005 XSLT 1 July 5th, 2007 04:27 PM
question on xslt templates -- urgent subbukns XSLT 1 May 21st, 2007 05:17 PM
simple XSLT apply-templates question fannus XSLT 7 March 27th, 2007 02:11 AM
dynamic xslt -> xslt creation namespace problem jkmyoung XSLT 2 July 15th, 2006 12:42 AM
xml and xsl templates as input to xslt gives xml rameshnarayan XSLT 5 August 3rd, 2005 01:58 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.