T
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"> </TH>
<TH style="WIDTH: 400px" align="middle">
<NOBR><A href="javascript:sort(SortTitleXSL.XMLDocument)">Title</A></NOBR>
</TH>
<TH style="WIDTH: 50px" align="middle">
<NOBR><A href="javascript:sort(SortDateXSL.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_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.transformNode
(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----
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"> </TH>
<TH style="WIDTH: 400px" align="middle">
<NOBR><A href="javascript:sort(SortTitleXSL.XMLDocument)">Title</A></NOBR>
</TH>
<TH style="WIDTH: 50px" align="middle">
<NOBR><A href="javascript:sort(SortDateXSL.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_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.transformNode
(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----