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 July 19th, 2005, 11:24 AM
Registered User
 
Join Date: Jul 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Suppressing Results in the Final Document

I've looked everywhere and tried searching using different keywords, but to no avail... Please excuse me if this question has been asked and answered already. I'm new to XSLT and my terminology may not be 100% correct, so please bear with me.

Here's the problem: I want to use the XSLT style sheet to remove results from the final document based on whether or not a specific element is present.

So for example, the XML code may look something like this:

<ITEM>
  <NUMBER>2</NUMBER>
  <DATE>7-12-2005</DATE>
  <TITLE>Random Title</TITLE>
</ITEM>
<ITEM>
  <NUMBER>3</NUMBER>
  <DATE>7-8-2005</DATE>
  <TITLE>Random Title 2</TITLE>
  <DELETE>7/19/2005</DELETE>
</ITEM>

When the original XML document is processed by the XSLT style sheet, I want to remove results from the final (HTML) document if the DELETE element is present.

Can anyone provide some help there?

Thanks,
Jennifer
 
Old July 20th, 2005, 02:21 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

You can't remove results as such, you can avoid putting them there. You'll have to show a bit more of your xslt.

--

Joe (Microsoft MVP - XML)
 
Old July 20th, 2005, 09:23 AM
Registered User
 
Join Date: Jul 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The stylesheet is as follows:

<xsl:template match="ITEM">
    <h4><a><xsl:attribute name="href"><xsl:value-of select="LINK"/></xsl:attribute>
    <xsl:value-of select="TITLE"/></a><br/>
    <xsl:value-of select="DATE"/></h4>
</xsl:template>
 
Old July 21st, 2005, 08:55 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Well if you mean you don't want to output the ITEM element if it has a DELETE child then you need to change the select from:
Code:
<xsl:apply-templates select="ITEM[not(DELETE)]"/>
or change the matching template, having one for each type:
Code:
<xsl:template match="ITEM[DELETE]"/>
and
Code:
<xsl:template match="ITEM[not(DELETE)]">
    <h4><a><xsl:attribute name="href"><xsl:value-of select="LINK"/></xsl:attribute>
    <xsl:value-of select="TITLE"/></a><br/>
    <xsl:value-of select="DATE"/></h4>
</xsl:template>
--

Joe (Microsoft MVP - XML)
 
Old July 21st, 2005, 02:55 PM
Registered User
 
Join Date: Jul 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you very much for your help!

I used the following option and it worked perfectly!

Code:
<xsl:apply-templates select="ITEM[not(DELETE)]"/>
Jennifer





Similar Threads
Thread Thread Starter Forum Replies Last Post
Suppressing Data Pankaj C XSLT 12 October 23rd, 2007 06:44 AM
suppressing system message??? aspuser27 Excel VBA 2 June 5th, 2007 01:49 PM
Suppressing content fatex9994 Crystal Reports 0 November 20th, 2006 01:30 PM
Suppressing login KiwiMark .NET Framework 2.0 0 June 13th, 2006 10:58 PM
Suppressing Blank Lines? boomboom BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 1 April 19th, 2005 08:20 PM





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