nanacz
asked on
XSL help pls.....
I have this xsl file which does some cleaning, ordering, and adds some required elements for tracking parent/child relationships. This is the first time i'm using xml n xsl and below is my code:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn.schemas-m icrosoft-c om:xslt" xmlns:a="DAV:" xmlns:d='urn:schemas-micro soft-com:o ffice:offi ce' xmlns:user="http://www.compaq.com/userfunctoins" version="1.0">
<msxsl:script language="JavaScript" implements-prefix="user">
var ii = 0;
function folderh(){
ii += 1;
return (ii);
}
function flevel(a){
var cnt = 0;
var StrIndex = a.match(/ \ / / g);
cnt = StrIndex.length-4;
return(cnt);
}
</msxsl:script>
<xsl:output method="xml" omit-xml-declaration="yes" indent="no" />
<xsl:template match="/">
<content>
<xsl:apply-templates select="a:multistatus/a:re sponse/a:p ropstat[a: status='HT TP/1.1 200 OK']">
<xsl:sort select="a:prop/a:href"/>
</xsl:apply-templates>
</content>
</xsl:template>
<xsl:template match="a:propstat">
<xsl:for-each select="a:prop">
<xsl:variable name = "status">
<xsl:value-of select= "a:status"/>
</xsl:variable>
<xsl:element name="folder">
<xsl:attribute name="id">
<xsl:value-of select="a.uid"/>
</xsl:attribute>
<foldername>
<xsl:variable name="target">
<xsl:value-of select = "a:href"/>
</xsl:variable>
<xsl:value-of select="substring-after ($target, 'Content/')" />
</foldername>
<posit>
<xsl:value-of select="user:folderh()"/>
</posit>
<filetype>
<xsl:variable name="filetype">
<xsl:value-of select="a:displayname"/>
</xsl:variable>
<xsl:value-of select="substring-after ($filetype, '.')"/>
</filetype>
<displayname><xsl:value-of select="a:displayname"/></ displaynam e>
<href><xsl:value-of select="a:href"/></href>
<isfolder><xsl:value-of select="a:isfolder"/></isf older>
<iscollection><xsl:value-o f select="a:iscollection"/>< /iscollect ion>
<haschildren><xsl:value-of select="a:haschildren"/></ haschildre n>
<level>
<xsl:value-of select="user:flevel(concat (a:parentn ame, ' '))"/>
</level>
<title><xsl:value-of select="d:title"/></title>
<author><xsl:value-of select="d:author"/></autho r>
<parentname><xsl:value-of select="a:parentname"/></p arentname>
<getlastmodified><xsl:valu e-of select="a:getlastmodified" /></getlas tmodified>
</xsl:element>
</xsl:for-each>
</xsl:template>
<xsl:template match="a:href">
</xsl:template>
</xsl:stylesheet>
The error is:
Script Execution Error: Namespace 'http://www.compaq.com/userfunctions' does not contain any functions.
Question: What do i do for this error?? is there any other url which has the same functions as the above url?? what can i do??
Thanks.
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn.schemas-m
<msxsl:script language="JavaScript" implements-prefix="user">
var ii = 0;
function folderh(){
ii += 1;
return (ii);
}
function flevel(a){
var cnt = 0;
var StrIndex = a.match(/ \ / / g);
cnt = StrIndex.length-4;
return(cnt);
}
</msxsl:script>
<xsl:output method="xml" omit-xml-declaration="yes"
<xsl:template match="/">
<content>
<xsl:apply-templates select="a:multistatus/a:re
<xsl:sort select="a:prop/a:href"/>
</xsl:apply-templates>
</content>
</xsl:template>
<xsl:template match="a:propstat">
<xsl:for-each select="a:prop">
<xsl:variable name = "status">
<xsl:value-of select= "a:status"/>
</xsl:variable>
<xsl:element name="folder">
<xsl:attribute name="id">
<xsl:value-of select="a.uid"/>
</xsl:attribute>
<foldername>
<xsl:variable name="target">
<xsl:value-of select = "a:href"/>
</xsl:variable>
<xsl:value-of select="substring-after ($target, 'Content/')" />
</foldername>
<posit>
<xsl:value-of select="user:folderh()"/>
</posit>
<filetype>
<xsl:variable name="filetype">
<xsl:value-of select="a:displayname"/>
</xsl:variable>
<xsl:value-of select="substring-after ($filetype, '.')"/>
</filetype>
<displayname><xsl:value-of
<href><xsl:value-of select="a:href"/></href>
<isfolder><xsl:value-of select="a:isfolder"/></isf
<iscollection><xsl:value-o
<haschildren><xsl:value-of
<level>
<xsl:value-of select="user:flevel(concat
</level>
<title><xsl:value-of select="d:title"/></title>
<author><xsl:value-of select="d:author"/></autho
<parentname><xsl:value-of select="a:parentname"/></p
<getlastmodified><xsl:valu
</xsl:element>
</xsl:for-each>
</xsl:template>
<xsl:template match="a:href">
</xsl:template>
</xsl:stylesheet>
The error is:
Script Execution Error: Namespace 'http://www.compaq.com/userfunctions' does not contain any functions.
Question: What do i do for this error?? is there any other url which has the same functions as the above url?? what can i do??
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This question has been classified abandoned. I will make a recommendation to the
moderators on its resolution in a week or two. I appreciate any comments
that would help me to make a recommendation.
<note>
Unless it is clear to me that the question has been answered I will recommend delete. It is possible that a Grade less than A will be given if no expert makes a case for an A grade. It is assumed that any participant not responding to this request is no longer interested in its final disposition.
</note>
If the user does not know how to close the question, the options are here:
https://www.experts-exchange.com/help/closing.jsp
Cd&
moderators on its resolution in a week or two. I appreciate any comments
that would help me to make a recommendation.
<note>
Unless it is clear to me that the question has been answered I will recommend delete. It is possible that a Grade less than A will be given if no expert makes a case for an A grade. It is assumed that any participant not responding to this request is no longer interested in its final disposition.
</note>
If the user does not know how to close the question, the options are here:
https://www.experts-exchange.com/help/closing.jsp
Cd&
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Accept sybe's comment as answer
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
Programming_Gal
EE Cleanup Volunteer
I will leave a recommendation in the Cleanup topic area that this question is:
Accept sybe's comment as answer
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
Programming_Gal
EE Cleanup Volunteer
ASKER
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-m
<msxsl:script language="JavaScript" implements-prefix="user">
var ii = 0;
function folderh(){
ii += 1;
return (ii);
}
function flevel(a){
var cnt = 0;
var StrIndex = a.match(/\//g);
cnt = StrIndex.length-4;
return (cnt);
}
</msxsl:script>
<xsl:output method="xml" omit-xml-declaration="yes"
<xsl:template match="/">
<content>
<xsl:apply-templates select="a:multistatus/a:re
<xsl:sort select="a:prop/a:href"/>
</xsl:apply-templates>
</content>
</xsl:template>
<xsl:template match="a:propstat">
<xsl:for-each select="a:prop">
<xsl:variable name = "status">
<xsl:value-of select= "a:status"/>
</xsl:variable>
<xsl:element name="folder">
<xsl:attribute name="id">
<xsl:value-of select="a.uid"/>
</xsl:attribute>
<foldername>
<xsl:variable name="target">
<xsl:value-of select = "a:href"/>
</xsl:variable>
<xsl:value-of select="substring-after ($target, 'Content/')" />
</foldername>
<posit>
<xsl:value-of select="user:folderh()"/>
</posit>
<filetype>
<xsl:variable name="filetype">
<xsl:value-of select="a:displayname"/>
</xsl:variable>
<xsl:value-of select="substring-after ($filetype, '.')"/>
</filetype>
<displayname><xsl:value-of
<href><xsl:value-of select="a:href"/></href>
<isfolder><xsl:value-of select="a:isfolder"/></isf
<iscollection><xsl:value-o
<haschildren><xsl:value-of
<level>
<xsl:value-of select="user:flevel(concat
</level>
<title><xsl:value-of select="d:title"/></title>
<author><xsl:value-of select="d:author"/></autho
<parentname><xsl:value-of select="a:parentname"/></p
<getlastmodified><xsl:valu
</xsl:element>
</xsl:for-each>
</xsl:template>
<xsl:template match="a:href">
</xsl:template>
</xsl:stylesheet>
My error is Script Execution Error: Microsoft JScript runtime error Object required line = 11, col = 1 (line is offset from the start of the script block). Error returned from property or method call.
I cant solve this error, this code is from a book, so i guess there shouldnt be any mistakes. There is another file which load this xsl file and another xsl file which converts the xml to hmtl.
if needed, below is the second xsl file:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="uri:xsl">
<xsl:script><![CDATA[
function addheading(){
var heading = " ";
heading +=" function makedisplayed(a, b, c) \n";
heading +=" { /n";
heading +=" if (a.style.display=='none'){
heading +=" a.style.display=' ';\n";
heading +=" b.style.display=' ';\n";
heading +=" c.style.display='none';\n"
heading +=" }\n";
heading +=" else {\n";
heading +=" a.style.display='none';\n"
heading +=" b.style.display='none';\n"
heading +=" c.style.display=' ';\n";
heading +=" }\n";
heading +=" }\n";
return heading;
}
]]></xsl:script>
<xsl:template match="/">
<HEAD>
<SCRIPT LANGUAGE='JavaScript'>
<xsl:eval>addheading()</xs
</SCRIPT>
</HEAD>
<TABLE>
<xsl:for-each select="content">
<xsl:apply-templates match="folder" />
</xsl:for-each>
</TABLE>
</xsl:template>
<xsl:template match="folder">
<xsl:eval no-entities="true">indentC
</xsl:template>
<xsl:script><![CDATA[
var IndexOffSet = 0;
function indentCategory(e){
if(e){
var href = e.selectSingleNode("href")
var dname = e.selectSingleNode("displa
var dfolder = e.selectSingleNode("isfold
var fileicon = e.selectSingleNode("filety
var currLevel = e.selectSingleNode("level"
var hasChildren = e.selectSingleNode("hasChi
var hrefText = " ";
var dnameText = " ";
var dfolderText = " ";
var dfolderText = dfolder.text;
var id = e.selectSingleNode("@id").
if (fileicon.length > 1){
fileicon = "DocTypeIcons\\" + fileicon + "16.gif";
}else{
fileicon ="DocTypeIcons\\DET16.gif"
}
var pos = e.selectSingleNode("posit"
pos = Math.abs(pos)+1;
var m = e.parentNode.childNodes.le
if (pos <= m){
eval('var g = e.parentNode.selectSingleN
var isFolder = g.childNodes.item(5).text;
var nexthasChildren = g.childNodes.item(7).text;
var nextLevel = g.childNodes.item(8).text;
}
else{
var isFolder = 1;
var hasChildren = 0;
}
if (href){
hrefText = "href=\"" + href.text + "\" ";
}
if (dname){
dnameText = dname.text;
}
var cat = e.selectSingleNode("displa
if (cat){
}else{
return hrefText + " " + dnameText;
}
var catTxt = cat.text;
var spaces = " ";
var retStr2 = " ";
var cnt = currLevel;
var ahref = " ";
for(var i=0; i<currLevel-1; i++){
spaces += " ";
}
for(var j=1; j<cnt+1; j++){
var test = " "; //" hasChildren="+hasChildren+
if (cnt == j){
if (1 == dfolderText){
if (1 == hasChildren){
ahref = "JavaScript:makedisplayed(
retStr2 += "<TR><TD> </TD>\n" +
"<TD width=\"100%\" valign=\"top\" align=\"left\">" + spaces + "<A href = ' "+ahref +" '><IMG border=0 src=\"blueplus.jpg\" id='p"+id+"'></IMG><IMG border=0 src=\"blueminus.jpg\" style=display:'none' id='m"+id+"'></IMG></A>" + " " + dnameText +test+"</TD></TR>";
retStr2 += "<TR style=display:'none' id='tr"+ id +"'><TD> </TD><TD><TA
}else{
retStr2 += "<TR><TD> </TD>\n" +
"<TD width=\"100%\" valign=\"top\" align=\"left\">" + spaces + "<IMG border=0 src=\"empty.gif\" id='p"+id+" '></IMG>" +
" "+ dnameText +test+"</TD></TR>";
}
}else{
retStr2 += "<TR><TD> </TD>\n" +
"<TD width=\"100%\" valign=\"top\" align=\"left\">" + spaces + "<IMG align = 'center' border=0 src=' " + fileicon +" '/>" + " " +"<A " + hrefText + ">"+ dnameText+test+"</A></TD><
if (1==isFolder && currLevel > 0 && 0==dfolderText){
retStr2 += "</TD></TABLE></TR>";
}
if ((cnt>2) && (1==isFolder) && (currLevel-1>nextLevel)){
retStr2 += "</TD></TABLE></TR>";
}
if ((cnt>2) && (0==isFolder) && (currLevel>nextLevel)){
retStr2 += "</TD></TABLE></TR>";
}
}
}
}
if ((1==isFolder) && (1==dfolderText) && (cnt>1) && (currLevel > nextLevel))
{
retStr2 += "</TD></TABLE></TR>";
}
return retStr2;
}else{
return " ";
}
}
]]></xsl:script>
</xsl:stylesheet>