Solved

Vbscript not displaying links

Posted on 2011-02-16
11
837 Views
Last Modified: 2012-08-13
Hi!

The below listed vbscript on an ASP page is not giving me any errors, but it also is not displaying the links from our XML page using the XSL page to render it. Any specific code corrections would be greatly appreciated.

<%
      Dim NewXML, re, oXmlSrc, oXml, oNode, oXslSrc, oXsl, oXslTemplate
     
      ' If you're using an XSLTemplate and XSLProcessor object,
      '   you have to use the FreeThreaded versions of DOMDocument
      Set oXmlSrc = Server.CreateObject("MSXML2.FreeThreadedDOMDocument.4.0")
      Call oXmlSrc.setProperty("ServerHTTPRequest", True)            
      oXmlSrc.async = False
     
      Set oXslSrc = Server.CreateObject("MSXML2.FreeThreadedDOMDocument.4.0")
      Call oXslSrc.setProperty("ServerHTTPRequest", True)            
      oXslSrc.async = False
     
      Set oXslTemplate = Server.CreateObject("MSXML2.XSLTemplate.4.0")

      ' If I haven't posted the form first, then load my unaltered XML.
      ' If I'm posting info to resort or edit, then build my XML from that.
     
    ' On Error Resume Next  'debugging code if table does not appear uncomment this line

      'xmlResponse = Replace(xmlResponse, "<?xml version=""1.0""?>", "<?xml version=""1.0"" encoding=""utf-8""?>")

            'Call oXmlSrc.loadXML (xmlResponse)      
            Call oXmlSrc.load (Server.MapPath("sitemap.xml"))
          'Response.Write "<xmp>" & oXmlSrc.xml & "</xmp>"    'debugging code
          'newXML = oXmlSrc.xml
        'Set re = new regexp
        're.pattern = " xmlns.+?>"
        'newXML = re.replace(newXML,">")
        'Call oXmlSrc.loadXML(newXML)
  if oXslsrc.load (Server.MapPath("sitemap.xsl")) then
     Set oXslTemplate.stylesheet = oXslsrc
     Set oXslProcessor = oXslTemplate.createProcessor()
     oXslProcessor.input = oXmlsrc
     Response.Write oXmlsrc
    else
       Response.Write "Could Not Retrieve SiteMap.xsl stylesheet"
end if %>
0
Comment
Question by:TrueBlue
  • 6
  • 5
11 Comments
 
LVL 65

Expert Comment

by:RobSampson
Comment Utility
It might be because you're loading the XML file twice.  Comment out this line:
            Call oXmlSrc.load (Server.MapPath("sitemap.xml"))

because this line
  If oXslsrc.load (Server.MapPath("sitemap.xsl")) Then

will also load it.

Also, do you get any output if you change this:
  If oXslsrc.load (Server.MapPath("sitemap.xsl")) Then

to this
  Response.Write "Loading xml...<BR>"
  If oXslsrc.load (Server.MapPath("sitemap.xsl")) Then
     Response.Write "XML loaded...<BR>"


Regards,

Rob.
0
 

Author Comment

by:TrueBlue
Comment Utility
Rob,

I did as you suggested and it returned the following ...

Loading xml...
XML loaded...
Response object error 'ASP 0185 : 80020003'
Missing Default Property
/sitemap.asp, line 0
A default property was not found for the object.

Any ideas?
TIA
0
 
LVL 65

Expert Comment

by:RobSampson
Comment Utility
Should this line:
     Response.Write oXmlsrc

be this:
     Response.Write oXmlsrc.xml

It looks like the Response object error that you are getting is due to this:
     Response.Write oXmlsrc

and oXmlsrc is an object, so you can't output it, you need to reference one of its (string) properties.

Rob.
0
 

Author Comment

by:TrueBlue
Comment Utility
Rob,

That fixed the error.
Now it displays the following...
Loading xml...
XML loaded...

But, no links are displayed.
Any other ideas?

TIA
0
 
LVL 65

Expert Comment

by:RobSampson
Comment Utility
Does it display any xml from the sitemap.xml?

What is the format of your xml? We might need to read the xml nodes to be able to output them.

Rob.
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:TrueBlue
Comment Utility
Rob,
The XML looks fine when I look at the page using IE.

Here is the XML:
http://www.topsecurityinc.com/sitemap.xml
Here is the XSL:
http://www.topsecurityinc.com/sitemap.xsl

Any suggestions would be appreciated.
0
 
LVL 65

Expert Comment

by:RobSampson
Comment Utility
OK, I'll see if I can run some tests with it.  So do you want the entire xml to be output to the page?

Rob.
0
 

Author Comment

by:TrueBlue
Comment Utility
Rob,

I am basically trying to make a people friendly sitemap using the XML file.

TIA
0
 
LVL 65

Expert Comment

by:RobSampson
Comment Utility
Hi, isn't it is possible to point your XML file to use the XSL directly, by adding something like this:
<?xml-stylesheet type="text/xsl" href="sitemap.xsl"?>

And then display the xml in the browser?

Regards,

Rob.
0
 

Author Comment

by:TrueBlue
Comment Utility
Rob,

Wouldn't this method negate the ability of search engines being able to properly read the sitemap for indexing purposed?

TIA
0
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
Comment Utility
It would if you had it processed client side.  It looks like if you process it server side, then Google would index the processed page.

See if this gives you any more information:
http://msdn.microsoft.com/en-us/magazine/bb984985.aspx

Regards,

Rob.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

762 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now