URL Escape Error in Template Markup

nzblue_fish
nzblue_fish's picture
User offline. Last seen 2 weeks 4 days ago. Offline
Joined: 09/30/2009
Points: 1165

Happy New Year mashers,

I'm looking forward to a mashing good new year in 2010!

First problem for the year then.

I'm trying to use the Google GeoCoding service through a directinvoke call, but am getting an error when running the mashup that tries to use a template to build a dynamic call to the webservice. Here's the error I'm getting:


  XPST0003: XQuery syntax error in #...q={$address}&output=xml</root>#:
    No closing ';' found for entity or character reference

Can anyone offer a suggestion on what's causing this error: Here's the emml snippet:

        <template expr="http://maps.google.com/maps/geo?q={$address}&amp;output=xml" outputvariable="geoCodeAPI" />
        <directinvoke endpoint="$geoCodeAPI" outputvariable="geocode"
            method="GET" responsecode="httpRC" responseheader="httpResponse"  />

I've found another way to do the same thing using assign and an Xpath concat, but it's not as elegant as a template especially when that seems to be the whole purpose of the template markup. Perhaps it's not supposed to work :)

Cheers,

Innes

 

 

 

 

0
Your rating: None
smitchell
smitchell's picture
User offline. Last seen 17 hours 2 min ago. Offline
Joined: 08/29/2008
Points: 34

I have a feeling that the issue is that you need to double-escape the & character in the query part of your template. More than likely the template is being parsed once, resolving &amp; to & and then being parsed again -- and the parser would expect ; to end the entity definition. Which is what the error is saying.

Try this:

<template expr="http://maps.google.com/maps/geo?q={$address}&amp;amp;output=xml" outputvariable="geoCodeAPI" />

 

Sara, technical writer/jackbe

 

nzblue_fish
nzblue_fish's picture
User offline. Last seen 2 weeks 4 days ago. Offline
Joined: 09/30/2009
Points: 1165

Hi Sara,

Brilliant ... yes your hunch was right. By double escaping the & to &amp;amp; I got the template to resolve without an error.

Thanks for that.

Cheers, Innes