[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: HOW TO CHECK FOR EXISTENCE OF A NODE

Subject: RE: HOW TO CHECK FOR EXISTENCE OF A NODE
From: "Mike Rudolph" <mrudolph@xxxxxxx>
Date: Fri, 14 Mar 2003 13:30:58 -0600
mike rudolph
I just ordered both Michael's and Jeni's books.  Thanks for the help.

Now I have a question regarding Cold Fusion... :D

Mike

-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Bix
Sent: Friday, March 14, 2003 12:07 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  HOW TO CHECK FOR EXISTENCE OF A NODE


Mike,

You should really consider purchasing a book or two on XSLT.  This type of a
question can easily be answered there.  Michael Kay's XSLT or Jeni
Tennison's Learning XSLT are great references.  In addition, please look
through http://www.dpawson.co.uk/.  Jeni also has a nice website that has a
broad introduction to some of the questions you'll probably come up with:
http://www.jenitennison.com/xslt/.  Finally, I think you should take a look
at the <xsl:if> and <xsl:choose><xsl: when/><xsl:otherwise/></xsl:choose>
elements.  I believe you can get away with using the <if> element, but you
may have other cases.  The choose/when/otherwise acts in a similar manner to
the if-then-else statements in c.

I made the assumption that you have an XSLT processor capable of handling
version 1.1 of XSLT.  In addition, I made the assumption that you did not
want a box to appear at all unless the current node contained the
"header_notes" element.  I've also included a full stylesheet with a variety
of different elements from within the XSLT language to give you and idea of
what you should be able to learn how to do from the references I mentioned
above.


<x:stylesheet version="1.1" xmlns:x="http://www.w3.org/1999/XSL/Transform">

    <x:attribute-set name="box">
        <x:attribute name="border">4</x:attribute>
        <x:attribute name="width">100%</x:attribute>
        <x:attribute name="valign">top</x:attribute>
        <x:attribute name="cellpadding">5</x:attribute>
    </x:attribute-set>

    <x:attribute-set name="cell">
        <x:attribute name="colspan">2</x:attribute>
        <x:attribute name="width">100%</x:attribute>
        <x:attribute name="valign">top</x:attribute>
    </x:attribute-set>

    <x:template match="/">

        <!-- Do something here to get it into the right form -->

        <x:if test="header_notes">
            <x:call-template name="makeBox">
                <x:with-param name="node" select="."/>
            </x:call-template>
        </x:if>

    </x:template>


    <x:template name="makeBox">
        <x:param name="node" select="."/>

        <x:element name="table" use-attribute-sets="box">
            <x:element name="tr">
                <x:element name="td" use-attribute-sets="cell">
                    <x:for-each select="$node/header_notes">
                        <x:value-of select="header_notes_text"/><x:element
name="br"/>
                    </x:for-each>
                </x:element>
            </x:element>
        </x:element>

    </x:template>


</x:stylesheet>

----- Original Message -----
From: "Mike Rudolph" <mrudolph@xxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Friday, March 14, 2003 10:54 AM
Subject:  HOW TO CHECK FOR EXISTENCE OF A NODE


>
> Newbie here.  I am looking for the proper element to evaluate the
existence
> of a node in order to suppress the generation of an HTML display 'box' if
a
> particular node does not exist.  So, instead of producing a box with a
> caption of 'HEADER NOTES' when there are no header notes, I would rather
not
> produce the box at all to cut down on the clutter.  Here is the code which
> makes the box and displays any header_notes_text if it exists.   For
> example,
>
>
>      <TABLE BORDER="4" WIDTH="100%" VALIGN="TOP" CELLPADDING="5">
>        <TR>
>          <TD WIDTH="100%" VALIGN="TOP" COLSPAN="2">
>            <H4 ALIGN="LEFT">HEADER NOTES AREA</H4>
>               <xsl:for-each select="header_notes">
>               <xsl:value-of select="header_notes_text" /><BR/>
>               </xsl:for-each>
>          </TD>
>        </TR>
>      </TABLE>
>
>
>
> I tried wrapping the above with xsl:template but got this error:
> Keyword xsl:template may not be used here.
>
> I have not had any ah-ha experiences yet, so I don't see the obvious.
>
> ----------
>
> Mike Rudolph - EDI Coordinator
> Green Bay Packaging Inc.
> Phone: 920.433.5426
> Fax:   920.438.5426
> Email: mrudolph@xxxxxxx
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread
  • RE: XSL and ASP, (continued)
    • Rick Taylor - Fri, 14 Mar 2003 12:30:44 -0500 (EST)
    • Bix - Fri, 14 Mar 2003 13:05:51 -0500 (EST)
      • Mike Rudolph - Fri, 14 Mar 2003 14:29:07 -0500 (EST) <=
    • XSLList - Fri, 14 Mar 2003 12:56:30 -0500 (EST)

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.