Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

XSL help pls.....

Posted on 2003-03-10
4
Medium Priority
?
387 Views
Last Modified: 2012-06-21
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-microsoft-com:xslt" xmlns:a="DAV:" xmlns:d='urn:schemas-microsoft-com:office:office' 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:response/a:propstat[a:status='HTTP/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"/></displayname>
     <href><xsl:value-of select="a:href"/></href>
     <isfolder><xsl:value-of select="a:isfolder"/></isfolder>
     <iscollection><xsl:value-of select="a:iscollection"/></iscollection>
     <haschildren><xsl:value-of select="a:haschildren"/></haschildren>
     <level>
          <xsl:value-of select="user:flevel(concat(a:parentname, ' '))"/>
     </level>
     <title><xsl:value-of select="d:title"/></title>
     <author><xsl:value-of select="d:author"/></author>
     <parentname><xsl:value-of select="a:parentname"/></parentname>
     <getlastmodified><xsl:value-of select="a:getlastmodified"/></getlastmodified>
     </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.
0
Comment
Question by:nanacz
4 Comments
 
LVL 28

Accepted Solution

by:
sybe earned 80 total points
ID: 8110073
change

xmlns:user="http://www.compaq.com/userfunctoins"

to

xmlns:user="urn:my-namespace"


0
 

Author Comment

by:nanacz
ID: 8117533
This is my updated code:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:a="DAV:" xmlns:d='urn:schemas-microsoft-com:office:office' xmlns:user="http://www.compaq.com/userfunctions" 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:response/a:propstat[a:status='HTTP/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"/></displayname>
      <href><xsl:value-of select="a:href"/></href>
      <isfolder><xsl:value-of select="a:isfolder"/></isfolder>
      <iscollection><xsl:value-of select="a:iscollection"/></iscollection>
      <haschildren><xsl:value-of select="a:haschildren"/></haschildren>
      <level>
            <xsl:value-of select="user:flevel(concat(a:parentname,' ' ))"/>
      </level>
      <title><xsl:value-of select="d:title"/></title>
      <author><xsl:value-of select="d:author"/></author>
      <parentname><xsl:value-of select="a:parentname"/></parentname>
      <getlastmodified><xsl:value-of select="a:getlastmodified"/></getlastmodified>
      </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'){ \n";
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()</xsl:eval>
      </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">indentCategory(this)</xsl:eval>
      </xsl:template>

<xsl:script><![CDATA[
var IndexOffSet = 0;
function indentCategory(e){
if(e){
      var href = e.selectSingleNode("href");
      var dname = e.selectSingleNode("displayname");
      var dfolder = e.selectSingleNode("isfolder");

      var fileicon = e.selectSingleNode("filetype").text;
      var currLevel = e.selectSingleNode("level").text;
      var hasChildren = e.selectSingleNode("hasChildren").text;
      var hrefText = " ";
      var dnameText = " ";
      var dfolderText = " ";
      var dfolderText = dfolder.text;

      var id = e.selectSingleNode("@id").text;
      if (fileicon.length > 1){
            fileicon = "DocTypeIcons\\" + fileicon + "16.gif";
      }else{
            fileicon ="DocTypeIcons\\DET16.gif";
      }

      var pos = e.selectSingleNode("posit").text;
      pos = Math.abs(pos)+1;
      var m = e.parentNode.childNodes.length
      if (pos <= m){
            eval('var g = e.parentNode.selectSingleNode(\"/content/folder[posit=" + pos +"]\");');
            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("displayname");
      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 += "&nbsp;&nbsp;";
      }

      for(var j=1; j<cnt+1; j++){
            var test = " "; //" hasChildren="+hasChildren+" isFolder"+isFolder;

            if (cnt == j){
                  if (1 == dfolderText){
                        if (1 == hasChildren){
                              ahref = "JavaScript:makedisplayed(document.all.item(\"tr"+id+"\"), document.all.item(\"m"+id+"\"), document.all.item(\"p"+id+"\"))";
                              retStr2 += "<TR><TD>&nbsp;</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>" + "&nbsp;" + dnameText +test+"</TD></TR>";
                              retStr2 += "<TR style=display:'none' id='tr"+ id +"'><TD>&nbsp;</TD><TD><TABLE>";
                        }else{
                              retStr2 += "<TR><TD>&nbsp;</TD>\n" +
                              "<TD width=\"100%\" valign=\"top\" align=\"left\">" + spaces + "<IMG border=0 src=\"empty.gif\" id='p"+id+" '></IMG>" +
                                    "&nbsp;"+ dnameText +test+"</TD></TR>";
                        }
                  }else{
                        retStr2 += "<TR><TD>&nbsp;</TD>\n" +
                        "<TD width=\"100%\" valign=\"top\" align=\"left\">" + spaces + "<IMG align = 'center' border=0 src=' " + fileicon +" '/>" + "&nbsp;&nbsp;" +"<A " + hrefText + ">"+ dnameText+test+"</A></TD></TR>";
                        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>
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 9115227
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:
http://www.experts-exchange.com/help/closing.jsp


Cd&

0
 
LVL 6

Expert Comment

by:Programming_Gal
ID: 9647920
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
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question