BigGreenClenaMachine
asked on
how can <iframe> with transformed xml comunicate with web page
i have a problem with transformed xml
everithing went as planned until i tryed to get a value of a variable named SelectedLeafID from a tree.htm.
Variable is defined inside a xmltree.js.
xmltree.xls uses that script and function SelectedLeaf_Changed changes the value of SelectedLeafID.
but tree.htm can't read its value.
Why not ??? and "Is there a way to do that?"
here are the files
----------------------- tree.xml -------------------------- --------
<?xml version="1.0" ?>
<!DOCTYPE tree SYSTEM "tree.dtd">
<?xml-stylesheet type="text/xsl" href="xmlTree.xsl"?>
<tree>
<branch id="B1">
<branchText>Branch1</branc hText>
<leaf id="L1">
<leafText>Leaf1</leafText>
</leaf>
<leaf id="L2">
<leafText>Leaf2</leafText>
</leaf>
</branch>
<branch id="B2">
<branchText>Branch2</branc hText>
<leaf id="L3">
<leafText>Leaf3</leafText>
</leaf>
<branch id="B3">
<branchText>Branch3</branc hText>
<leaf id="L4">
<leafText>Leaf4</leafText>
</leaf>
<leaf id="L5">
<leafText>Leaf5</leafText>
</leaf>
</branch>
<leaf id="L6">
<leafText>Leaf6</leafText>
</leaf>
</branch>
</tree>
-------------------------- ---------- ---------- ---------- ---------- --------
-------------------------- --xmltree. xls------- ---------- ---------- ------
<?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>XML Tree Control</title>
<link rel="stylesheet" type="text/css" href="xmlTree.css"/>
<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="branch">
<span class="trigger">
<xsl:attribute name="onClick">showBranch( '<xsl:valu e-of select="@id"/>');</xsl:att ribute>
<img src="closed.gif">
<xsl:attribute name="id">I<xsl:value-of select="@id"/></xsl:attrib ute>
</img>
<xsl:value-of select="branchText"/>
<br/>
</span>
<span class="branch">
<xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attrib ute>
<xsl:apply-templates/>
</span>
</xsl:template>
<xsl:template match="leaf">
<img src="doc.gif"/>
<span class="leaf">
<xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attrib ute>
<xsl:attribute name="onClick">SelectedLea f_Changed( '<xsl:valu e-of select="@id"/>');</xsl:att ribute>
<xsl:value-of select="leafText"/>
</span><br/>
</xsl:template>
<!-- avoid output of text node with default template -->
<xsl:template match="branchText"/>
</xsl:stylesheet>
-------------------------- ---------- ---------- ---------- ---------- ---------- -------
-------------------------- -------xml tree.js--- ---------- ---------- ---------- -----
var SelectedLeafID= null;
var openImg = new Image();
openImg.src = "open.gif";
var closedImg = new Image();
closedImg.src = "closed.gif";
function showBranch(branch){
var objBranch = document.getElementById(br anch).styl e;
if(objBranch.display=="blo ck")
objBranch.display="none";
else
objBranch.display="block";
swapFolder('I' + branch);
}
function swapFolder(img){
objImg = document.getElementById(im g);
if(objImg.src.indexOf('clo sed.gif')> -1)
objImg.src = openImg.src;
else
objImg.src = closedImg.src;
}
function SelectedLeaf_Changed(xleaf ID)
{
if (SelectedLeafID!=null)docu ment.getEl ementById( SelectedLe afID).clas sName="lea f";
var lf = document.getElementById(xl eafID);
lf.className="leafSelected ";
SelectedLeafID = xleafID;
}
-------------------------- ---------- ---------- ---------- ---------- -----
---------------------xmltr ee.css---- ---------- ---------- ---------- --
body
{
font: 10pt Verdana,sans-serif;
color: navy;
}
.trigger{
cursor: hand;
display: block;
}
.branch{
display: none;
margin-left: 16px;
}
.leaf
{
cursor: hand;
background-color:white;
color:navy;
}
.leafSelected
{
background-color:Navy;
color:White;
}
-------------------------- ---------- ---------- ---------- ---------- -
-------------------------- ----tree.h tm-------- ---------- --------
<html>
<head>
<title>XML Tree Control</title>
<script language="javascript" src="xmltree.js"></script>
</head>
<body>
<form name="form1" id="form1" method="post" action="">
<iframe id="tree" src="tree.xml" value="" STYLE="POSITION:RELATIVE" ></iframe>
<input type="button" name="cmd" id="cmd" value="value" onclick="alert(SelectedLea fID);">
</form>
</body>
</html>
-------------------------- ---------- ---------- ---------- ---------- ---------- ----------
you will also need three images called:
open.gif
closed.gif
doc.gif
Thx
everithing went as planned until i tryed to get a value of a variable named SelectedLeafID from a tree.htm.
Variable is defined inside a xmltree.js.
xmltree.xls uses that script and function SelectedLeaf_Changed changes the value of SelectedLeafID.
but tree.htm can't read its value.
Why not ??? and "Is there a way to do that?"
here are the files
----------------------- tree.xml --------------------------
<?xml version="1.0" ?>
<!DOCTYPE tree SYSTEM "tree.dtd">
<?xml-stylesheet type="text/xsl" href="xmlTree.xsl"?>
<tree>
<branch id="B1">
<branchText>Branch1</branc
<leaf id="L1">
<leafText>Leaf1</leafText>
</leaf>
<leaf id="L2">
<leafText>Leaf2</leafText>
</leaf>
</branch>
<branch id="B2">
<branchText>Branch2</branc
<leaf id="L3">
<leafText>Leaf3</leafText>
</leaf>
<branch id="B3">
<branchText>Branch3</branc
<leaf id="L4">
<leafText>Leaf4</leafText>
</leaf>
<leaf id="L5">
<leafText>Leaf5</leafText>
</leaf>
</branch>
<leaf id="L6">
<leafText>Leaf6</leafText>
</leaf>
</branch>
</tree>
--------------------------
--------------------------
<?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>XML Tree Control</title>
<link rel="stylesheet" type="text/css" href="xmlTree.css"/>
<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="branch">
<span class="trigger">
<xsl:attribute name="onClick">showBranch(
<img src="closed.gif">
<xsl:attribute name="id">I<xsl:value-of select="@id"/></xsl:attrib
</img>
<xsl:value-of select="branchText"/>
<br/>
</span>
<span class="branch">
<xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attrib
<xsl:apply-templates/>
</span>
</xsl:template>
<xsl:template match="leaf">
<img src="doc.gif"/>
<span class="leaf">
<xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attrib
<xsl:attribute name="onClick">SelectedLea
<xsl:value-of select="leafText"/>
</span><br/>
</xsl:template>
<!-- avoid output of text node with default template -->
<xsl:template match="branchText"/>
</xsl:stylesheet>
--------------------------
--------------------------
var SelectedLeafID= null;
var openImg = new Image();
openImg.src = "open.gif";
var closedImg = new Image();
closedImg.src = "closed.gif";
function showBranch(branch){
var objBranch = document.getElementById(br
if(objBranch.display=="blo
objBranch.display="none";
else
objBranch.display="block";
swapFolder('I' + branch);
}
function swapFolder(img){
objImg = document.getElementById(im
if(objImg.src.indexOf('clo
objImg.src = openImg.src;
else
objImg.src = closedImg.src;
}
function SelectedLeaf_Changed(xleaf
{
if (SelectedLeafID!=null)docu
var lf = document.getElementById(xl
lf.className="leafSelected
SelectedLeafID = xleafID;
}
--------------------------
---------------------xmltr
body
{
font: 10pt Verdana,sans-serif;
color: navy;
}
.trigger{
cursor: hand;
display: block;
}
.branch{
display: none;
margin-left: 16px;
}
.leaf
{
cursor: hand;
background-color:white;
color:navy;
}
.leafSelected
{
background-color:Navy;
color:White;
}
--------------------------
--------------------------
<html>
<head>
<title>XML Tree Control</title>
<script language="javascript" src="xmltree.js"></script>
</head>
<body>
<form name="form1" id="form1" method="post" action="">
<iframe id="tree" src="tree.xml" value="" STYLE="POSITION:RELATIVE" ></iframe>
<input type="button" name="cmd" id="cmd" value="value" onclick="alert(SelectedLea
</form>
</body>
</html>
--------------------------
you will also need three images called:
open.gif
closed.gif
doc.gif
Thx
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
--------------------tree.d
<!ELEMENT tree (branch+)>
<!ELEMENT branch (branchText,(branch|leaf)*
<!ATTLIST branch id CDATA #REQUIRED>
<!ELEMENT branchText (#PCDATA)>
<!ATTLIST leaf id CDATA #REQUIRED>
<!ELEMENT leaf (leafText)>
<!ELEMENT leafText (#PCDATA)>
--------------------------