Tuesday, 7 July 2009
WSDL 2.0 and all that
Keith Chapman's Blog: RESTfull Mashup with WSDL 2.0 - WSO2 Mashup Server
and the referenced WSDL file he uses. I think he in turn uses the useful IBM page on this subject, and the WSDL primer, core definition and adjunct pages. Apart from that, there's not much out there on using WSDL for RESTful services.
In theory this could all also be done in RDF, or even a mixture of the two... this might provide both the functional definition in WSDL and the ontological framework ('find me all the atlas web services which give run information') in RDF. I'll start with WSDL, progress to UDDI and then try to backtrack and insert some RDF.
Tuesday, 9 June 2009
Safari 4: Does Acid pass the Acid test?
Corrupt screen memory: Go to that link after visting another page and you'll see the new page just billboarded on top of the one you were looking at.

Try resizing the window to see ugly stuttering visual history as the window moves...

...and then there's simple (but big number) arithmetic inside XSLT. Safari just gets it wrong. Come on guys, where are those 64 bits you promised us? Heres an example of hex conversion, where the large integer here simply gets converted to zero inside safari, but the correct answer is given in Firefox.
So Acid 3 is all very well at testing the fancy new features, but I would have thought that CSS styling of Plain Old Xml would be even more fundamental than testing the new selectors.. so Acid 3 is failing my acid test, at least.
Friday, 5 June 2009
Parametrized Xslt from javascript, using prototype
var Loader = Class.create({
initialize: function(){
this.result="";
},
loadXml: function(docPath){
this.ajaxLoad(docPath);
},
ajaxLoad: function(docPath){
//bind the passed function to the original class
//the method (get) needs to be explicitly written in lowercase for the Safari browser!
new Ajax.Request(docPath, {asynchronous: false, onSuccess: this._callback.bind(this), method: "get",
onFailure: function(r){alert("load failed");}})
},
_callback: function(r){
this.result=r.responseXML;
},
doc: function(){
if (this.result==""){
alert("no doc");
}
return this.result;
}
});
var Transformer = Class.create({
initialize: function(){
this.processor = new XSLTProcessor();
this.paramNames=[];
this.paramValues=[];
this.xslPath="";
this.xmlPath="";
this.fileLoader = new Loader();
},
setXslt: function(xslPath){
this.xslPath = xslPath;
this.fileLoader.loadXml(xslPath);
this.stylesheet = this.fileLoader.doc();
},
setXml: function(docPath){
this.xmlPath = docPath;
this.fileLoader.loadXml(docPath);
this.xmlDoc = this.fileLoader.doc();
},
setParam: function(paramName, paramValue){
this.paramNames.push(paramName);
this.paramValues.push(paramValue);
},
exec: function(thisdoc){
this.processor.importStylesheet(this.stylesheet);
for (var i=0;i<this.paramValues.length;i++){
this.processor.setParameter("",this.paramNames[i], this.paramValues[i]);
}
var fragment = this.processor.transformToFragment(this.xmlDoc, thisdoc);
return fragment;
}
});
//global functions
function changeLinks(){
//take existing links in the div 'displayableModules' and add an id, and suppress the href link
var allLinks=$("displayableModules").getElementsByTagName("a");
for (var i=0;i
var thisElement=$(allLinks[i]);
var thisElementUrl=String(thisElement.href);
var moduleId="module_".concat(thisElementUrl.substring(thisElementUrl.lastIndexOf('#') + 1));
thisElement.setAttribute("id", moduleId);
thisElement.setAttribute("name", thisElementUrl.substring(0,thisElementUrl.lastIndexOf('#')));
thisElement.setAttribute("href","");
}
listenToLinks();
}
function listenToLinks(){
//take existing links in the div 'displayableModules' and listen to them...
var allLinks=$("displayableModules").getElementsByTagName("a");
for (var i=0;i
var thisElement=$(allLinks[i]);
var thisModule=String(thisElement.id);
thisElement.observe('click',transform);
}
}
function transform(e) {
var moduleElement=e.element();
var thisModule=moduleElement.id;
var sourceFile=moduleElement.name;
var transformer = new Transformer();
transformer.setXslt("./xsl/graph.xsl");
transformer.setXml(sourceFile);
transformer.setParam("id",thisModule.substring(7));
w=window.open("",thisModule,"width=670,height=500");
w.document.open();
w.document.write('
Bad channels for module ' + thisModule.substring(7) + '
');f=transformer.exec(w.document);
w.document.getElementById('insert').appendChild(f);
w.document.close();
}
document.observe('dom:loaded', changeLinks);
Wednesday, 3 June 2009
Prototype and running XSLT from JavaScript
Thursday, 28 May 2009
Java 'PUT' for RESTful service
Wednesday, 27 May 2009
Saxon XSLT 2.0 format-number problem (update!)
Symbol Meaning
0 a digit
# a digit, zero shows as absent
. placeholder for decimal separator
, placeholder for grouping separator.
; separates formats.
- default negative prefix.
% multiply by 100 and show as percentage
? multiply by 1000 and show as per mille
¤ currency sign; replaced by currency symbol; if
doubled, replaced by international currency symbol.
If present in a pattern, the monetary decimal separator
is used instead of the decimal separator.
X any other characters can be used in the prefix or suffix
' used to quote special characters in a prefix or suffix.
<numbers>
<test> id="1">1.3</test>
<test> id="2">8E-4</test>
<test> id="3">8E-8</test>
<test> id="4">0.0</test>
<test> id="5">0</test>
</numbers>
and an xslt:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="2.0">
<xsl:output method="text"/>
<xsl:template match="numbers">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="test">
<xsl:value-of select="concat('Original: ',text())"/>
Format with #.#####
'<xsl:value-of select="format-number(xs:double(.), '#.#####')"/>'
Format with #.#########
'<xsl:value-of select="format-number(xs:double(.), '#.#########')"/>'
</xsl:template>
</xsl:stylesheet>
But the output is not what one would expect:
Original: 1.3
Format with #.#####
'1.3'
Format with #.#########
'1.3'
Original: 8E-4
Format with #.#####
'.0008'
Format with #.#########
'.0008'
Original: 8E-8
Format with #.#####
''
Format with #.#########
'.00000008'
Original: 0.0
Format with #.#####
''
Format with #.#########
''
Original: 0
Format with #.#####
''
Format with #.#########
''
Tuesday, 26 May 2009
CherryPy Caching: reprise
Friday, 15 May 2009
CherryPy Caching
I just tried turning on CherryPy web caching, this is one of the few things which receives only very cursory treatment in Sylvain Hellegouarch's excellent book, 'CherryPy Essentials'. I managed by incorporating the