On 09/19/2011 07:48 PM, Rita Greenberg wrote:
Hello.

Could somebody please explain the following code I found in a .fo file.

Here is my XML file.
                   <RCDATA>
                     <RCDATALINE>
                         <RC>ZE</RC>
                         <RCANSI>W1</RCANSI>
                         <TRC/>
                         <RCREDUCTION>  5878.14</RCREDUCTION>
                         <RCOVERRIDE/>
                         <RCMODIFIED/>
                     </RCDATALINE>
                     <RCDATALINE>
                         <RC>NR</RC>
                         <RCANSI>45</RCANSI>
                         <TRC/>
                         <RCREDUCTION>  0.00</RCREDUCTION>
                         <RCOVERRIDE/>
                         <RCMODIFIED/>
                     </RCDATALINE>

Here is the Following-sibling statement:
<xsl:if test="/doc/EOB/DETAIL/DETAILLINE/RCDATA/RCDATALINE/RC[.!='']/following-
sibling::*[.=''] and /doc/EOB/DETAIL/DETAILLINE/RCDATA/RCDATALINE/RC[.!
='']/following-sibling::*[.!='Y']">

My understanding of following-sibling::* is that the test is checking the
(first RC element and it it's not '' (empty) and the following siblings
(RCANSI, TRC, RCREDUCTION, RCOVERRIDE, RCMODIFIED) are = '' (empty))
AND
(first RC element and it it's not '' (empty) and the following siblings
(RCANSI, TRC, RCREDUCTION, RCOVERRIDE, RCMODIFIED) are not = 'Y'.

With the values above the condition is met and a block of code executed but I
don't understand how the first part of the test can be true since some of the
following-siblings are not = ''.

First, this is not a question for the FOP list, since this is strictly an XSLT (or rather XPath) question.

An xsl:if test doesn't check all the nodes, but the existence of _some_ nodes that pass the test.

A parent/descendant selector doesn't pick the first node of type <descendant>, but one that does fit in the whole expression.

The following-sibling axis, as explained on http://www.w3.org/TR/xpath/#axes , refers to all the nodes that are children of the same parent and follow the current node.

So, the whole test checks that:

- there are any RC nodes that have some text in them
- and they have at least one following sibling that is empty (this is true for the TRC node)

AND, distinctly:

- there are any RC nodes that have some text in them (it doesn't have to be the same node as in the above condition) - and they have at least one following sibling that doesn't have Y as their content (and this is again true for every sibling node in your example)

Overall, I think that the whole test is wrong, since it never tries to relate to the context node. What you probably want is to put this condition in a template that is already on the RCDATALINE, and continue testing from that point on with ./RC instead of going from the root with /doc/..


Thanks,
Rita


--
Sergiu Dumitriu
http://purl.org/net/sergiu/

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org

Reply via email to