 |
|
 |
I've been trying to get this to work with no success. I can't even get it to work imbeding it in simple html. I used the javascript above and put the following in the body to just do a single child/parent tree. The parent is visible and the child is not, like it should be, but it won't expand.
<input type="hidden" id="hidIsExpanded" value="0" />
+</label>
Message:
<label class="Expander"> </label>
asdf = asdf
|
|
|
|
 |
|
 |
Crap forgot to turn off HTML interpretting.
<div class="Parent IsVisible">
<input type="hidden" id="hidIsExpanded" value="0" />
<label id="lblExpand" class="Expander" onclick="ExpanderClicked(event)">+</label>
<span>Message:</span>
<div class="NotVisible">
<label class="Expander"> </label>
<span>asdf = asdf</span><br/>
</div>
|
|
|
|
 |
|
 |
Ya, I'm retarded I had a typo. It works in straight html but still not working with my xslt...i'll get back with a more specific question about my xslt code tomorrow...
|
|
|
|
 |
|
 |
Hi,
I have made a cross-browser compatible version of the JavaScript. Replace tree.js with this code:
function ExpanderClicked(event) {
var ctlExpander;
if (event.target) {
ctlExpander=event.target;
}
else if (event.srcElement) {
ctlExpander=event.srcElement;
}
var parent = ctlExpander.parentNode;
var childs = parent.childNodes;
var count = 0;
for (var i = 0; i < childs.length; i++) {
if (childs[i].nodeType == 1) {
if (childs[i].nodeName == 'DIV') {
if (childs[i].parentNode == parent) {
count++;
}
}
}
}
if (count > 0) {
var strCSS;
elem = ctlExpander.previousSibling;
while (elem.innerHTML == null) {
elem = elem.previousSibling;
}
if (elem.value == "1") {
ctlExpander.innerHTML = "+ ";
elem.value = "0";
strCSS = "NotVisible";
}
else {
ctlExpander.innerHTML = "- ";
elem.value = "1";
strCSS = "IsVisible";
}
for (var i = 0; i < childs.length; i++) {
if (childs[i].nodeType == 1) {
if (childs[i].nodeName == 'DIV') {
if (childs[i].parentNode == parent) {
childs[i].className = strCSS;
}
}
}
}
}
}
You also need to replace ExpanderClicked() with ExpanderClicked(event) in the XSLT.
This code was tested 14 april 2008 with Internet Explorer 7, Firefox 2, Opera 9, Netscape Navigator 8, and Safari 3.
|
|
|
|
 |
|
 |
Hello Can someone help me! I have a problem about xslt I want to use attribute to be a condition what should I write xslt command or function this is my xml file <assess_controls> <assess_control> <<b>company_name</b>><u>xxx</u></company_name> <<b>form_name</b> <b>no</b>="<u>1</u>">form_xxx</form_name> <assesser_name>xxx</assesser_name> <control_type>xxx</control_type> <control_subgroup sub_group="1 xxx"> <activitys> <activity>xxx</activity> <comment>comment 1</comment> </activitys> </control_subgroup> <control_subgroup sub_group="2 xxx"> <activitys> <activity>xxx3 </activity> <comment>comment 3</comment> </activitys> </control_subgroup> </assess_control> <assess_control> <company_name>xxx</company_name> <form_name no="2">form_xxx</form_name> <assesser_name>yyy</assesser_name> <control_type>yyy</control_type> <control_subgroup sub_group="1 yyy"> <activitys> <activity>yyy</activity> <comment>comment 1</comment> </activitys> </control_subgroup> <control_subgroup sub_group="2 yyy"> <activitys> <activity>yyy3 </activity> <comment>comment 3</comment> </activitys> </control_subgroup> </assess_control> </assess_controls>
<big>I want to use <company_name>, <form_name> and attribute of form_name "no" and xslt if below</big>
<xsl:param name="<b>comp</b>">admin</xsl:param> <xsl:param name="<b>formname</b>">pppp</xsl:param> <xsl:param name="<b>formno</b>">1</xsl:param> <xsl:template match="/"> <HTML> <BODY STYLE="font-family:Arial, helvetica, sans-serif; font-size:10pt; background-color:#EEEEEE"> <xsl:apply-templates/> </BODY> </HTML> </xsl:template> <xsl:template match="assess_control"> <xsl:if test="company_name = <b>$comp</b>"> <xsl:if test="form_name = <b>$formname</b>"> <xsl:apply-templates select= "form_name"/> <table class = "borders" border = "1"> <tr class = "largebluetext"> <td><xsl:value-of select="company_name"/></td> <td><xsl:value-of select="control_type"/></td> <td><xsl:value-of select="control_group"/></td></tr> <tr><td><xsl:value-of select ="form_name"/></td></tr> </table> <xsl:apply-templates select ="control_subgroup "/> <xsl:value-of select="@sub_group"/> </xsl:if> </xsl:if> </xsl:template> <xsl:template match="form_name"> <xsl:if test="<b>$formno</b>"> <table><tr><td>no: <xsl:value-of select="@no"/></td></tr></table> </xsl:if> </xsl:template>
<xsl:template match="control_subgroup"> <span class="blacktext"> <xsl:value-of select="@sub_group"/> </span> <xsl:for-each select="activitys"> <table class = "borders" border = "1"> <tr class = "largeyellowtext"> <td class = "borders1"><xsl:value-of select="activity"/></td> <td class = "borders2"><xsl:value-of select="score"/></td> <td class = "borders3"><xsl:value-of select="comment"/></td></tr> </table> </xsl:for-each> </xsl:template> </xsl:stylesheet>
The problem is I can't specify form_name[@no] I want. What wrong of my xslt code?
Thank you very much
|
|
|
|
 |
