Hi, Jay, hi, all, I'm currently close to a solution I was thinking of. but currently I don't understand following:
This is the beginning of my new call template. As branch I support a list of nodes for the tree's next level. As tree-structure-string I support the list of currently needed images (in form of a string) before this tree branch. in the for-each I decide for each element if it is the last one or not, needed for finding the image to be added in this tree level and for the next level. So far for now, but when I tried to debug the XSL Transformation I found that $tree-structure-new-branch is not set to a value. In my case it took the xsl:otherwise route, but value isn't set. What did I wrong? Regards, Kai <xsl:template name="tree-master"> <xsl:param name="branch"/> <xsl:param name="tree-structure-string"/> <xsl:for-each select="$branch"> <xsl:variable name="tree-structure-new-branch"> <xsl:choose> <!-- if this node is not last... --> <xsl:when test="not(position()=last())"> <img width="16" height="16" alt="the branch is not finished"/> </xsl:when> <xsl:otherwise> <img width="16" height="16" alt="This is the last element of the branch"/> </xsl:otherwise> </xsl:choose> </xsl:variable> > Hi, Jay, > > I try your solution tomorrow to see how it looks like. If I found a better > solution I will tell you here :-) > > But many thanks for your hints! > > Kai > > > > Hi, Kai, > > > > The following stylesheet, applied to the following XML (an extension of > > your example), generates the same tree view as used by the Acrobat > Reader > > (at least in version 7): > > > > XSL: > > > > <?xml version="1.0" encoding="UTF-8"?> > > <xsl:stylesheet version="1.0" > > xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > > > > > > > <xsl:template match="objects"> > > <html> > > <head> > > <title>Test</title> > > </head> > > <style> > > <!-- > > td {font-family:monospace} > > --> > > </style> > > <body> > > <table> > > <xsl:apply-templates/> > > </table> > > </body> > > </html> > > </xsl:template> > > > > <xsl:template match="object"> > > <tr> > > <td> > > <xsl:for-each select="ancestor::object[not(position()=last())]"> > > <xsl:choose> > > <xsl:when test="generate-id(.)=generate-id(../*[last()])"> > >    > > </xsl:when> > > <xsl:otherwise> > > |  > > </xsl:otherwise> > > </xsl:choose> > > </xsl:for-each> > > <xsl:choose> > > <xsl:when test="generate-id(.)=generate-id(../*[last()])"> > > <xsl:if test="..[not(name()='objects')]"> -</xsl:if> > > <xsl:value-of select="@id"/> > > </xsl:when> > > <xsl:otherwise> > > |-<xsl:value-of select="@id"/> > > </xsl:otherwise> > > </xsl:choose> > > <xsl:apply-templates/> > > </td> > > </tr> > > </xsl:template> > > > > <xsl:template match="relation"> > > <xsl:apply-templates/> > > </xsl:template> > > > > </xsl:stylesheet> > > > > XML: > > <objects> > > <object Level="0" id="01"> > > <relation Level="0"> > > <object Level="1" id="11"> > > <relation Level="1"> > > <object Level="2" id="21"> > > <relation Level="2"> > > <object Level="3" id="31"/> > > <object Level="3" id="32"/> > > </relation> > > </object> > > <object Level="2" id="22"> > > <relation Level="2"> > > <object Level="3" id="33"> > > <relation Level="3"> > > <object Level="4" id="41"/> > > <object Level="4" id="42"/> > > </relation> > > </object> > > <object Level="3" id="34"> > > <relation Level="3"> > > <object Level="4" id="43"/> > > <object Level="4" id="44"/> > > </relation> > > </object> > > </relation> > > </object> > > <object Level="2" id="23"> > > <relation level="2"> > > <object Level="3" id="35"/> > > <object Level="3" id="36"/> > > </relation> > > </object> > > </relation> > > </object> > > </relation> > > </object> > > </objects> > > > > Note that the relation elements and Level attributes are unnecessary. If > > you have control over the application that generates the XML, you could > > eliminate them. In that case you could alse eliminate the > match="relation" > > template in the XSL. > > > > If you want a line down the left-most edge, I'll have to leave that to > > you. I have run out of the time that I can spend on someone else's > > project. I did enjoy having something different to work on, though. > > > > Thanks. > > > > Jay Bryant > > Bryant Communication Services > > (presently consulting at Synergistic Solution Technologies) > > > > > > > > > > "Kai Hackemesser" <[EMAIL PROTECTED]> > > 02/21/2005 11:45 AM > > Please respond to > > [EMAIL PROTECTED] > > > > > > To > > [EMAIL PROTECTED] > > cc > > > > Subject > > Re: XSLT Question > > > > > > > > > > > > > > Hi J, > > > > Partly you are right, with your test I can tell what image I need for > the > > current level of the tree, but I can't see how to retrieve the required > > images from lower levels. the test you described needs to be done for > > every > > element up to level 0. It's not just the Indent which I want to show, > but > > also some lines and branches, depending from the structure. Like the > > folder > > tree in an windows explorer window. > > > > Ciao! > > Kai > > > > > Hi, Kai, > > > > > > I don't think you need to call a template for that. You can test for > the > > > > > characteristics of the node from within the matching template and get > > the > > > image you need. > > > > > > Several xsl:when statements within an xsl:choose block should let you > > > figure out which images to use when. For example, <xsl:when > > > test="generate-id(.)=generate-id(../*[last()])"> will tell you whether > > the > > > current node is the last child node of its parent. Also, to indent > > > properly, you can read the Level attribute and put the appropriate > > number > > > of indentation objects (blank table cells, spaces, whatever you use) > > > before the image. > > > > > > J > > --------------------------------------------------------------------- > 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]