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

RE: ancestor/subsequent descendant test, problem resta

Subject: RE: ancestor/subsequent descendant test, problem restated
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Mon, 30 Mar 2009 09:38:40 +0800
RE:  ancestor/subsequent descendant test
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@xxxxxxxxxxxxxxxxxxxx
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

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.