TopBraid Composer Maestro Edition を使用して SWP (SPARQL Web ページ) を学習しており、SWP ファイルを作成できます。この SWP ファイルは、SPARQL を使用してサンプル データセットにクエリを実行し、結果を HTML として返します。これは、私のプロジェクトにあるコード スニペットです。
<!-- 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:test="{= ui:param('test', xsd:string) }">
<h1>G'day, {= ?test }!</h1>
<ul>
<ui:forEach ui:resultSet="{#
SELECT *
WHERE {
<http://topbraid.org/examples/kennedys#AlfredTucker> ?property ?value .
}
}">
<li>{= ui:label(?value) }</li>
</ui:forEach>
</ul>
</ui:setContext>
この SWP スニペットは魔法のように機能し、必要なものが表示されます。HTML ではなく XML を取得するにはどうすればよいでしょうか。
編集:
返される HTML は次のとおりです。
<!DOCTYPE html>
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<data>
<entry>
<property>year of birth</property>
<value>1967</value>
</entry>
<entry>
<property>first name</property>
<value>Alfred</value>
</entry>
<entry>
<property>has gender</property>
<value>male</value>
</entry>
<entry>
<property>last name</property>
<value>Tucker</value>
</entry>
<entry>
<property>name</property>
<value>Alfred Tucker</value>
</entry>
<entry>
<property>has spouse</property>
<value>Kym Smith</value>
</entry>
<entry>
<property>http://www.w3.org/1999/02/22-rdf-syntax-ns#type</property>
<value>Person</value>
</entry>
</data>
</body>
</html>
その代わりに、これを xml ヘッダーと共に返すようにしたいだけです。
<data>
<entry>
<property>year of birth</property>
<value>1967</value>
</entry>
<entry>
<property>first name</property>
<value>Alfred</value>
</entry>
<entry>
<property>has gender</property>
<value>male</value>
</entry>
<entry>
<property>last name</property>
<value>Tucker</value>
</entry>
<entry>
<property>name</property>
<value>Alfred Tucker</value>
</entry>
<entry>
<property>has spouse</property>
<value>Kym Smith</value>
</entry>
<entry>
<property>http://www.w3.org/1999/02/22-rdf-syntax-ns#type</property>
<value>Person</value>
</entry>
</data>