Subject: Re: [xsl] ancestor query From: Jörg Heinicke <joerg.heinicke@xxxxxx> Date: Fri, 16 Nov 2001 21:48:38 +0100 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] ancestor query, Tanzila Mohammad | Thread | [xsl] xsl:param error, Vaibhava |
RE: [xsl] xslt on server-side vs. c, Hunsberger, Peter | Date | Re: [xsl] xslt on server-side vs. c, Michael Case |
Month |