|
 |
Hello Can someone help me! I have a problem about xslt I want to use attribute to be a condition what should I write xslt command or function this is my xml file <assess_controls> <assess_control> <company_name>xxx</company_name> <form_name no="1">form_xxx</form_name> <assesser_name>xxx</assesser_name> <control_type>xxx</control_type> <control_subgroup sub_group="1 xxx"> <activitys> <activity>xxx</activity> <comment>comment 1</comment> </activitys> </control_subgroup> <control_subgroup sub_group="2 xxx"> <activitys> <activity>xxx3 </activity> <comment>comment 3</comment> </activitys> </control_subgroup> </assess_control> <assess_control> <company_name>yyy</company_name> <form_name no="2">form_xxx</form_name> <assesser_name>yyy</assesser_name> <control_type>yyy</control_type> <control_subgroup sub_group="1 yyy"> <activitys> <activity>yyy</activity> <comment>comment 1</comment> </activitys> </control_subgroup> <control_subgroup sub_group="2 yyy"> <activitys> <activity>yyy3 </activity> <comment>comment 3</comment> </activitys> </control_subgroup> </assess_control> </assess_controls>
<big>I want to use <company_name>, <form_name> and attribute of form_name "no" and xslt if below</big>
<xsl:param name="<b>comp</b>">admin</xsl:param> <xsl:param name="<b>formname</b>">pppp</xsl:param> <xsl:param name="<b>formno</b>">1</xsl:param> <xsl:template match="/"> <HTML> <BODY STYLE="font-family:Arial, helvetica, sans-serif; font-size:10pt; background-color:#EEEEEE"> <xsl:apply-templates/> </BODY> </HTML> </xsl:template> <xsl:template match="assess_control"> <xsl:if test="company_name = <b>$comp</b>"> <xsl:if test="form_name = <b>$formname</b>"> <xsl:apply-templates select= "form_name"/> <table border = "1"> <tr> <td><xsl:value-of select="company_name"/></td> <td><xsl:value-of select="control_type"/></td> <td><xsl:value-of select="control_group"/></td></tr> <tr><td><xsl:value-of select ="form_name"/></td></tr> </table> <xsl:apply-templates select ="control_subgroup "/> <xsl:value-of select="@sub_group"/> </xsl:if> </xsl:if> </xsl:template>
<xsl:template match="form_name"> <xsl:if test="<b>$formno</b>"> <table><tr><td>no: <xsl:value-of select="@no"/></td></tr></table> </xsl:if> </xsl:template>
<xsl:template match="control_subgroup"> <span class="blacktext"> <xsl:value-of select="@sub_group"/> </span> <xsl:for-each select="activitys"> <table border = "1"> <tr class = "largeyellowtext"> <td class = "borders1"><xsl:value-of select="activity"/></td> <td class = "borders2"><xsl:value-of select="score"/></td> <td class = "borders3"><xsl:value-of select="comment"/></td></tr> </table> </xsl:for-each> </xsl:template> </xsl:stylesheet>
The problem is I can't specify form_name[@no] I want. What wrong of my xslt code?
Thank you very much
|
|
|
|
 |
