-
Changing targets in XML Tree
Hello,
Perhaps a simple question, but one that I'm currently stuck on:
I'm using Tom Duffy's article as a base for creating a javascript tree control with an xml base. Article is at http://www.windx.com/getHelpOn/Article/11874/0/page/1 .
At any rate, after populating the xml, things more or less look snazzy. Except one issue. The sample html that was included on that tutorial uses an iframe as the tree menu container and the body is just a div. Great, sounds fantastic. Only problem, every recurring link clicked within the tree opens within the tree iframe and not in the content area.
I did a bit of tweaking here and there and the closest I've gotten so far was to specify (in the xsl, not the html itself) to set a base target for the content div. Now, it at least opens in a new window rather than the tree.
But my question now is, where did I go wrong? Is this as simple as not being able to use a div for a base target? Or is it that the value specified in the xsl not going to be carried over when the html is rendered? I can specify the base target in both the html page's head, or in the html page's iframe call, but same result as well.
All I want to do is take what is a nicely-designed script pattern supplied on the site and tweak it so that links open in the rendered content frame. Any ideas?
The sample scripts are supplied within the above link, but I'll show you the html and the xsl (with my base target added) here. Thanks
- - - - - - -
****XSLT****
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl utput method="html"></xsl utput>
<xsl:template match="/">
<html>
<head>
<title>XML Tree Control</title>
<link rel="stylesheet" type="text/css" href="xmlTree.css"/>
<script type="text/javascript" src="xmlTree.js"></script>
<base target="content"/>
</head>
<xsl:apply-templates/>
</html>
</xsl:template>
<xsl:template match="tree">
<body>
<xsl:apply-templates/>
</body>
</xsl:template>
<xsl:template match="branch">
<span class="trigger">
<xsl:attribute name="onClick">
showBranch('<xsl:value-of select="@id"/>');
</xsl:attribute>
<img src="closed.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="leaf">
<img src="doc.gif"/>
<a>
<xsl:attribute name="href" >
<xsl:value-of select="link"/>
</xsl:attribute>
<xsl:value-of select="leafText"/>
</a><br/>
</xsl:template>
<!-- avoid output of text node with default template -->
<xsl:template match="branchText"/>
</xsl:stylesheet>
- - - - - - -
****HTML****
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Embedded XML Tree Control</title>
<style type="text/css">
#tree{
border-right:1px black solid;
border-top: none;
border-bottom: none;
border-left:none;
position: absolute;
top:10;
left:0;
width: 250;
}
#content{
position:absolute;
top:0;
left: 160;
font-family: sans-serif;
color: navy;
}
</style>
<script type="text/javascript">
function setHeight(){
var availableHeight = 0;
if(document.all)
availableHeight = document.body.clientHeight;
else
availableHeight = innerHeight;
var tree = document.getElementById('tree').style;
tree.height = availableHeight-20;
}
</script>
</head>
<body onload="setHeight()">
<iframe id="tree" src="tree.xml"><base target="content></iframe>
<div id="content">
<h2>Page Content Here</h2>
</div>
</body>
</html>
Similar Threads
-
By Tim in forum xml.announcements
Replies: 0
Last Post: 10-11-2001, 04:00 PM
-
By xmlstartkabel in forum XML
Replies: 0
Last Post: 10-10-2001, 04:07 AM
-
By Tim Frost in forum xml.announcements
Replies: 0
Last Post: 04-02-2001, 10:53 AM
-
By Extensibility in forum web.announcements
Replies: 0
Last Post: 07-20-2000, 06:20 PM
-
By Sales in forum xml.announcements
Replies: 0
Last Post: 07-20-2000, 06:18 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks