473,385 Members | 1,620 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

XML XSL javascript, sorting child node of data island

Tim
I've been working on this for over a week now, and just can't get this
figured out. Hoping one of you gurus can help me out here.

I have an xml data island that I'm representing on an htm page as an
expandable menu. Got that working, but now I need to add sorting and
searching abilities to the menu. I am hoping to do this with xsl but
can't get it to work.

Is this because of the way I've formed my xml, having the children
within the parent elements? Or is my xml alright but my xsl is mis
formed.

If you could help me figure out how to simply have xsl sort the list,
I'm sure I could figure out the rest.

If your solution is strictly using javascript, then please be specific
as I'm not too familiar with the javascript/xml api yet.

----html code below----

<XML id=xmlDSO></XML>
<XML ID="SortDateXSL">
<root>
<xsl:for-each order-by="+ item_title" select="root/master/detail"
xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<master>
<category_id><xsl:value-of select="category_id"/></category_id>
<category_name><xsl:value-of
select="category_name"/></category_name>
<detail>
<item_id><xsl:value-of select="item_id"/></item_id>
<item_title><xsl:value-of select="item_title"/></item_title>
<item_date><xsl:value-of select="item_date"/></item_date>
<item_hours><xsl:value-of select="item_hours"/></item_hours>
<item_posted><xsl:value-of select="item_posted"/></item_posted>
</detail>
</master>
</xsl:for-each>
</root>
</XML>

<XML ID="SortTitleXSL">
<root>
<master>
<category_id><xsl:value-of select="category_id"/></category_id>
<category_name><xsl:value-of
select="category_name"/></category_name>
<xsl:for-each order-by="+ item_title" select="master"
xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<detail>
<xsl:attribute name="ID"><xsl:value-of select="@ID"/>
<item_id><xsl:value-of select="item_id"/></item_id>
<item_title><xsl:value-of select="item_title"/></item_title>
<item_date><xsl:value-of select="item_date"/></item_date>
<item_hours><xsl:value-of select="item_hours"/></item_hours>
<item_posted><xsl:value-of select="item_posted"/></item_posted>
</detail>
</xsl:for-each>
</master>
</root>
</XML>

<TABLE dataSrc="#xmlDSO" cellSpacing="0" cellPadding="0">
<TBODY>
<TR>
<TD colSpan="2">
<TABLE style="FONT-SIZE: 12px; FONT-FAMILY: arial; TEXT-ALIGN: left"
cellSpacing="0" cellPadding="0">
<TBODY>
<TR>
<TD style="WIDTH: 20px; HEIGHT: 20px" align="right">
<IMG style="CURSOR: hand" onclick="doExpandClick(tblDetails);"
src="img/xml-plus.gif" align=absMiddle>
</TD>
<TD style="WIDTH: 20px; HEIGHT: 20px">
<IMG src="img/xml-folder.gif">
</TD>
<TD style="WIDTH: 500px; TEXT-ALIGN: left">
<SPAN DATAFLD="category_name"></SPAN>
</TD>
</TR>
</TBODY>
</TABLE>
</TD>
</TR>
<TR>
<TD style="WIDTH: 20px"></TD>
<TD>
<TABLE dataFld="detail" style="DISPLAY: none" dataSrc="#xmlDSO"
cellSpacing="1" cellPadding="2" border="0">
<THEAD>
<TR>
<TH style="WIDTH: 20px">&nbsp;</TH>
<TH style="WIDTH: 400px" align="middle">
<NOBR><A href="javascript:sort(SortTitleXSL.XMLDocument)">T itle</A></NOBR>
</TH>
<TH style="WIDTH: 50px" align="middle">
<NOBR><A href="javascript:sort(SortDateXSL.XMLDocument)">Ye ar</A></NOBR>
</TH>
<TH style="WIDTH: 50px" align="middle">
<NOBR>Hours</NOBR>
</TH>
<TH style="WIDTH: 50px" align="middle">
<NOBR>Posted</NOBR>
</TH>
</TR>
</THEAD>
<TBODY>
<TR id="trDetail" name="trDetail">
<TD style="WIDTH: 20px">
<IMG src="img/xml-item.gif">
</TD>
<TD style="WIDTH: 400px" align="left">
<SPAN DATAFLD="item_title"></SPAN>
</TD>
<TD style="WIDTH: 50px" align="middle">
<SPAN DATAFLD="item_date"></SPAN>
</TD>
<TD style="WIDTH: 50px" align="middle">
<SPAN DATAFLD="item_hours"></SPAN>
</TD>
<TD style="WIDTH: 50px" align="middle">
<SPAN DATAFLD="item_posted"></SPAN>
</TD>
</TR>
</TBODY>
</TABLE>
</TD>
</TR>
</TBODY>
</TABLE>