|
 |
i need a Tabular tree conrol thro' xml xslt.If you have source code, let me know.
tabular tree control is similar to squishy control(server side).
I need a client side control.
|
|
|
|
 |
|
 |
I believe there is a small bug when the root node is contracted, it seems to lose the value of the ctlHidden from time to time (something to do with lower nodes being expanded) Simply, if you add: alert(ctlHidden.value) before the staus check of node: (if(ctlHidden.value == "1")) you will see that it can come back as undefined. After looking into this further, it seems to lose which element the event was fired from at the begining of the funcion. var ctlExpander = event.srcElement; var ctlSelectedEntry = ctlExpander.parentElement; and as such does not know what the vtlHidden value is set to... I cannot find a way to fix this problem, it looks like it may be an inherent event handling bug with ie6. Any suggesttions/comments? J
|
|
|
|
 |
|
 |
anyone know how to make the javascript working with Mozilla?
|
|
|
|
 |
|
 |
Hi,
have you got any solution for this? if yes, please forward me to mrameshchandra@gmail.com. This is very urgent.
Thanks and regards,
mrc
|
|
|
|
 |
|
 |
In Firefox 2.0.0.4 the menu behavior is non existent.
The parent/children are all shown one under another
Any clues? Perhaps a javascript method is defined only in IE?
|
|
|
|
 |
|
 |
Thanks for the menu, just what I was looking for....
I wanted to use without asp, so I moved the javascript code to the html page containing the javascript transform.
It all works except the very top item, and IE 6 gives the following error:
Line: 21
Char: 3
Error: Object Required
Code: 0
Any thoughts please,
below is my html code.
Thanks
Neil
<body>
<script language="javascript">
function ExpanderClicked()
{
//Get the element that was clicked
var ctlExpander = event.srcElement;
var ctlSelectedEntry = ctlExpander.parentElement;
//Get all the DIV elements that are direct descendants
var colChild = ctlSelectedEntry.children.tags("DIV");
if(colChild.length > "0")
{
var strCSS;
//Get the hidden element that indicates whether or not entry is expanded
var ctlHidden = ctlSelectedEntry.all("hidIsExpanded");
if(ctlHidden.value == "1")
{
//Entry was expanded and is being contracted
ctlExpander.src = "images/album.gif";
ctlHidden.value = "0";
strCSS = "NotVisible";
}
else
{
//Entry is being expanded
ctlExpander.src = "images/album.gif";
ctlHidden.value = "1";
strCSS = "IsVisible";
}
//Show all the DIV elements that are direct children
for(var intCounter = 0; intCounter < colChild.length; intCounter++)
{
colChild[intCounter].className = strCSS;
}
}
}
</script>
<script type="text/javascript">
// Load XML
var xml = new ActiveXObject("Msxml2.DOMDocument")
xml.async = false
xml.load("contents.xml")
// Load XSL
var xsl = new ActiveXObject("Msxml2.DOMDocument")
xsl.async = false
xsl.load("contents1.xsl")
// Transform
document.write(xml.transformNode(xsl))
</script>
|
|
|
|
 |
|
 |
I copied your code into a .htm file and I don't get an error. From the error message I suspect that the problem is with a null variable. I suggest you "debug" the code by putting in an alert every so often to determine if any of your variables are null.
|
|
|
|
 |
|
 |
I'm unable to figure it out, could you have a look at the rest of my code please?
here is the rest of the code:
contents1.xsl:
Parent IsVisible
<!-- Element has children, it can be expanded -->
<input type="hidden" id="hidIsExpanded" value="0" />
<img src="images/album.gif" id="lblExpand" önclick="ExpanderClicked()" />
<img src="images/cd.gif" class="Expander" />
NotVisible
contents.xml
Bryan Adams
The Best Of Me
Christina Aguilera
Christina Aguilera
B*Witched
B*Witched
|
|
|
|
 |
|
 |
