| JezUK Ltd - The Coffee Grounds - March 2005 |
| << February 2005 | April 2005 >> |
New Doctor Who series confirmed - Yay!
Eccleston quits Doctor Who role - Boo!
Timing. What's the secret of great comedy?
Really, really enjoyed the new Dr Who on Saturday, so a bit disappointed to hear that Christopher Eccleston will only be doing one series. It's a shame, I think, but it's only television.
No doubt those Who truefans who aren't sticking pins on to little Eccleston effigies will be organising online petitions to try and change his mind. Around lunchtime I thought it would be funny to try and word a petition that exactly reflected the typecasting Eccleston says he fears, seed it around, get a load of people signed up, in the papers by Monday, that kind of thing. Oh, the irony, etc, etc. Unfortunately wasn't clever enough to word the petition while I still thought it was the funniest thing ever. Ah, well.
Came up with a good domain name though - www.comebackchris.com. Go on Whofans, register it now.
http://www.gallifreyone.net/forum/index.php
[added 1st Apr 2005]
http://www.itv.com/news/entertainment_198760.html [added 5th Apr 2005]
This is what the Bean cooked (with a bit of guidance from Nattle).
hey charlotte!my name is divana valencia you can call me diva.im from indonesia!can you come to my country???my country
had a show!!its called visit indonesia 2008!!please,come to my country!especially lenteng agung,thats my school!im in first grade!my school name is 98 junior high school,im your very,very very very heavy fans!!!!!oh,im forget something!congratulations!you have a new child!ruby,am i right??please give me your dvd movie???????(ill be there?)please.............. my address is jl=street JL.O Pojok no.10 rt 10 rw 03,srengseng sawah,south jakarta,indonesia.... THANKSSSS very much!!!
with Love..
Diva [added 11th Mar 2008]
Look Ma! I wrote an XSD!
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
targetNamespace="http://www.w3.org/XML/1998/namespace">
<xs:attribute name="space">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="preserve"/>
<xs:enumeration value="default"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:schema>
Stick it in a file call xmlspace.xsd and include it in your own schemas using
<xs:import namespace="http://www.w3.org/XML/1998/namespace"
schemaLocation="xmlspace.xsd"/>
...
<xs:element name="myElement">
<xs:complexType ...
...
<xs:attribute ref="xml:space"/>
</xs:complexType>
</xs:element>
Just had a fantastic red pepper risotto for lunch. The Bean cooked it. What a little champ.
[Recipe]
Have just confirmed that I'm going to attend a Microsoft Community Leaders Day. I have no idea what it involves, other than a day in the Regus office next to the Reading mothership, but hopefully full-scale implants aren't on the agenda.
(I qualify as a "community leader" by virtue of being on the ACCU committee. Ewan, the chair, can't go and I was the only person [foolish enough?] to express an interest.)
Deffo
Maybe
You know what I need? Someone to join me on my occasional trips out. A rock buddy, if you will.

Been investigating when parsers call ignorableWhitespace -
Validating Parsers must use this method to report each chunk of whitespace in element content (see the W3C XML 1.0 recommendation, section 2.10): non-validating parsers may also use this method if they are capable of parsing and using content models.
Xerces validates, but I've not been able to get it to report ignorableWhitespace. libxml2 I've not been able to get to load an external DTD, and doesn't valid via its SAX API. With an internal DTD I can't get it to report whitespace, although it looks like it should. Expat reads external DTDs but doesn't validate or do content models. MSXML won't read external DTDs either.
:(
http://www.6nations.net/ vs http://6nations.net/
Wooden spoons all round.
In my mind, I have this thing completely cracked now. I know it's going to work, I know what needs to be done, I just need to get on and do it. When I was young and callow I'd have packed it in now. Now I pretend to be a grown-up, I try and finish things. Or at least finish them more.
The class definitions are coming along now. The generated classes describe value objects, so we shouldn't expect to pass them round as pointers. However, since an object could contain an arbitrarily large number of other objects, the cost of copying the objects around could be very large. At the risk of prematurely optimising, the classes use handle-body. The body reference counts and kills itself when it isn't needed any more. I'm not planning to copy-on-write, but I need to think about that a bit more.
Here's a zip. Here's a tar.gz. wc, which I'm starting to obsess about a bit, says 507, not sure where the extra 62 lines went. Haven't decided on a license yet, btw, but it'll be BSD or GPL, probably GPL.
...
//////////////////////////
// instance variables
std::string MandatoryChild_;
std::string OptionalChild_;
bool is_OptionalChild_set_;
std::vector CollectionChild_;
...
wc says 521. A Lucas number. And prime. Screw U, smellygit!
Dear Bastard,
Thank you so much for smashing the window of my car. I've met so many new people this morning, all of them saying "I think someone has tried to break into your car". They are all wrong, of course, since you didn't even open the door. Clearly you just needed to smash something.
Perhaps you could pop back and leave your address. The next time *I* feel the need to smash something, I'd be happy to come round to your place and smash something of yours.
Jez
No time for smart-arse commentary this evening, so just cop this and then fill in your own:
/*
* This source file was automatically generated from
* an XML Schema. You probably don't want to edit it.
*/
class Cardinality_impl
{
public:
Cardinality_impl() :
MandatoryChild_(),
OptionalChild_(),is_OptionalChild_set_(false),
CollectionChild_collection_(),
ref_count(0)
{
} //
//////////////////////////
// instance variables
//////////////////////////
// ref count
void add_ref() { ++ref_count; }
void remove_ref() { if(--ref_count == 0) delete this; }
private:
unsigned int ref_count;
// no impl
Cardinality_impl(const Cardinality_impl&);
Cardinality_impl& operator=(const Cardinality_impl&);
bool operator==(const Cardinality_impl&) const;
} // class Cardinality_impl
wc says 512. A power of two! Sweet.
I'm not an XML Schema guru, so "big ups" (as I believe the young people say) to my "homie" Kal for his XML Schema Browser which gives pithy little summaries cross-linked into the specification text. Ph34r h1s l33t sk1llz.
Yesterday I had a go at generating bindings for optional element, so next up is element which can appear multiple times -
<xs:element name="something" maxOccurs="X" ... />
or
<xs:element name="orother" minOccurs="Y" maxOccurs="X" .../>
where X is some integer greater than 1 (or Y), or the work "unbounded, and Y is an integer less than X.
For my purposes if I see a maxOccurs attribute, I'm not bothered about minOccurs because I'm only generating data bindings, not validation code. (At the moment anyway - we'll see).
So given
<xs:element name="thing" type="xs:string"
minOccurs="0" maxOccurs="unbounded"/>
my little pile of XSLT (417 lines, now uses xsl:document so won't work with MSXML's XSLT processor anymore) generates
const std::vector<std::string>& get_thing_collection() const;
void add_thing(std::string& new_thing);
void remove_thing(int index);
void clear_thing_collection();
I'm not entirely thrilled with exposing the vector directly, but it'll do for now. It's enough declaration too. Next up, some definition.
Microsoft MVPs Say They Want Old VB Back
I don't have a "professional" opinion on this - I'm not a VB programmer, never have been, never will be. This is consistent with what I've read and heard, although I rarely speak directly to people who work solely in VB. I have an opinion on VB obviously - that it's frustrating and largely rubbish - but that's not really relevant here.
What does strike me as slightly strange in the timing. It's going on 4 years since VB6 was banged on the head. There was an immediate kerfuffle about lack of backward compatibility. Why now? Are these people so useless that they can't pick up a new variant of BASIC in four years?
From rblevin.blogspot.com
"Thank G-d I'm not dependent on having to program any longer, because with the release of .NET, I'd be farkled, fubar'd, and frazzled. Like many other developers, I don't have the time, energy, or desire to un-learn the substantial skills I've acquired in over 20 years of coding with Microsoft Basics, and re-learn some new thing that's marketed as Visual Basic, but is, in fact, radically different."Apparently so. All software - desktop apps, languages, databases, whatever - gets end-of-lifed eventually, some unfortunately, some fortunately. I knew a couple of DataEase programmers who had their living taken out from underneath them, but they didn't sit about moaning, they just got on and applied what they knew. The fundamental programming disciplines aren't tied to any one language or any one way of working. They won't disappear out the side of your head. I doubt very much that MS will change their minds about this - history would suggest not. I suggest these blokes buck up and get on.
For DataEase you can substitute any number of things - numerous Basic and Pascal variants, uncountable 4GLs (as they were quaintly known), word processor macro languages, Borland's OWL, and so on and so on. There's a lot of code out there written for VC6 that will require a great deal of work if it's to be built with modern compilers.
Embrace change. It's what programming's about.
I'm writing this as I go to bed in the anticipation that Matt's article for ZDNet will be published overnight and perhaps generate some small amount of attention. See you in the morning.
Update: Here it is at last, Microsoft developers revolting over VB
I moved to C# over 2 years ago after 6 years of VB3-VB6.
The biggest problem i found with VB was that it allowed *anybody* to knock *something* together that looked like a working app. I've lost count of the number of times I have been tasked with "productionising" a "60 percent finished" protype , which in fact needed a complete re-write.
OK I can't hold the language to task for idiots writing bad code, but it certainly allowed the promotion of bad practice.
By the way, for C# development xsd.exe supplied with Visual Studio will generate a class structure from an XSD.
[added 11th Mar 2005]
But I want an adventure! [added 11th Mar 2005]
[Add a comment]
Just cut a new release of WheresKal, my little Jabber chatbot. It's now bundles up everything it needs so is much easier to install, for a start, and now also includes some almost useful functionality.
(13:43:34) jez: remind me to turn the oven off in 30 minutes
(13:43:34) whereskal: ok, I'll remind you to turn the oven off in 30 minutes
...
(14:13:34) whereskal: You asked me to remind you to turn the oven off
http://hitchhikers.movies.go.com/trailers/ [added 10th Mar 2005]
.... [added 11th Mar 2005]
Now understands
<xs:element name="OptionalChild" type="xs:string" minOccurs="0"/>
generating
...
const std::string& get_OptionalChild() const;
bool is_OptionalChild_set() const;
void set_OptionalChild(const std::string& new_OptionalChild);
void reset_OptionalChild();
...
Here's the drop. wc says 366 lines. More functionality with less code - always good.
And so to bed. The general structure of the header file is complete - include guards, forward declarations, that kind of thing. Popped in generating accessors for xs:attributes too. Tomorrow, maybe I'll look at optional and multiple elements. Or maybe some definitions to go with the declarations. Who knows?
Here's today's drop. wc says 382 lines so far.
Despite the plethora of more pressing things, I've hacked a bit more XSLT this morning.
My current work, extending an existing Zope application, is a little tiring; not because it's difficult, it's just long winded and fiddly. As a little reward to myself every hour and half or so, whenever I hit some little milestone, I have a ten second oil break. The conference, the port and whatever need more concentration that I can bring to bear, but XSLT hacking can happen in tiny increments. It feels like fun too (probably because it's not directed to any external end or deadline).
So far this morning, I've filled out more of the deserialisation class declaration
class catalog_factory : public SAX::DefaultHandler
{
public:
static catalog read(SAX::InputSource& is);
private:
catalog_factory(SAX::XMLReader& reader);
~catalog_factory();
const catalog& get_catalog() const;
virtual void startElement(const std::string& namespaceURI,
const std::string& localName,
const std::string& qName,
const SAX::Attributes& atts);
virtual void endElement(const std::string& namespaceURI,
const std::string& localName,
const std::string& qName);
virtual void characters(const std::string& ch);
virtual void fatalError(const SAX::SAXException& exception);
catalog catalog_;
SAX::XMLReader& parser_;
SAX::ContentHandler* child_factory_;
// we have exciting complex content
}; // class catalog_factory
This stuff is a doddle!
Being a programmer is a bit like being a copper sometimes. You're never off duty.
A few weeks ago, my colleague-in-code Allan Kelly posted to accu-general
I'd like to be able to take an XML Schema and feed it into a code generator. The generator would produce a set of C++ classes which would allow me to navigate the XML. So, I could pass an XPath/XPointer withing a document to one of these classes, and I could then navigate through the document below, e.gXMLRoot address_document(filename, xpath); XMLNode house = address_document->House(); int num = house->Number(); string road = house->Road();
You get the ideas?
So, does it exist?
This kind of thing is called data-binding and I referred him to Google. I mentioned BindOTron in passing, and opined
I don't see why it wouldn't be possible to generate your C++ classes from schema using a set of XSLT stylesheets
What a crazy fool I was. That idea has been wriggling around in the back of my head in exactly the way crappy songs lodge in your ear even though you only caught two bars of it. So, even though I have a conference presentation to finish, a big pile of Java to port to C#, an article to write, and, if all else fails, some actual live paying work to do, I spent an hour this evening writing enough of a stylesheet to convince myself that it would work. Well I always knew it would work - there's nothing you can't do with a Turing complete language after all - but I've now I know it's going to be pretty easy too.
Given this cheesy example -
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xs:element name="elem">
<xs:complexType>
<xs:sequence>
<xs:element name="first" type="xs:string"/>
<xs:element name="second" type="xs:string"/>
<xs:element name="third" type="xs:string"/>
<xs:element name="number" type="xs:int"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
you get this cheesy output
class elem_impl;
class elem
{
public:
elem();
elem(const elem rhs);
~elem();
elem& operator=(const elem& rhs);
bool operator==(const elem& rhs) const;
const std::string& get_first() const;
void set_first(const std::string& new_first);
const std::string& get_second() const;
void set_second(const std::string& new_second);
const std::string& get_third() const;
void set_third(const std::string& new_third);
int get_number() const;
void set_number(int new_number);
void emit_xml(std::ostream& os) const;
private:
void set_impl(elem_impl* impl);
elem_impl* impl_;
}; // elem
Readers with too much time on their hands will note that this output is extremely similar to BindOTron's. The stylesheet handles refs too and happily eats the toy schemas I've been feeding it. It'll probably choke on any real schema, but it's not a bad start for less than an hour and 150 lines of XSLT.
I'd say you where a genius but you told me it was so easy :)
I thought this would be possible but I don’t have the knowledge of XSLT (or time) to do it. Knowing it is possible sets me wondering... it gives me a number of ideas
- we really could keep our C++ code (or Java, or C# or whatever) in step with our XML quite simply
- we could create a new generation of design tools which produced XML and a second set of tools which turn the XML into code, i.e. you get a front end and a back end.
I’m sure this will generate more ideas too.
Good work Jez, and thanks for playing with my idea.
[added 8th Mar 2005]
To be honest, the tools probably already exist, but they're expensive or crappy or are GUI only so don't integrate with your build process or have some other failing. I assume so anyway, otherwise more of us C++ types would be doing it :) [added 8th Mar 2005]
[Add a comment]
software created, extended or repaired
My graphic designer chum Ken came up with that as the tagline for the super-duper Jez UK business cards he's working on. Like it?
Got a groovy application that uses loads of XSLT stylesheets? What to stash those stylesheets in your Jar file? Well, go right ahead, because this simple URIResolver will take care of hooking them out when you need them.
package uk.co.jezuk.xcrete; import javax.xml.transform.URIResolver; import javax.xml.transform.Source; import javax.xml.transform.TransformerException; import javax.xml.transform.stream.StreamSource; import java.io.InputStream; public class ResourceResolver implements URIResolver { public Source resolve(String href, String base) throws TransformerException { if(!href.startsWith("resource://")) return null; // will make Oracle XSLT processor explode, // even though it's correct try { String resource = href.substring(11); // chop off the resource:// ClassLoader loader = getClass().getClassLoader(); InputStream is = loader.getResourceAsStream(resource); return new StreamSource(is, resource); } // try catch(Exception ex) { throw new TransformerException(ex); } // catch } // resolve } // ResourceResolver
Use it something like this -
TransformerFactory transformerFactory_; transformerFactory_ = TransformerFactory.newInstance(); transformerFactory_.setURIResolver(new ResourceResolver());Your TransformerFactory (and any Transformers you create with it) will now be able to resolve URIs in the form
resource://my/package/name/stylesheet.xsl, whether you are loading, importing or including them.
And yes, the Oracle XSLT processor will explode if you give it a null. If you are saddled with it though, don't return null, do something like this instead
try {
URL thing = new URL(new URL(base), href);
return new StreamSource(thing.toString());
} // try
catch(MalformedURLException ex) {
throw new TransformerException(ex);
} // catch
| << February 2005 | April 2005 >> |