Hello everyone,
I'm facing some troubles customizing the SPARQL endpoint's html page
of a Virtuoso Open Source 6.1 I have on a remote ubuntu 12.04.2
machine.

The goal of this customization is to add some links under the
<textarea> element a user can click in order to change its content
with some example SPARQL queries.
I followed what's listed here:
http://docs.openlinksw.com/virtuoso/rdfsparql.html#rdfsupportedprotocolendpointuricustm

I wrote an XSLT (see attachment) that basically creates a copy of the
original VOS SPARQL endpoint's html page adding some code in the
<style> and <script> html elements, I copied the VOS SPARQL endpoint's
html source in a .html file, and launched my XSLT against it. I piped
the result in another .html file and tried to display it on my
machine's browser.
It works: it reads the CSS, modifies the textarea, and adds the links.

Thus, I placed this XSLT on a remote machine, and I issued the command
in the isql-vt console giving it the address where the XSLT resides,
reloaded the endpoint page, and waited.
It took nearly 5 minutes, but after that the endpoint does not show up
correctly: the CSS seems to be ignored, and the whole html page
displayed is just its text content.

What am I missing?
Do I have to change something in the XSLT?
Thank you
  Andrea


-- 
Andrea Bagnacani - altlabel
web: bagnacan.web.cs.unibo.it
twitter: @altlabel
<?xml version="1.0" encoding="UTF-8"?>

<!-- Andrea Bagnacani - altlabel
	
	add the default VOS SPARQL endpoint's html page a list of links near the html
	<textarea> element so that a user can change its content with some example
	queries by clicking them.
-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
	xmlns:xs="http://www.w3.org/2001/XMLSchema";
	xmlns:fn="http://www.w3.org/2005/xpath-functions";
	xmlns:html="http://www.w3.org/1999/xhtml";
	exclude-result-prefixes="xsl xs fn"
	version="2.0" >
    
    <xsl:strip-space elements="*"/>
	<xsl:output method="xhtml" omit-xml-declaration="no" encoding="UTF-8" indent="yes" />
	
	
	<!-- add the doctype at the beginning -->
	<xsl:template match="/">
		<xsl:text disable-output-escaping='yes'>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"&gt;</xsl:text>
		<xsl:apply-templates/>
    </xsl:template>
	
	
	
	<!-- the root element -->
	<xsl:template match="html:html">
		<xsl:element name="html" namespace="http://www.w3.org/1999/xhtml";>
			<xsl:attribute name="version">-//W3C//DTD XHTML 1.1//EN</xsl:attribute>
			
			<!-- copy its attributes as well -->
			<xsl:for-each select="./@*">
				<xsl:copy-of select="."/>
			</xsl:for-each>
			
			<xsl:apply-templates/>
		</xsl:element>
	</xsl:template>
	
	
	
	<!-- non-leaf elements to be copied -->
	<xsl:template match="html:head | html:body | html:fieldset | html:form
		| html:div | html:select | html:span">
		<xsl:element name="{fn:local-name(.)}" namespace="http://www.w3.org/1999/xhtml";>
			
			<!-- copy its attributes as well -->
			<xsl:for-each select="./@*">
				<xsl:copy-of select="."/>
			</xsl:for-each>
			
			<xsl:apply-templates/>
		</xsl:element>
	</xsl:template>
	


	<!-- leaf elements to be copied -->
	<xsl:template match="html:meta | html:title | html:h1 | html:a | html:br
		| html:label | html:input | html:option | html:i">
		<xsl:copy-of select="."/>
	</xsl:template>
	
    

	<!-- the css
		add the code for the html <textarea> element
	-->
	<xsl:template match="html:style">
		<style xmlns="http://www.w3.org/1999/xhtml";>
			<!-- copy its attributes as well -->
			<xsl:for-each select="./@*">
				<xsl:copy-of select="."/>
			</xsl:for-each>
			
			<xsl:value-of select="."/>
<xsl:text>
/* -------------------------- */
/* style customization starts */
/* -------------------------- */
fieldset textarea {
width: 60%;
font-family: monospace;
font-size: 10pt;
}
/* ------------------------ */
/* style customization ends */
/* ------------------------ */
</xsl:text>
		</style>
	</xsl:template>
	


	<!-- the script
		add the code for the html <textarea> element
	-->
	<xsl:template match="html:script">
		<script xmlns="http://www.w3.org/1999/xhtml";>
			<!-- copy its attributes as well -->
			<xsl:for-each select="./@*">
				<xsl:copy-of select="."/>
			</xsl:for-each>
			
			<xsl:value-of select="."/>
<xsl:text>
/* --------------------------- */
/* script customization starts */
/* --------------------------- */
/* Select the textarea by its ID (that you need to give it) */
var textarea = document.getElementById('query');				
/* Define the function that sets the value passed */
function changeTextarea( str ) {
textarea.value = str;
}
/* ------------------------- */
/* script customization ends */
/* ------------------------- */
</xsl:text>
		</script>
	</xsl:template>
	
    

	<!-- the textarea
		add the links to be placed near this element
	-->
	<xsl:template match="html:textarea">
		<textarea xmlns="http://www.w3.org/1999/xhtml";>
			<!-- copy its attributes as well -->
			<xsl:for-each select="./@*">
				<xsl:copy-of select="."/>
			</xsl:for-each>
			
			<xsl:value-of select="."/>
		</textarea>
		
		<!-- add the links -->
		<br xmlns="http://www.w3.org/1999/xhtml"/>
		<a  xmlns="http://www.w3.org/1999/xhtml"; href="foo.com" onmouseover="changeTextarea('foo.com is a great site')">Foo.com</a>
		<br xmlns="http://www.w3.org/1999/xhtml"/>
		<a  xmlns="http://www.w3.org/1999/xhtml"; href="bar.com" onmouseover="changeTextarea('bar.com is a terrible site')">Bar.com</a>
		<br xmlns="http://www.w3.org/1999/xhtml"/>
	</xsl:template>
	    
</xsl:stylesheet>
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135031&iu=/4140/ostg.clktrk
_______________________________________________
Virtuoso-users mailing list
Virtuoso-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/virtuoso-users

Reply via email to