<SCRIPT language=javascript>
xmlDSO.async = false;
xmlDSO.load("test_tool_get-xml.xml");
var xmldoc = xmlDSO.cloneNode(true);

function sort(WhichXSL){
xmlDSO.loadXML(xmldoc.documentElement.transformNod e
(WhichXSL.documentElement));
}

function doExpandClick(tblDetailData){
try{
var strSrc = new String(event.srcElement.src);
if (strSrc.indexOf("minus") > 0){
strNewSrc = strSrc.replace("minus", "plus");
}
else{
strNewSrc = strSrc.replace("plus", "minus");
}
event.srcElement.src = strNewSrc
var recNumber = event.srcElement.recordNumber - 1;
if (tblDetailData[recNumber].style.display == "none"){
tblDetailData[recNumber].style.display = "";
}
else{
tblDetailData[recNumber].style.display = "none";
}
}
}
</SCRIPT>
----end html----
################
----xml file below saved as "test_tool_get-xml.xml"----
<?xml version="1.0" ?>
<root>
<master id="3">
<category_id>3</category_id>
<category_name>Cosourcing</category_name>
</master>
<master id="2">
<category_id>2</category_id>
<category_name>Comprehensive Tax Solutions</category_name>
</master>
<master id="1">
<category_id>1</category_id>
<category_name>Business Advisory</category_name>
</master>
<master id="4">
<category_id>4</category_id>
<category_name>GEIS--EBT</category_name>
<detail id="34">
<item_id>34</item_id>
<item_title>G Time! Executive Compensation</item_title>
<item_date>2003</item_date>
<item_hours>1</item_hours>
<item_href></item_href>
<item_src></item_src>
<item_type>xml-item</item_type>
<item_posted></item_posted>
</detail>
<detail id="77">
<item_id>77</item_id>
<item_title>Family Wealth Planning Basis Estate Planning (1 of
6)</item_title>
<item_date>2003</item_date>
<item_hours>2</item_hours>
<item_href></item_href>
<item_src></item_src>
<item_type>xml-item</item_type>
<item_posted></item_posted>
</detail>
<detail id="80">
<item_id>80</item_id>
<item_title>Employee Benefits Update</item_title>
<item_date>2003</item_date>
<item_hours>0.5</item_hours>
<item_href></item_href>
<item_src></item_src>
<item_type>xml-item</item_type>
<item_posted></item_posted>
</detail>
</master>
<master id="5">
<category_id>5</category_id>
<category_name>GEIS--IAS</category_name>
</master>

</root>
----end xml----
Jul 20 '05 #1
5 1843
On 18 Feb 2004 14:08:06 -0800, sm******@hotmail.com (Tim) wrote:
I've been working on this for over a week now,


Yes, well take whatever obsolete book you're reading and throw it a
very long way away. Nothing that contains the strings "DSO" or the
attribute "dataFld" has ever worked right.

Use client-side XSLT. It's a bit browser-specific, but it does work
well (where it can work at all).

--
Smert' spamionam
Jul 20 '05 #2
Tim
Okay, thanks for the advice.

Can you recomend any sites that have good tutorials on this kind of
thing?

Everything I know comes from googling but I'm afraid I might be asking
google the wrong questions.
Yes, well take whatever obsolete book you're reading and throw it a
very long way away. Nothing that contains the strings "DSO" or the
attribute "dataFld" has ever worked right.

Use client-side XSLT. It's a bit browser-specific, but it does work
well (where it can work at all).

Jul 20 '05 #3
On 19 Feb 2004 08:03:44 -0800, sm******@hotmail.com (Tim) wrote:
Can you recomend any sites that have good tutorials on this kind of
thing?


Sorry, no. I'm sure there are, but I'm not up to date on what's out
there.

As to books, then my tutorial pick is still Michael Kay's XSLT book.
That'll cover XSLT and XPath, and the client-side scripting for data
islands is a trivial example that's a M$oft example (you load the
document into one DOM, the XSLT into another and use the
..transformNode() method)..

M$oft do a very useful (and a free download) SDK for their MSXML
component. This is a Windows help file that describes XSLT and DOM.
It's thin on examples, terrible as a tutorial, but a convenient
reference that I never travel without.

BTW - Is there any way to use this thing on a Linux box ? WINE ? It's
cross-language, so the JavaScript version of it is also a pretty
useful reference for accessing DOM from Java
--
Smert' spamionam
Jul 20 '05 #4
Tim
May thanks.
I've got this thing working as a straight xml page now while using xsl
to format it. I can see the light!

