I'm learning SWP (SPARQL Web Pages) using TopBraid Composer Maestro Edition and I am able to create a SWP file. This SWP file uses SPARQL to query the sample dataset to return results as HTML. This is the code snippet that I have in my project:
<!-- 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>
This SWP snippet works like a charm and displays what I need. How can I get XML instead of HTML, though?
Edit:
This is the HTML that is returned:
<!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>
Instead of that, I just want it to return this with xml headers as well:
<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>
SWP is a data templating tool just like JSP, ASP, etc. The processor will respond with whatever text is in the SWP file unless there is a SWP processing directive, denoted by the curly brackets or a SWP element. Therefore the short answer to your question is to simply use the XML tags instead of HTML.
The following should give you the XML you're looking for: