Hi, Jay,

ok, here more details:

my XML source looks like that:
...
<object Level="0">
  <relation Level="0">
     <object Level="1">
       <relation Level="1">
         <object Level="2">
           ...
         </object>
       </relation>
     </object>
     <object Level="1">
       <relation Level="1">
         <object Level="2">
           ...
I think you got the structure. There are <attribute> elements and a lot of
element attributes I now haven't shown because not needed for my question.

I have to create a explorer tree like picture from that. For each line of my
list I need to find out what tree structure images are needed (&u2503;
&u2523; &u2517; in form of fixed size gif images), I need to know for
example if this element is the last child of its parent, if the parent is
the last child of its parent and so on, to decide which image is the
correct. 
I need it recursive because there is theoretical no limit of depth,
practical it would lie at about ten.

My solution was about this:

   <xsl:template match="object">
      <tr>
         <td>
            <xsl:call-template name="tree-scructure">
               <xsl:with-param name="treenode" select="node()"/>
            </xsl:call-template>
            <xsl:value-of select="[EMAIL PROTECTED]'DisplayedName']/value"/>
         </td>
         <td>
            <xsl:call-template name="replace-null">
               <xsl:with-param name="input"
                  select="[EMAIL PROTECTED]'beGTABeschreibPos']/value"/>
            </xsl:call-template>
         </td>
         <td>
            <xsl:value-of select="attribute
[EMAIL PROTECTED]'LifeCycleState']/value"/>
         </td>
         <td>
            <xsl:value-of select="[EMAIL PROTECTED]'ProjectName']/value"/>
         </td>
      </tr>
      <xsl:apply-templates select="relation"/>
   </xsl:template>
   <xsl:template match="relation">
      <tr>
         <td>
            <xsl:call-template name="tree-scructure">
               <xsl:with-param name="treenode" select="node()"/>
            </xsl:call-template>
            <xsl:value-of select="[EMAIL PROTECTED]'LDisplayedName']/value"/>
         </td>
      </tr>
      <xsl:apply-templates select="object"/>
   </xsl:template>

   <xsl:template name="tree-scructure">
      <xsl:param name="treenode"/>
      <xsl:param name="recursive"/>
      <xsl:if test="$treenode/@Level > 0">
         <xsl:call-template name="tree-scructure">
            <xsl:with-param name="treenode" select="parent::node()"/>
            <xsl:with-param name="recursive">true</xsl:with-param>
         </xsl:call-template>
      </xsl:if>
      <img width="16" height="16" alt="just an incomplete test"/>
   </xsl:template>

That's where I am now.... a not working thing.

Thank you for your time,
Kai




> Hi, Kai,
> 
> I would need a bit more detail to be able to help with that. Please post 
> the smallest (but still still complete) set of XML files (input and 
> desired output) that you want. That way, we can see what you mean.
> 
> A couple observations, though: You can't walk back up the tree from a 
> parameter passed to a template by using path expressions. Thus, you can't 
> get the parent of a node you passed as a parameter by using .. or a 
> similar construct. If memory serves, this problem arises because, when you
> pass a path as a parameter, you really pass a result tree fragment. 
> Unfortunately, the result tree fragment has its own root node (the node 
> you passed), so you can't go up from there. To solve this problem, you 
> need more information. In the past, I have used a text representation of 
> the full path (from the document root) to the node I want. Then I can use 
> the name() function and predicate logic to walk back up the path. If you 
> only need to go up one level, you could pass the parent node as another 
> parameter. That method is not extensible, but it will work, so long as you
> really only need to go up one level.
> 
> Also, you should subscribe to [EMAIL PROTECTED] and ask that
> question there. The heavy hitters in the XSL world read that list.
> 
> HTH
> 
> Jay Bryant
> Bryant Communication Services
> (presently consulting at Synergistic Solution Technologies)
> 
> 
> 
> 
> "Kai Hackemesser" <[EMAIL PROTECTED]> 
> 02/21/2005 09:27 AM
> Please respond to
> [EMAIL PROTECTED]
> 
> 
> To
> [EMAIL PROTECTED]
> cc
> 
> Subject
> XSLT Question
> 
> 
> 
> 
> 
> 
> Hello,
> 
> I know this is not quite the right mailing list for that question, but 
> maybe
> somebody here knows?
> 
> I need to create a kind of recursive call-template, where certain 
> attributes
> >from different parent elements are needed. I want to do a call to a 
> template
> by itself, giving it the parent element as parameter. Ho can I evaluate 
> the
> parent of a parameter given node? Or how do I set a parent element to be
> current() element? While in a call?
> 
> Regards,
> Kai
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to