Ask a questionAsk a question
 

AnswerMultimap Web Services help

  • Monday, September 28, 2009 4:03 PMinsert_funny_username_here Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code

    Following the Multimap API V1.2 Web Services Documentation - Searching documentation but having some issues.

    I have to use classic asp. I am grabbing the xml file, and xsl to output it.

    EXAMPLE OF MY ASP CODE:

    		strURL=** my url with api key ***
    		set oXMLhttp = Server.CreateObject("Microsoft.XMLHTTP")
    			oXMLhttp.open "GET", strURL, False
    			oXMLhttp.send
    		set oXMLsource = Server.CreateObject("Microsoft.XMLDOM")
    			oXMLsource.async = false
    			oXMLsource.loadxml(oXMLhttp.responseText)			
    		set oXSL = Server.CreateObject("Microsoft.XMLDOM")
    			oXSL.async = false
    			oXSL.load(server.mappath("xsl/multimap.xsl"))
    	    	ResultsFeed = oXMLsource.transformNode(oXSL)		
    		Response.Write(ResultsFeed)

    EXAMPLE OF MY XSL CODE:

    <?xml version="1.0" encoding="iso-8859-1" ?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="html" omit-xml-declaration="yes"/>
    
    <xsl:template match="/">
    	<table summary="api test" cellspacing="0">
    		<thead>
    			<th scope="col">Distance</th>
    		</thead>
    		<tbody>
    			<xsl:apply-templates select="//Record"></xsl:apply-templates>
    		</tbody>
    	</table>
    </xsl:template>
    
    
    <xsl:template match="Record">
    	<tr>
    		<td>
    			<xsl:value-of disable-output-escaping="yes" select="Distance/Miles"/>mi 
    			(<xsl:value-of disable-output-escaping="yes" select="Distance/KM"/>km)
    		</td>
    	</tr>
    </xsl:template>
    
    </xsl:stylesheet>
    
    I have been able to get this code to work if i remove xmlns="http://clients.multimap.com/API" from the RecordSets node. Otherwise it returns nothing. I am sure it is a bad idea to remove this.

    What am i doing wrong? I am sure I am doing something wrong.
    •  

Answers

  • Friday, October 09, 2009 2:26 PMJohn-SheridanMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     AnswerHas Code
    i'm stripping it out before i load it. something like:
    strResponse=oXMLhttp.responseText

    //regex code to strip out Route node so it becomes <Route>

    oXMLsource.loadxml(strResponse)
    This works fine. Is it ok to strip out the Route node? All i am doing is outputting data from it.
    Looks like you are not denoting the use of "mm" to refer all Multimap elements.  You need to prefix/qualify all Multimap elements in the stylesheet with ‘mm’.  The top <xsl:stylesheet> element should denote the reference for "mm", for example - xmlns:mm='http://clients.multimap.com/API' .

    Please reference the information at the following link, this is the recommended and correct  solution:-
    http://lists.xml.org/archives/xml-dev/200105/msg00284.html


    The following is an example of what the stylesheet should contain:-
      <?xml version="1.0" encoding="iso-8859-1" ?>
    - <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:mm="http://clients.multimap.com/API">
      <xsl:output method="html" omit-xml-declaration="yes" />
    - <xsl:template match="/">
    - <table summary="api test" cellspacing="0">
    - <thead>
      <th scope="col">Distance</th>
      </thead>
    - <tbody>
      <xsl:apply-templates select="//mm:Record" />
      </tbody>
      </table>
      </xsl:template>
    - <xsl:template match="mm:Record">
    - <tr>
    - <td>
      <xsl:value-of disable-output-escaping="yes" select="mm:Distance/mm:Miles" />
      mi (
      <xsl:value-of disable-output-escaping="yes" select="mm:Distance/mm:KM" />
      km)
      </td>
      </tr>
      </xsl:template>
      </xsl:stylesheet>



    We do not expect any issues if you would like to remove the namespace from the response XML so that you do not have to add the ‘mm’ prefix throughout the XSL, as long as there’s no conflict between the names of Multimap elements and the generic www.w3c.org elements.  Users - Please use this method at your own risk.


All Replies

  • Tuesday, October 06, 2009 4:23 PMJohn-SheridanMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi
    We are not sure of the issue here, the RecordSets node and "xmlns="http://clients.multimap.com/API" is normally returned in the XML after the URL request, so how/where are you removing the xmlns attribute?

    Thanks, John.




  • Thursday, October 08, 2009 8:31 AMinsert_funny_username_here Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code
    i'm stripping it out before i load it. something like:
    strResponse=oXMLhttp.responseText
    
    //regex code to strip out Route node so it becomes <Route>
    
    oXMLsource.loadxml(strResponse)
    This works fine. Is it ok to strip out the Route node? All i am doing is outputting data from it.
  • Friday, October 09, 2009 2:26 PMJohn-SheridanMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     AnswerHas Code
    i'm stripping it out before i load it. something like:
    strResponse=oXMLhttp.responseText

    //regex code to strip out Route node so it becomes <Route>

    oXMLsource.loadxml(strResponse)
    This works fine. Is it ok to strip out the Route node? All i am doing is outputting data from it.
    Looks like you are not denoting the use of "mm" to refer all Multimap elements.  You need to prefix/qualify all Multimap elements in the stylesheet with ‘mm’.  The top <xsl:stylesheet> element should denote the reference for "mm", for example - xmlns:mm='http://clients.multimap.com/API' .

    Please reference the information at the following link, this is the recommended and correct  solution:-
    http://lists.xml.org/archives/xml-dev/200105/msg00284.html


    The following is an example of what the stylesheet should contain:-
      <?xml version="1.0" encoding="iso-8859-1" ?>
    - <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:mm="http://clients.multimap.com/API">
      <xsl:output method="html" omit-xml-declaration="yes" />
    - <xsl:template match="/">
    - <table summary="api test" cellspacing="0">
    - <thead>
      <th scope="col">Distance</th>
      </thead>
    - <tbody>
      <xsl:apply-templates select="//mm:Record" />
      </tbody>
      </table>
      </xsl:template>
    - <xsl:template match="mm:Record">
    - <tr>
    - <td>
      <xsl:value-of disable-output-escaping="yes" select="mm:Distance/mm:Miles" />
      mi (
      <xsl:value-of disable-output-escaping="yes" select="mm:Distance/mm:KM" />
      km)
      </td>
      </tr>
      </xsl:template>
      </xsl:stylesheet>



    We do not expect any issues if you would like to remove the namespace from the response XML so that you do not have to add the ‘mm’ prefix throughout the XSL, as long as there’s no conflict between the names of Multimap elements and the generic www.w3c.org elements.  Users - Please use this method at your own risk.