xsl-list
[Top] [All Lists]

RE: Positional tests

2005-03-02 13:19:30
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(_at_)mulberrytech(_dot_)com
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
======================================================================


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>