This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: getting the node position in source xml in a variable


Yes the structure is always like this (i.e data and display nodes are always
siblings)
but the xpath can change (different names of tags..)..
we want to keep it at one place so that if we want to change something we
have to change only at one place..

For example, are the display nodes and associated data nodes
always siblings of each other, nested under some other node? Very Correct..
Thanks & Regards
Gurvinder
Amdocs Limited , Cyprus


-----Original Message-----
From: Jeni Tennison [mailto:jeni@jenitennison.com]
Sent: Wednesday, February 27, 2002 4:20
To: Gurvinder Singh
Cc: 'xsl-list@lists.mulberrytech.com'
Subject: Re: [xsl] getting the node position in source xml in a variable


Hi Gurvinder,

> That excatly is the problem...
> all the nodes in the $displaynodes are not siblings...

Ahh...

> coz i have something like this
> <test>
>   <nodes>
>         <level2>
>                 <data>3</data>
>                 <display>C</display>
>                 <someotherdata>abc</someotherdata>
>         </level2>
>         <level2>
>                 <data>2</data>
>                 <display>B</display>
>                 <someotherdata>abc</someotherdata>
>         </level2>
>         <level2>
>                 <data>1</data>
>                 <display>A</display>
>                 <someotherdata>abc</someotherdata>
>         </level2>
>   </nodes>
>  </test>

If the data and display elements that you want to associate are
already associated (as they are in this structure) then why not just
use that association?

For example, rather than using the lookup template at all, you could
just do:

  <select name="test">
    <xsl:for-each select="/test/nodes/level2">
      <xsl:sort select="display" />
      <option id="{data}" value="{data}">
        <xsl:value-of select="concat(data, '-', display)" />
      </option>
    </xsl:for-each>
  </select>

I guess that you're using the lookup template so that you can create
other select elements in the same kind of way elsewhere. Making the
lookup template absolutely generic will make it comparatively
inefficient, so before going to that extreme, perhaps you could
describe the variety of situations in which you want to use the lookup
template? For example, are the display nodes and associated data nodes
always siblings of each other, nested under some other node?

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]