473,574 Members | 3,170 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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><x sl:value-of select="categor y_id"/></category_id>
<category_name> <xsl:value-of
select="categor y_name"/></category_name>
<detail>
<item_id><xsl:v alue-of select="item_id "/></item_id>
<item_title><xs l:value-of select="item_ti tle"/></item_title>
<item_date><xsl :value-of select="item_da te"/></item_date>
<item_hours><xs l:value-of select="item_ho urs"/></item_hours>
<item_posted><x sl:value-of select="item_po sted"/></item_posted>
</detail>
</master>
</xsl:for-each>
</root>
</XML>

<XML ID="SortTitleXS L">
<root>
<master>
<category_id><x sl:value-of select="categor y_id"/></category_id>
<category_name> <xsl:value-of
select="categor y_name"/></category_name>
<xsl:for-each order-by="+ item_title" select="master"
xmlns:xsl="http ://www.w3.org/TR/WD-xsl">
<detail>
<xsl:attribut e name="ID"><xsl: value-of select="@ID"/>
<item_id><xsl:v alue-of select="item_id "/></item_id>
<item_title><xs l:value-of select="item_ti tle"/></item_title>
<item_date><xsl :value-of select="item_da te"/></item_date>
<item_hours><xs l:value-of select="item_ho urs"/></item_hours>
<item_posted><x sl:value-of select="item_po sted"/></item_posted>
</detail>
</xsl:for-each>
</master>
</root>
</XML>

<TABLE dataSrc="#xmlDS O" 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="doExpa ndClick(tblDeta ils);"
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="catego ry_name"></SPAN>
</TD>
</TR>
</TBODY>
</TABLE>
</TD>
</TR>
<TR>
<TD style="WIDTH: 20px"></TD>
<TD>
<TABLE dataFld="detail " style="DISPLAY: none" dataSrc="#xmlDS O"
cellSpacing="1" cellPadding="2" border="0">
<THEAD>
<TR>
<TH style="WIDTH: 20px">&nbsp;</TH>
<TH style="WIDTH: 400px" align="middle">
<NOBR><A href="javascrip t:sort(SortTitl eXSL.XMLDocumen t)">Title</A></NOBR>
</TH>
<TH style="WIDTH: 50px" align="middle">
<NOBR><A href="javascrip t:sort(SortDate XSL.XMLDocument )">Year</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_t itle"></SPAN>
</TD>
<TD style="WIDTH: 50px" align="middle">
<SPAN DATAFLD="item_d ate"></SPAN>
</TD>
<TD style="WIDTH: 50px" align="middle">
<SPAN DATAFLD="item_h ours"></SPAN>
</TD>
<TD style="WIDTH: 50px" align="middle">
<SPAN DATAFLD="item_p osted"></SPAN>
</TD>
</TR>
</TBODY>
</TABLE>
</TD>
</TR>
</TBODY>
</TABLE>

<SCRIPT language=javasc ript>
xmlDSO.async = false;
xmlDSO.load("te st_tool_get-xml.xml");
var xmldoc = xmlDSO.cloneNod e(true);

function sort(WhichXSL){
xmlDSO.loadXML( xmldoc.document Element.transfo rmNode
(WhichXSL.docum entElement));
}

function doExpandClick(t blDetailData){
try{
var strSrc = new String(event.sr cElement.src);
if (strSrc.indexOf ("minus") > 0){
strNewSrc = strSrc.replace( "minus", "plus");
}
else{
strNewSrc = strSrc.replace( "plus", "minus");
}
event.srcElemen t.src = strNewSrc
var recNumber = event.srcElemen t.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>xm l-item</item_type>
<item_posted> </item_posted>
</detail>
<detail id="77">
<item_id>77</item_id>
<item_title>Fam ily 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>xm l-item</item_type>
<item_posted> </item_posted>
</detail>
<detail id="80">
<item_id>80</item_id>
<item_title>Emp loyee 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>xm l-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 6476
On 18 Feb 2004 14:08:06 -0800, sm******@hotmai l.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******@hotmai l.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.helpscribbl e.com/decompiler.html >
<http://msdn.microsoft. com/workshop/author/htmlhelp/download.asp>
<http://www.keyworks.ne t/>
<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.e xe
$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
1846
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 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...
27
2168
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
2928
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 ability to define a subsection to be open when you land on a page, but when you select another option for it to open that section and close the...
3
1751
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 for different keywords I want highlighting on the same page. I have done this by changing the original word 'yellow' for other javascript colour...
2
945
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 datagrid. HTML Datagrid1 TemplateColumn Table Header information Detail Information
3
3345
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 cut/paste it into 2 files and run it to see what I mean. ###############menu.html############### <html> <body> <script type="text/javascript">
4
6313
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 large amount of data to sort e.g > 200 then there is a slight delay in the table sort. To cater for this I want to provide some feedback to the...
1
1593
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 that reproduces the issue: function PrintNode(node) { AddText("<b>"+node.nodeName+"</b>="+node.nodeValue+" ("+node.childNodes.length+"...
5
4921
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 there are, it crashes. There are currently 6 columns, and I only want 4. How do I remove the last two (discount and date)? Here is a link:...
1
7856
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8137
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6509
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5651
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5335
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3773
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3793
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2270
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1099
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.