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

Re: Fwd: Selecting First Child of Ancestor using Xpath

Subject: Re: Fwd: Selecting First Child of Ancestor using Xpath
From: Nathan Tallman <ntallman@xxxxxxxxx>
Date: Wed, 20 Nov 2013 10:57:48 -0500
Re:  Fwd: Selecting First Child of Ancestor using Xpath
Thank you, Martin and Wendell.

On Wed, Nov 20, 2013 at 10:35 AM, Wendell Piez <wapiez@xxxxxxxxxxxxxxx> wrote:
> Hi Nathan,
>
> As in XSLT 1.0, test="../../c04[1]" will test for the existencee of a
> c04 inside the grandparent. Since you are inside a c04, this will
> always be true.
>
> You probably want something like "empty(../preceding-sibling::c04)"
>
> But I might go to a little more trouble to make my logic explicit:
>
> <xsl:template match="c04">
>   <!-- binding a variable to a Boolean value capturing your test -->
>  <xsl:variable name="c04-is-first" select="empty(preceding-sibling::c04)"/>
>   <xsl:for-each select="did">
>     <xsl:if test="$c04-is-first">...
>
> I will forego the rant on why EAD is so much easier with plain 'c'
> than it is with numbered components. So much easier that one is
> usually rewarded by a pre-process that converts numbered components
> into unnumbered ones....
>
> Cheers, Wendell
> Wendell Piez | http://www.wendellpiez.com
> XML | XSLT | electronic publishing
> Eat Your Vegetables
> _____oo_________o_o___ooooo____ooooooo_^
>
>
> On Wed, Nov 20, 2013 at 10:12 AM, Nathan Tallman <ntallman@xxxxxxxxx> wrote:
>> I have the following xml:
>>
>>                <c03 level="otherlevel" otherlevel="subsubseries"
>> id="seriesB2ii">
>>                   <did>
>>                      <unittitle>Section ii. Subject Files</unittitle>
>>                      <unitdate era="ce"
>> calendar="gregorian">1937-1958</unitdate>
>>                   </did>
>>                   <scopecontent>
>>                      <p>Scope and Content Note: Includes file on
>> Jewish organizations, annual
>>                         meetings, anti-discrimination and legislation,
>> Commentary newsletter,
>>                         Emergency Committee, foreign affairs, human
>> and civil rights, Israel, joint
>>                         defense appeal, Palestine immigration and
>> platform, peace, and the American
>>                         Jewish tercentenary.</p>
>>                   </scopecontent>
>>                   <arrangement>
>>                      <p>Arrangement Note: Arranged alphabetically.</p>
>>                   </arrangement>
>>                   <c04 level="file">
>>                      <did>
>>                         <container type="Box">B7</container>
>>                         <container type="Folder">30</container>
>>                         <unittitle>Administrative Committee</unittitle>
>>                         <unitdate era="ce"
>> calendar="gregorian">1943-1944</unitdate>
>>                      </did>
>>                   </c04>
>>                   <c04 level="file">
>>                      <did>
>>                         <container type="Box">B7</container>
>>                         <container type="Folder">31</container>
>>                         <unittitle>American Council for Judaism</unittitle>
>>                         <unitdate era="ce" calendar="gregorian">1950</unitdate>
>>                      </did>
>>                   </c04>
>>                   <c04 level="file">
>>                      <did>
>>                         <container type="Box">B7</container>
>>                         <container type="Folder">32</container>
>>                         <unittitle>American Jewish Conference</unittitle>
>>                         <unitdate era="ce"
>> calendar="gregorian">January - May 1943</unitdate>
>>                      </did>
>>                   </c04>
>>
>> I'm working on a template that matches on c04, then has an
>> xsl:for-each for the did (so did is m context node). I am transforming
>> this into an HTML table.
>>
>> I'd like to do an xsl:coose/when to test for the first c04 child of
>> c03, so I can add table headers. As this is processing all dids I need
>> the test to specifically catch the first c04 child. However
>> test="../../c04[1]" does not seem to be doing the trick.
>>
>> Any suggestions? I'm using XSLT 2.0.
>>
>> Thanks,
>> Nathan

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.