Strabon

changeset 547:8b1b2a49ebf6

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).
author Babis Nikolaou <charnik@di.uoa.gr>
date Sat Sep 15 03:07:44 2012 +0300 (2012-09-15)
parents b67d9d491156
children 4bd5b9a0177b
files resultio/src/main/java/org/openrdf/query/resultio/sparqlhtml/stSPARQLResultsHTMLWriter.java
line diff
     1.1 --- a/resultio/src/main/java/org/openrdf/query/resultio/sparqlhtml/stSPARQLResultsHTMLWriter.java	Fri Sep 14 20:55:57 2012 +0300
     1.2 +++ b/resultio/src/main/java/org/openrdf/query/resultio/sparqlhtml/stSPARQLResultsHTMLWriter.java	Sat Sep 15 03:07:44 2012 +0300
     1.3 @@ -19,10 +19,14 @@
     1.4   */
     1.5  public class stSPARQLResultsHTMLWriter implements TupleQueryResultWriter {
     1.6  
     1.7 -	public static final String TABLE			= "TABLE";
     1.8 -	public static final String TABLE_ROW_TAG	= "TR";
     1.9 -	public static final String TABLE_HEADER_TAG = "TH";
    1.10 -	public static final String TABLE_DATA_TAG	= "TD";
    1.11 +	public static final String TABLE				= "TABLE";
    1.12 +	public static final String TABLE_ROW_TAG		= "TR";
    1.13 +	public static final String TABLE_HEADER_TAG 	= "TH";
    1.14 +	public static final String TABLE_DATA_TAG		= "TD";
    1.15 +	public static final String STYLE				= "class";
    1.16 +	public static final String TABLE_HEADER_CLASS	= "query_results_header";
    1.17 +	public static final String TABLE_DATA_CLASS		= "query_results_data";
    1.18 +	public static final String TABLE_CLASS			= "query_results_table";
    1.19  	
    1.20  	/**
    1.21  	 * The underlying XML formatter.
    1.22 @@ -51,12 +55,18 @@
    1.23  			// keep the order of binding names
    1.24  			this.bindingNames = bindingNames;
    1.25  			
    1.26 +			// set style for table
    1.27 +			xmlWriter.setAttribute(STYLE, TABLE_CLASS);
    1.28 +			
    1.29  			// write start of table
    1.30  			xmlWriter.startTag(TABLE);
    1.31  			
    1.32  			// write Table header containing the bindings
    1.33  			xmlWriter.startTag(TABLE_ROW_TAG);
    1.34  			for (String bindingName: bindingNames) {
    1.35 +				// set style for header
    1.36 +				xmlWriter.setAttribute(STYLE, TABLE_HEADER_CLASS);
    1.37 +				
    1.38  				xmlWriter.textElement(TABLE_HEADER_TAG, bindingName);
    1.39  			}
    1.40  			
    1.41 @@ -95,6 +105,7 @@
    1.42  				if (binding.getValue() instanceof BNode) {
    1.43  					value.insert(0, "_:");
    1.44  				}
    1.45 +				xmlWriter.setAttribute(STYLE, TABLE_DATA_CLASS);
    1.46  				xmlWriter.textElement(TABLE_DATA_TAG, value.toString());
    1.47  				
    1.48  				value.setLength(0);