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

RE: Positional tests

Subject: RE: Positional tests
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Wed, 02 Mar 2005 15:19:30 -0500
xsl test for node existance
Hi Paul,

At 02:26 PM 3/2/2005, you wrote:
Here's a true representation of my data.

When processing font in block (3) or font in (4) I need to check back to see
if block(2) exists.

The structure is not the same in all cases as this XML originates from a
convertor.

Well if block (2) is always in that spot, when it's there at all, you could try


test="ancestor::body/preceding-sibling::block"

which tests true if any block elements appear before the body ancestor of the context node, inside its parent (here, the Section2).

Is that more like it?

Testing for a node's existence is easier than testing if a node is the same node as some other given node -- we just retrieve the node. When a node-set is converted to a Boolean it comes out true if any nodes are in the set, false if it is empty. So testing any XPath location path directly is effectively a test to see whether any nodes exist in the set returned by the expression.

Of course, specifying exactly the correct location path for any given situation can be something of an art. First you have to specify the situation....

Cheers,
Wendell

<book>
  <Section1>
    <inline>
      <block>Anexo</block> (1)
    </inline>
    <Section2>
      <block>Abreviaturas</block> (2)
      <body>
        <table>
          <thead>
            <tr>
              <td>
                <p>
                  <block> (3)
                    <font font-weight="bold">Abbreviation</font>
                  </block>
                </p>
              </td>
              <td>
                <p>
                  <block> (4)
                    <font font-weight="bold">Description</font>
                  </block>
                </p>
              </td>
            </tr>
          </thead>
          <tbody>
            .
            .
            .
          </tbody>
        </table>
      </body>
    </Section2>
  </Section1>
</book>


======================================================================
Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================

Current Thread

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.