1
我正在使用TopBraid作曲家大師版學習SWP(SPARQL網頁),並且我可以創建一個SWP文件。此SWP文件使用SPARQL查詢示例數據集以將結果作爲HTML返回。這是代碼片段,我在我的項目:如何使用TopBraid Composer SPARQL網頁返回XML?
<!-- 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片斷就像一個魅力,並顯示我需要什麼。儘管如何獲得XML而不是HTML?
編輯:
這是返回的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>
什麼是你所得到的查詢結果?它的格式是什麼? (我知道你說過HTML,但是如果是,例如XHTML,那麼它也是XML)。 –
我剛剛使用HTML輸出編輯原始文章 –
您是否嘗試過使用regexp和/或XSLT修剪返回的HTML並返回只有XML? – Xenyal