Now all I have to do is import the menu into an asp page from the
client. I guess it's the same as importing the xml into an html page.
Time to go script searching...

Will look into your tut' samples once I get some more time.

BTW, I tried running this MS help file in cygwin, but no fun. I didn't
try too hard though.
If you wanted to run this in *nix I woud suggest finding a Linux
version of a .chm reader. The file you want to read is the help file
in the MSXML 4.0 folder in your program files folder. I have no idea
if there is such a thing for *nix but I'm sure there is, so good luck.

Thanks again!
Can you recomend any sites that have good tutorials on this kind of
thing?


Sorry, no. I'm sure there are, but I'm not up to date on what's out
there.

As to books, then my tutorial pick is still Michael Kay's XSLT book.
That'll cover XSLT and XPath, and the client-side scripting for data
islands is a trivial example that's a M$oft example (you load the
document into one DOM, the XSLT into another and use the
.transformNode() method)..

M$oft do a very useful (and a free download) SDK for their MSXML
component. This is a Windows help file that describes XSLT and DOM.
It's thin on examples, terrible as a tutorial, but a convenient
reference that I never travel without.

BTW - Is there any way to use this thing on a Linux box ? WINE ? It's
cross-language, so the JavaScript version of it is also a pretty
useful reference for accessing DOM from Java

Jul 20 '05 #5
Andy Dingley wrote:
M$oft do a very useful (and a free download) SDK for their MSXML
component. This is a Windows help file that describes XSLT and DOM.
It's thin on examples, terrible as a tutorial, but a convenient
reference that I never travel without.

BTW - Is there any way to use this thing on a Linux box ? WINE ?
[...]


I do not know what type of file you are exactly writing about. However,
you can decompile Help files (.hlp) or compiled HTML files (.chm) and
then view it on Linux with your favorite app. From a Google search for
"decompile html help":

<http://www.helpscribble.com/decompiler.html>
<http://msdn.microsoft.com/workshop/author/htmlhelp/download.asp>
<http://www.keyworks.net/>
<http://www.blue-sky.com/>

If you need only one compiled HTML document, you can view the source
in your favorite text editor (right-click, View Source) and save it
whereever you want.

The CrossOver Plugin (includes a basic WINE distribution) *could*
be another possibility, run "hh.exe $chm_helpfile" or "winhlp32.exe
$hlp_file" with it: <http://www.codeweavers.com/products/crossover/>
F'up2 comp.text.xml

PointedEars
Jul 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Tim | last post by:
I've been working on this for over a week now, and just can't get this figured out. Hoping one of you gurus can help me out here. I have an xml data island that I'm representing on an htm page as...
27
by: C Gillespie | last post by:
Dear All, Hopefully I have a simple problem. Basically, I just want to alter some text with JS. Here is some of my test code: <snip> <script type="text/javascript"> var tmp='a';
16
by: Jay | last post by:
I've been using Travis's Expanding Menu (http://www.squidfingers.com/code/dhtml/expandingmenu/) for a site i'm working on. The problem is I need to add some functionality to it. I need the the...
3
by: Jane D | last post by:
I have got a bookmarklet for use with Opera which highlights all occurrences of some text in the displayed page. I find it very useful. Sometimes I need to use two or three different colours...
2
by: DelphiBlue | last post by:
I have a Nested Datagrid that is using a data relations to tie the parent child datagrids together. All is working well with the display but I am having some issues trying to sort the child...
1
by: Johan Åhlén | last post by:
Hi, Does anybody have any idea how to access child nodes in a TreeView without using postbacks? For example: in the subtree below I want to disable nodes B, C and D when A is checked (and...
3
by: jimmygoogle | last post by:
I posted earlier with a scope problem. I think I resolved it in IE but in Firefox it still exists. Anyone have any ideas/experience with this? I attached my code sorry it is so long. You can...
4
by: bboyle18 | last post by:
Hi, I am working with a table sorting script which can be found here http://www.workingwith.me.uk/articles/scripting/standardista_table_sorting This script works very nicely, but when there is a...
1
by: Ger | last post by:
My problem is related to this thread. I wrote an XML DOM parser. It parses the complete tree on IE, but it stops after the first downstream on FireFox, SeaMonkey and Opera. This is a simplified code...
5
by: jrod11 | last post by:
hi, I found a jquery html table sorting code i have implemented. I am trying to figure out how to edit how many colums there are, but every time i remove code that I think controls how many colums...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.