xsl-list
[Top] [All Lists]

[xsl] tricky text and structure test is troubling me

2020-03-06 10:38:57
At least it's proving tricky for me...

 

Simple case, a piece of XML which looks like this

 

<document>

  <title>document title</title>

    ... (A) ...

     <section>

       <title>section title>

       ... (B) ...

    </section>

  ... (C) ...

</section>

 

Assuming the current node is the <document>, I need a test which tells me
whether there is going to be any *visible* content in the space labelled
(A).

 

There are complications.

 

Firstly, it is not sufficient to just look for a text node or img element
within (A) because a couple of elements have text content but are not
rendered by our output stage.

For example, targets.

 

<document>

  <title id="a">document title</title>

  <target id="b">alternative title</target>

  <section>

    <title id="c">section title</title>

    ...

  </section>

</document>

 

The number of such elements is finite, in fact off the top of my head
targets and footnotes are the only ones.

 

Secondly, before the XSL process which needs to evaluate this test is run
the input document is pre-processed to pull in any included sub-content.
These inclusions are reflected in the document like so:

 

<document>

  <title id="a">document title</title>

  <target id="b">alternative title</target>

  <included srcfile="path1.xml">

    <included srcfile="path1a.xml">

      <section>

        <title id="c">section title</title>

        ...

      </section>

    </included>

    <included srcfile="path1b.xml">

      <section>

        <title id="d">another section title</title>

        ...

      </section>

    </included>

  </included>

</document>

 

I need to be able to tell the difference between the case where - reading in
document order - the document contains a descendant text node (that isn't
part of the document title or a target element), or img element, before the
first section element, and the case where there isn't. I'm probably
overthinking it but after much thought I have yet to arrive at a working
solution.

 

I hope I have explained this adequately!

 

Thanks in advance

T

 
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--
<Prev in Thread] Current Thread [Next in Thread>