I need to generate an xsl table for the xml below, for attributes fname and lname. I guess I have done something wrong in xpath. Could someone help me out by writing an xsl table for the xml below..
<sparql>
<head>
<variable name="s"/>
<variable name="fname"/>
<variable name="lname"/>
</head>
<results>
<result>
<binding name="s">
<uri>http://tn.gov.in/Person/41</uri>
</binding>
<binding name="fname">
<literal>Gayathri</literal>
</binding>
<binding name="lname">
<literal>Vasudevan</literal>
</binding>
</result>
<!-- more result elements -->
</results>
</sparql>
like i have an servlet which queries a semantic data , using jena... the output of the servlet is above xml... while setting the output format Jena has an option in which the XML can be styled mapping the xsl file..
now when i used lachlan's example i got output as i posted in that comment.. nothing , my output must be in the form of an Table in which fname,lname should be displayed
like
fname lname
------------------------
Magesh vasudevan
Gayathri vasudevan
etc...
what's the mistake i must have done ? this is my xsl:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="UTF-8"/>
<xsl:template match="sparql/results">
<html>
<head><title>persons</title>
</head>
<body>
<table width="40%" border="1">
<THEAD>
<TR>
<TD><B>first name</B></TD>
<TD><B>last name</B></TD>
</TR>
</THEAD>
<TBODY>
<xsl:for-each select="result">
<TR>
<TD><xsl:value-of select="binding[@name='fname']/literal/text()" /></TD>
<TD><xsl:value-of select="binding[@name='fname']/literal/text()" /></TD>
</TR>
</xsl:for-each>
</TBODY>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
My output is:
http://tn.gov.in/Person/41 Gayathri Vasudevan http://tn.gov.in/Person/43 Vivek Vasudevan http://tn.gov.in/Person/37 Magesh Vasudevan http://tn.gov.in/Person/39 Vasudevan Srinivasan
i dint put the name='s' in the xsl def.. but i am getting that also in the output that too wihtout formatting as table..
YES i have nampespace for the root sparql..
<sparql xmlns="http://www.w3.org/2005/sparql-results#">
<head>
<variable name="s"/>
<variable name="fname"/>
<variable name="lname"/>
<variable name="title"/>
<variable name="mno"/>
<variable name="community"/>
</head>
<results>
<result>
<binding name="s">
<uri>http://tn.gov.in/Person/45</uri>
</binding>
<binding name="fname">
<literal>Ravi</literal>
</binding>
<binding name="lname">
<literal>Kumar</literal>
</binding>
<binding name="title">
<literal>Mr.</literal>
</binding>
<binding name="mno">
<literal>876876</literal>
</binding>
<binding name="community">
<literal>FC-Forward Caste</literal>
</binding>
</result>
how should i match template now?