3
我對SWP非常陌生,我對將從URL獲取的參數傳遞到SPARQL查詢以使其更加動態化非常困惑。這是SWP文件我的工作:如何將參數傳遞到SPARQL Web頁面查詢
<!-- Navigate to http://localhost:8083/tbl/tutorial.swp?test=Mate in a web browser -->
<ui:setContext
xmlns:kennedys="http://topbraid.org/examples/kennedys#"
ui:queryGraph="<http://topbraid.org/examples/kennedys>"
let:query = "{= ui:param('test', xsd:string)}"
let:helloThere = "{= xsd:string('hello')}"
>
<h1>G'day, {= ?helloThere}!</h1>
<table>
<thead>
<tr>
<th data-field="propertyID">
Property ID
</th>
<th data-field="property">
Property
</th>
<th data-field="valueID">
Value ID
</th>
<th data-field="value">
Value
</th>
</tr>
</thead>
<ui:forEach ui:resultSet="{#
SELECT *
WHERE {
<http://topbraid.org/examples/kennedys#AlfredTucker> ?property ?value .
}
}">
<tr>
<td>{= xsd:string(?property) }</td>
<td>{= ui:label(?property) }</td>
<td>{= xsd:string(?value) }</td>
<td>{= ui:label(?value) }</td>
</tr>
</ui:forEach>
</table>
</ui:setContext>
這一切工作正常和花花公子,但我想在一個變量傳遞到SPARQL查詢。我試過這樣的事情:
<ui:forEach ui:resultSet="{#
SELECT *
WHERE {
<http://topbraid.org/examples/kennedys#" + {= ?query} + "> ?property ?value .
}
}">
<tr>
<td>{= xsd:string(?property) }</td>
<td>{= ui:label(?property) }</td>
<td>{= xsd:string(?value) }</td>
<td>{= ui:label(?value) }</td>
</tr>
</ui:forEach>
不幸的是,這是行不通的。我想知道如何將變量傳遞到SPARQL查詢中。
「這不起作用」是有點不明確的。第二種情況下你得到了什麼結果? –
Topbraid支持只是回覆並提供給我一個解決方案!感謝您的幫助 –
感謝您發佈解決方案!不要忘記[接受它](http://meta.stackexchange.com/q/5234/225437)! (在Stack Overflow上接受你自己的答案是完全可以接受的;畢竟,你最清楚哪個答案適合你!) –