Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #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.



Reply With Quote
  #2 (permalink)  
Old October 18th, 2004, 07:44 AM
mhkay's Avatar
Wrox Author
Points: 18,481, Level: 59
Points: 18,481, Level: 59 Points: 18,481, Level: 59 Points: 18,481, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,960
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/
Reply With Quote
  #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?

Reply With Quote
  #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>





Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 09:45 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.