****ignore other msg, forgot to ignore html**** I'm unable to figure it out, could you have a look at the rest of my code please? here is the rest of the code: contents1.xsl: <code><?xml version="1.0" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <xsl:for-each select="//db1/cdmenu"> <xsl:call-template name="SubMenu"> <xsl:with-param name="strCSS">Parent IsVisible</xsl:with-param> </xsl:call-template> </xsl:for-each> </xsl:template> <xsl:template name="SubMenu"> <xsl:param name="strCSS" /> <xsl:variable name="strURL" select="Artist" /> <div class="{$strCSS}"> <xsl:choose> <xsl:when test="count(cdmenu) > 0"> <!-- Element has children, it can be expanded --> <input type="hidden" id="hidIsExpanded" value="0" /> <img src="images/album.gif" id="lblExpand" onclick="ExpanderClicked()" /> </xsl:when> <xsl:otherwise> <img src="images/cd.gif" class="Expander" /> </xsl:otherwise> </xsl:choose> <a href="data.html#{$strURL}" target="DataF" class="pnpNavigatorLink"><xsl:value-of select="Artist" /></a> <xsl:for-each select="cdmenu"> <xsl:call-template name="SubMenu"> <xsl:with-param name="strCSS">NotVisible</xsl:with-param> </xsl:call-template> </xsl:for-each> </div> </xsl:template> </xsl:stylesheet> </code> contents.xml <code><db1> <cdmenu> <Artist>Bryan Adams</Artist> <cdmenu><Artist>The Best Of Me</Artist></cdmenu> </cdmenu> <cdmenu> <Artist>Christina Aguilera</Artist> <cdmenu><Artist>Christina Aguilera</Artist></cdmenu> </cdmenu> <cdmenu> <Artist>B*Witched</Artist> <cdmenu><Artist>B*Witched</Artist></cdmenu> </cdmenu> </db1></code>
|
|
|
|
 |
|
 |
solved it, It needs text before the function as a title in plain html.
Thanks Neil
|
|
|
|
 |
|
 |
Is it possible to ad Persistence to the menu, so the tree remains in the same state after opening a new page. Perhaps with a session variable Regards Claus
|
|
|
|
 |
|
 |
i'm sorry but i'm new to XML and i can't get the script working i've downloaded the .zip file and extract all the files into my web server and run the script. all i get is :
Development Parent IsVisible + NotVisible
when i click the + button nothing happens! Any ideas? ps: i'm using Internet explorer 6 chris B
|
|
|
|
 |
|
 |
AFAIK all you need to run this is IE5.5 or greater, and the MSXML parser Version 3. Since the tree isn't rendering properly ("IsVisible" and "NotVisible" are CSS classes, and you should definitely not be seeing those), I'm guessing it might be that you don't have the correct parser?
Do any script errors appear when the tree loads?
|
|
|
|
 |
|
 |
I got the same problem with the tree not rendering properly. Replacing the XML parser from "Microsoft.XMLDOM" to "Msxml2.DOMDocument" seemed to do the trick.
Note - Not sure if this is the best solution - I'm new to this sort of thing.
|
|
|
|
 |
|
 |
I am sorry, I don't have the patience to peruse this potentially useful article until can see the end result.
-Domenic Denicola- [CPUA 0x1337]
Geekn
MadHamster Creations
|
|
|
|
 |
|
 |
The image is at the top of the page (The menu in the image contains "Development" at the top, with "In-House" and "Microsoft" on the next level, etc.) - that is basically what the menu looks like.
Of course, it is entirely possible to add snazzy little images to indicate whether a menu entry is expanded or collapsed, but I figured "+" and "-" are okay.
|
|
|
|
 |
|
 |
I'm dumb
In that case, good work. Nice article! And sorry about my stupidity
-Domenic Denicola- [CPUA 0x1337]
Geekn
MadHamster Creations
|
|
|
|
 |
|
 |
yes u are
hey just kidding.. guys do post some good XML examples and tutorial, Also how to working with JSP as well as ASP too.. and even where can we decide to have xml in business logic. For eample I want to develop informatics banking project or shopping carts?
I know what it does and how its work now I am doing some business logic brain stroming. Please do joing me and lets share knowledge.
Thanks and regards.
Anand Bisht
|
|
|
|
 |
|
 |
Other than having extremely limited space, I can't think of a reason why not to use XML. Both the concept and the format are simple - after all, it's basically a formatted string. And it works well on the user interface layer. You don't strictly need XSLT to transform XML for display; theres DOM, SAX, etc. (Server-side you can use pretty much what you want.)
BTW, if you're using .NET, you'll find that XML is a major part of it.
|
|
|
|
 |