0

input parameter substitution in url - not simply substituting

Hi,

I've been looking into YQL for a private project of mine and try to define an open table that is queried like this:

CODE
use "http://github.com/vicmortelmans/yql-tables/raw/master/bible/nl.willibrord.xml" as nl.willibrord;
select * from nl.willibrord where book='John' and chapter=3 and passage=16


The open table should fetch html data from this URL



So I specify the <url> as

CODE
http://www.bijbel.net/wb/?{book}+{chapter},{passage}


The variables in '{}' should be replaced by the 'where'-criteria of the query.

But if I query the table, the console tells me that this URL is called:

CODE
<url execution-time="9" proxy="DEFAULT"><![CDATA[http://www.bijbel.net/wb/?+,&John+3,16]]></url>


Notice the extra occurrence of the '+' and ',' in the GET-section...

Why is YQL doing this ?? I've been thinking this behaviour is triggered by the uritemplate feature, but can't figure out how...

Complete open table definition:

CODE
<?xml version="1.0" encoding="UTF-8"?>
<table xmlns="http://query.yahooapis.com/v1/schema/table.xsd">
<meta>
<author>Vic Mortelmans</author>
<description>The table contains the complete bible. Each passage is a record, identified by it's citation reference.</description>
<sampleQuery>select * from nl.willibrord where book='John' and chapter=3 and passage=16 </sampleQuery>
<documentationURL>http://docs.google.com/View?id=ddq89pzk_155t6rwmkhp</documentationURL>
</meta>
<bindings>
<select produces="XML" itemPath="*">
<urls>
<url>http://www.bijbel.net/wb/?{book}+{chapter},{passage}</url>
</urls>
<inputs>
<key id="book" type="xs:string" paramType="path" required="true"/>
<key id="chapter" type="xs:integer" paramType="path" required="true"/>
<key id="passage" type="xs:integer" paramType="path" required="true"/>
</inputs>
<execute><![CDATA[
var page = y.query("select * from html where url=@url and xpath='//font[@color=\"red\"]'",{url:request.url});
response.object = page.results;
]]></execute>
</select>
</bindings>
</table>

(http://github.com/vicmortelmans/yql-tables/raw/master/bible/nl.willibrord.xml)

Thanks !!
Vic

by
1 Reply
  • The problem here is that + in a URI is a space character. Instead I think you should use %20 like this:

    select * from uritemplate where template ='http://www.bijbel.net/wb/?{book}%20{chapter},{passage}' and book = 'John' and chapter=3 and passage=16

    Sam
    0

Recent Posts

in YQL