xsl-list
[Top] [All Lists]

RE: [xsl] ancestor/subsequent descendant test, problem restated

2009-03-29 21:39:37
At 2009-03-30 03:26 +1300, Trevor Nicholls wrote:
Here it is the section contained within the included "abc_config_file.xml"
element, because this section will produce a separate result document, and
section content both before and after it will go into the result document
produced by the first section inside the included "abc.xml" element.

So then it is a section child of <include> that cannot have sig='Y' absent if a preceding <include> does have sig='Y'?

Because this generated file has stripped out all the content inside the
sections, including the ids, I modified your XSL to use the srcfile of the
nearest ancestral "included" element, which on reflection is probably how I
would choose to report the problem to the authors anyway.
...
                <xsl:variable name="probf"
select="ancestor::included[1]/@srcfile" />
Problem section found in: <xsl:value-of select="$probf"/>

No need to use a variable in the above. Though hopefully a processor would optimize this.

I think the preceding-sibling test would work if I could somehow strip out
any "included" elements in the tree before evaluating the "sibling"
sections. Unfortunately I can't rely on there being zero, one, two, or any
number of nested "included" elements complicating the
[sibling/*-nephew/*-uncle] relationship.

Then I'm guessing you mean "sibling" by the definition of "depth of nested section" regardless of any intervening elements.

I hope the example below helps.

. . . . . . . . . Ken


T:\ftemp>type trevor.xml
<?xml version="1.0" encoding="UTF-8"?>
<document>
        <included srcfile="introduction.xml">
                <section sig="Y">
                        <section/>
                </section>
        </included>
        <included srcfile="abc.xml">
                <section sig="Y">
                        <included srcfile="abc_intro.xml">
                                <section/>
                        </included>
                        <included srcfile="abc_config.xml">
                                <section>
                                        <included
srcfile="abc_config_file.xml">
                                                <section sig="Y">
                                                        <section>
                                                                <section>

<section/>
                                                                </section>
                                                                <section/>
                                                        </section>
                                                </section>
                                        </included>
                                        <included
srcfile="abc_config_reloc.xml">
                                                <section>
                                                        <section/>
                                                        <section/>
                                                </section>
                                        </included>
                                </section>
                        </included>
                        <included srcfile="abc_remove.xml">
                                <section/>
                        </included>
                        <included srcfile="abc_web.xml">
                                <section>
                                        <included
srcfile="abc_web_grouping.xml">
                                                <section>
                                                        <included
srcfile="abc_web_grp_intro.xml">
                                                                <section/>
                                                        </included>
                                                        <included
srcfile="abc_web_grp_create.xml">
                                                                <section>

<section/>

<section/>
                                                                </section>
                                                        </included>
                                                        <included
srcfile="abc_web_grp_add.xml">
                                                                <section>

<section/>

<section/>
                                                                </section>
                                                        </included>
                                                        <included
srcfile="abc_web_grp_nest.xml">
                                                                <section>

<section/>

<section/>
                                                                </section>
                                                        </included>
                                                </section>
                                        </included>
                                        <included srcfile="abc_motd.xml">
                                                <section>
                                                        <included
srcfile="abc_motd_display.xml">
                                                                <section/>
                                                        </included>
                                                        <included
srcfile="abc_motd_edit.xml">
                                                                <section/>
                                                        </included>
                                                </section>
                                        </included>
                                </section>
                        </included>
                        <included srcfile="abc_security.xml">
                                <section>
                                        <section>
                                                <section/>
                                        </section>
                                </section>
                        </included>
                </section>
        </included>
</document>

T:\ftemp>call xslt trevor.xml trevor.xsl

Problem section found in: abc_config_reloc.xml
T:\ftemp>type trevor.xsl
<?xml version="1.0" encoding="US-ASCII"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                version="1.0">
  <xsl:output method="text"/>

<xsl:template match="/">
  <xsl:for-each select="//section[not(@sig='Y')]">
    <!--find the closest preceding section at the same section depth-->
    <xsl:if test="preceding::section[count(ancestor::section)=
                                     count(current()/ancestor::section)][1]/
                  @sig='Y'">
Problem section found in: <xsl:value-of
select="ancestor::included[1]/@srcfile"/>
          </xsl:if>
        </xsl:for-each>
</xsl:template>

</xsl:stylesheet>

T:\ftemp>rem Done!





--
XSLT/XSL-FO/XQuery training in Los Angeles (New dates!) 2009-06-08
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video lesson:    http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18
Video overview:  http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18
G. Ken Holman                 mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal


--~------------------------------------------------------------------
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>
--~--