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

Re: ancestor query

Subject: Re: ancestor query
From: Jörg Heinicke <joerg.heinicke@xxxxxx>
Date: Fri, 16 Nov 2001 21:48:38 +0100
column heading as query result
You can use ancestor like the following one. You only need a common ancestor
of both elements, in your case 'table-header'. I assume, that you need the
@lang too.

1st method (using ancestor):

<xsl:value-of select="concat(.,' ',
ancestor::table-header/table-header-literals/unit[@lang =
current()/@lang])"/>

2nd method (using root node):


<xsl:value-of select="concat(.,' ',
/query-result/yearbook/table-header-literals/unit[@lang =
current()/@lang])"/>

3rd method (using parents):

<xsl:value-of select="concat(.,' ',
../../../table-header-literals/unit[@lang = current()/@lang])"/>

4th method (using keys):

<xsl:stylesheet ....>
<xsl:key name="units" match="unit" use="@lang"/>
<xsl:template match="column-header">
    <xsl:value-of select="concat(.,' ',key('units',@lang))"/>
</xsl:template>
</xsl:stylesheet>

Regards,

Joerg



> I have the following xml:
>
> <query-result>
>    <yearbook id="fzyb" volume="49" year="1999">
> <name lang="CH">English Name...</name>
>                          .....
> <table-header>
> <table-header-literals>
> <literal name="number">22</literal>
>                                         <literal
> name="startpage">57</literal>
> <literal name="table" lang="EN">TABLE</literal>
> ....
> <unit name="fzybk-MT-N" lang="ES">TM N</unit>
> </table-header-literals>
> <table-column-headers>
> <table-column-header-row>
> <column-header lang="AR" name="ELEMENT">Arabic name
> ...</column-header>
> <column-header lang="CN" name="ELEMENT">Chinese name</column-header>
> <column-header lang="EN" name="ELEMENT">PRODUCTION</column-header>
> <column-header lang="FR" name="ELEMENT">PRODUCTION</column-header>
> <column-header lang="ES" name="ELEMENT">PRODUCCION</column-header>
> </table-column-header-row>
> <table-column-header-row>
>                                          .........
>
> My xsl:
>  .........
>  <xsl:for-each
>
select="./table-header/table-column-headers/table-column-header-row/column-h
> eader[@name='ELEMENT']">
>        <xsl:sort select="concat(substring(./@lang='ES',1,1),./@lang)"
> data-type="text" order="ascending"/>
>              <fo:table-cell>
>               <fo:block text-align="center" space-after.optimum="5pt"
> font-weight="bold" space-before.optimum="10pt">
>                  <xsl:value-of select="concat(.,' ', '<<unit
details>>')"/>
>               </fo:block>
>               </fo:table-cell>
>      </xsl:for-each>
> .........
>
> I want to have the 'unit' node value in the concatenation. Is there a way
> that I can either:
>
> - get to the root path directly then work my way down to the node.
>
> e.g. root/query-result/yearbook/table-header/table-header-literals/unit
>
> - or go up the node tree, by making use of ancestor (I have had trouble
with
> this).
>
> Thanks
>
> Tanz


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.