# HG changeset patch # User Babis Nikolaou # Date 1347667664 -10800 # Node ID 8b1b2a49ebf63b092b7e7d8c47290dee9de43157 # Parent b67d9d491156af59b8eedc97ac3e0bd92d120b32 added css classes for rendering the HTML result. To give style to the TABLE tag, one has to define class "TABLE.query_results_table". To give style to the TH tag, one has to define class "TH.query_results_header". To give style to the TD tag, one has to define class "TD.query_results_data". This way, we can change transparently the view of the SPARQL results in HTML. The same is going to be done for the case of KML (description). diff -r b67d9d491156 -r 8b1b2a49ebf6 resultio/src/main/java/org/openrdf/query/resultio/sparqlhtml/stSPARQLResultsHTMLWriter.java --- a/resultio/src/main/java/org/openrdf/query/resultio/sparqlhtml/stSPARQLResultsHTMLWriter.java Fri Sep 14 20:55:57 2012 +0300 +++ b/resultio/src/main/java/org/openrdf/query/resultio/sparqlhtml/stSPARQLResultsHTMLWriter.java Sat Sep 15 03:07:44 2012 +0300 @@ -19,10 +19,14 @@ */ public class stSPARQLResultsHTMLWriter implements TupleQueryResultWriter { - public static final String TABLE = "TABLE"; - public static final String TABLE_ROW_TAG = "TR"; - public static final String TABLE_HEADER_TAG = "TH"; - public static final String TABLE_DATA_TAG = "TD"; + public static final String TABLE = "TABLE"; + public static final String TABLE_ROW_TAG = "TR"; + public static final String TABLE_HEADER_TAG = "TH"; + public static final String TABLE_DATA_TAG = "TD"; + public static final String STYLE = "class"; + public static final String TABLE_HEADER_CLASS = "query_results_header"; + public static final String TABLE_DATA_CLASS = "query_results_data"; + public static final String TABLE_CLASS = "query_results_table"; /** * The underlying XML formatter. @@ -51,12 +55,18 @@ // keep the order of binding names this.bindingNames = bindingNames; + // set style for table + xmlWriter.setAttribute(STYLE, TABLE_CLASS); + // write start of table xmlWriter.startTag(TABLE); // write Table header containing the bindings xmlWriter.startTag(TABLE_ROW_TAG); for (String bindingName: bindingNames) { + // set style for header + xmlWriter.setAttribute(STYLE, TABLE_HEADER_CLASS); + xmlWriter.textElement(TABLE_HEADER_TAG, bindingName); } @@ -95,6 +105,7 @@ if (binding.getValue() instanceof BNode) { value.insert(0, "_:"); } + xmlWriter.setAttribute(STYLE, TABLE_DATA_CLASS); xmlWriter.textElement(TABLE_DATA_TAG, value.toString()); value.setLength(0);