Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
| Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old October 18th, 2004, 07:14 AM
Authorized User
 
Join Date: Oct 2004
Location: , , .
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default problem in treeview using xml,xslt.

we are trying to build treeview using xml,xslt.
Indentation of tree nodes are not coming properly.
All the nodes in the tree are coming in the same vertical align.



  #2 (permalink)  
Old October 18th, 2004, 07:44 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

If you want help debugging your code, you will need to post it.

Michael Kay
http://www.saxonica.com/
  #3 (permalink)  
Old October 18th, 2004, 08:26 AM
Authorized User
 
Join Date: Jul 2004
Location: Oxford, , United Kingdom.
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default

What expression are you using to determine the level of indentation?

  #4 (permalink)  
Old October 18th, 2004, 11:29 PM
Authorized User
 
Join Date: Oct 2004
Location: , , .
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i m adding spaces using for loop after each and every Branch ..for each leaf.
But that is not the appropriate way..i mean number of levels can change

Please see the xsl and xml code below..


xmlTree.xsl
<?xml version="1.0" ?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="html"></xsl:output>


<xsl:template match="/">
<html>
<head>
<title>XLM Tree Control</title>
<link href="xmlTree.css" type="text/css" rel="stylesheet"/>

<script type="text/javascript" src="xmlTree.js"></script>
</head>
<xsl:apply-templates/>
</html>
</xsl:template>



<xsl:template match="tree">
<body>
<xsl:apply-templates/>
</body>
</xsl:template>

<xsl:template match="branchLevel1">
<span class="trigger">
<xsl:attribute name="onClick">
showBranch
('<xsl:value-of select="@id"/>')
</xsl:attribute>

<img src="images/collapse.gif">
<xsl:attribute name="id">I<xsl:value-of select="@id"/>
</xsl:attribute>
</img>

<xsl:value-of select="branchText"/>


<br/>
</span>

<span class="branch">
<xsl:attribute name="id">
<xsl:value-of select="@id"/>
</xsl:attribute>
<xsl:apply-templates/>
</span>
</xsl:template>


<xsl:template match="branchLevel2">
<span class="trigger">
<xsl:attribute name="onClick">
showBranch
('<xsl:value-of select="@id"/>')
</xsl:attribute>
<xsl:text disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;</xsl:text>

<img src="images/collapse.gif">
<xsl:attribute name="id">I<xsl:value-of select="@id"/>
</xsl:attribute>
</img>

<xsl:value-of select="branchText"/>

<xsl:text disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;</xsl:text>

<br/>
</span>

<span class="branch">
<xsl:attribute name="id">
<xsl:value-of select="@id"/>
</xsl:attribute>
<xsl:apply-templates/>
</span>
</xsl:template>




<xsl:template match="branchLevel3">
<span class="trigger">
<xsl:attribute name="onClick">
showBranch
('<xsl:value-of select="@id"/>')
</xsl:attribute>
<xsl:text disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp; nbsp;</xsl:text>

<img src="images/collapse.gif">
<xsl:attribute name="id">I<xsl:value-of select="@id"/>
</xsl:attribute>
</img>

<xsl:value-of select="branchText"/>

<xsl:text disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp; nbsp;</xsl:text>

<br/>
</span>

<span class="branch">
<xsl:attribute name="id">
<xsl:value-of select="@id"/>
</xsl:attribute>
<xsl:apply-templates/>
</span>
</xsl:template>



<xsl:template match="branchLevel4">
<span class="trigger">
<xsl:attribute name="onClick">
showBranch
('<xsl:value-of select="@id"/>')
</xsl:attribute>
<xsl:text disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp; nbsp;&amp;nbsp;&amp;nbsp;</xsl:text>

<img src="images/collapse.gif">
<xsl:attribute name="id">I<xsl:value-of select="@id"/>
</xsl:attribute>
</img>

<xsl:value-of select="branchText"/>
<xsl:text disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp; nbsp;&amp;nbsp;&amp;nbsp;</xsl:text>


<br/>
</span>

<span class="branch">
<xsl:attribute name="id">
<xsl:value-of select="@id"/>
</xsl:attribute>
<xsl:apply-templates/>
</span>
</xsl:template>




<xsl:template match="branchLevel5">
<span class="trigger">
<xsl:attribute name="onClick">
showBranch
('<xsl:value-of select="@id"/>')
</xsl:attribute>
<xsl:text disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp; nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;</xsl:text>

<img src="images/collapse.gif">
<xsl:attribute name="id">I<xsl:value-of select="@id"/>
</xsl:attribute>
</img>

<xsl:value-of select="branchText"/>

<xsl:text disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp; nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;</xsl:text>

<br/>
</span>

<span class="branch">
<xsl:attribute name="id">
<xsl:value-of select="@id"/>
</xsl:attribute>
<xsl:apply-templates/>
</span>
</xsl:template>




<xsl:template match="branchLevel6">
<span class="trigger">
<xsl:attribute name="onClick">
showBranch
('<xsl:value-of select="@id"/>')
</xsl:attribute>
<xsl:text disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp; nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp; nbsp;&amp;nbsp;</xsl:text>

<img src="images/collapse.gif">
<xsl:attribute name="id">I<xsl:value-of select="@id"/>
</xsl:attribute>
</img>

<xsl:value-of select="branchText"/>

<xsl:text disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp; nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp; nbsp;&amp;nbsp;</xsl:text>

<br/>
</span>

<span class="branch">
<xsl:attribute name="id">
<xsl:value-of select="@id"/>
</xsl:attribute>
<xsl:apply-templates/>
</span>
</xsl:template>



<xsl:template match="leaf">

<img src="images/doc.gif"/>

<a>
<xsl:attribute name="href">
<xsl:value-of select="link"/>

</xsl:attribute>

<xsl:value-of select="leafText"/>
</a>


<br/>



</xsl:template>










<xsl:template match="leaf">
<xsl:text disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp; nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp; nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;</xsl:text>

<img src="images/doc.gif"/>

<a>
<xsl:attribute name="href">
<xsl:value-of select="link"/>

</xsl:attribute>

<xsl:value-of select="leafText"/>
</a>

<xsl:text disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp; nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp; nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;</xsl:text>


<br/>



</xsl:template>
<xsl:template match="branchText"/>

</xsl:stylesheet>



xmltree.xml
<?xml version="1.0" ?>

<!DOCTYPE tree SYSTEM 'tree.dtd'>

<?xml-stylesheet type="text/xsl" href="xmlTree.xsl"?>

<tree>
<branchLevel1 id="html">
    <branchText>HTML</branchText>
    <leaf>
    <leafText>Tags,Tags,Tags</leafText>
    <link>#</link>
    </leaf>
    <leaf>
    <leafText>Hyperlink</leafText>
    <link>#</link>
    </leaf>
    <leaf>
    <leafText>Images</leafText>
    <link>#</link>
    </leaf>
    <leaf>
    <leafText>Tables</leafText>
    <link>#</link>
    </leaf>
    <leaf>
    <leafText>Form</leafText>
    <link>#</link>
    </leaf>
    </branchLevel1>


    <branchLevel1 id="css">
    <branchText>CSS</branchText>
    <leaf>
    <leafText>InlineStyle</leafText>
    <link>#</link>
    </leaf>
    <leaf>
    <leafText>External Style Sheet</leafText>
    <link>#</link>
    </leaf>
    <leaf>
    <leafText>Formatting Text</leafText>
    <link>#</link>
    </leaf>
    <leaf>
    <leafText>positioning Text</leafText>
    <link>#</link>
</leaf>
    <leaf>
    <leafText>Jyoti</leafText>
    <link>#</link>
    </leaf>


    <branchLevel2 id="css2">
    <branchText>CSS2</branchText>
    <leaf>
    <leafText>InlineStyle2</leafText>
    <link>#</link>
    </leaf>
    <leaf>
    <leafText>External Style Sheet2</leafText>
    <link>#</link>
    </leaf>
    <leaf>
    <leafText>Formatting Text2</leafText>
    <link>#</link>
    </leaf>
    <leaf>
    <leafText>positioning Text2</leafText>
    <link>#</link>
</leaf>
    <leaf>
    <leafText>Jyoti2</leafText>
    <link>#</link>
    </leaf>


    <branchLevel3 id="css3">
    <branchText>CSS3</branchText>
    <leaf>
    <leafText>InlineStyle3</leafText>
    <link>#</link>
    </leaf>
    <leaf>
    <leafText>External Style Sheet3</leafText>
    <link>#</link>
    </leaf>
    <leaf>
    <leafText>Formatting Text3</leafText>
    <link>#</link>
    </leaf>
    <leaf>
    <leafText>positioning Text3</leafText>
    <link>#</link>
</leaf>
    <leaf>
    <leafText>Jyoti3</leafText>
    <link>#</link>
    </leaf>
    <branchLevel4 id="css4">
    <branchText>CSS4</branchText>
    <leaf>
    <leafText>InlineStyle4</leafText>
    <link>#</link>
    </leaf>
    <leaf>
    <leafText>External Style Sheet4</leafText>
    <link>#</link>
    </leaf>
    <leaf>
    <leafText>Formatting Text4</leafText>
    <link>#</link>
    </leaf>
    <leaf>
    <leafText>positioning Text4</leafText>
    <link>#</link>
</leaf>
    <leaf>
    <leafText>Jyoti4</leafText>
    <link>#</link>
    </leaf>
    <branchLevel5 id="css5">
    <branchText>CSS5</branchText>
    <leaf>
    <leafText>InlineStyle5</leafText>
    <link>#</link>
    </leaf>
    <leaf>
    <leafText>External Style Sheet5</leafText>
    <link>#</link>
    </leaf>
    <leaf>
    <leafText>Formatting Text5</leafText>
    <link>#</link>
    </leaf>
    <leaf>
    <leafText>positioning Text5</leafText>
    <link>#</link>
</leaf>
    <leaf>
    <leafText>Jyoti5</leafText>
    <link>#</link>
    </leaf>
    <branchLevel6 id="css6">
    <branchText>CSS6</branchText>
    <leaf>
    <leafText>InlineStyle6</leafText>
    <link>#</link>
    </leaf>
    <leaf>
    <leafText>External Style Sheet6</leafText>
    <link>#</link>
    </leaf>
    <leaf>
    <leafText>Formatting Text6</leafText>
    <link>#</link>
    </leaf>
    <leaf>
    <leafText>positioning Text6</leafText>
    <link>#</link>
</leaf>
    <leaf>
    <leafText>Jyoti6</leafText>
    <link>#</link>
    </leaf>
    </branchLevel6>
    </branchLevel5>
    </branchLevel4>
    </branchLevel3>
    </branchLevel2>
    </branchLevel1>





    </tree>







Similar Threads
Thread Thread Starter Forum Replies Last Post
XML to XML with xslt problem bertvanpet XSLT 1 July 5th, 2007 06:25 AM
XSLT process XML problem in XMLSpy xinr XSLT 2 September 14th, 2006 11:53 AM
problem transforming XML using xslt micky3248 XSLT 7 August 18th, 2006 03:52 AM
Problem using XSLT to change XML attribute cbeech1980 XSLT 1 October 18th, 2005 06:26 AM
xml and xslt problem astroflake XSLT 1 April 13th, 2004 06:09 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.