<< February 2005 April 2005 >>

Thursday 31 March, 2005
# I hate facing media, says Charles - The assembled microphones picked up his comments, mumbled to his sons, which included: "I hate doing this."
Republican though I am, I can't say I blame him right at the moment.

[Add a comment]
#www.comebackchris.com

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.

Richard [w] said I don't know about the petitions, but you should read some of the exchanges taking place on various Doctor Who message boards. It gives wearing an anorak a very bad name indeed ! [added 1st Apr 2005]
planetcutie said Yup. Outpost Gallifrey's forum has been shut down by the editor because of it :

http://www.gallifreyone.net/forum/index.php

[added 1st Apr 2005]

mattb said It seems the timing issue was not Eccleston's doing - the Beeb had agreed not to reveal the decision, which was made back in January, but then allowed it to slip out.

http://www.itv.com/news/entertainment_198760.html [added 5th Apr 2005]


[Add a comment]
#Cooking with Pete: Red Pepper Risotto

This is what the Bean cooked (with a bit of guidance from Nattle).

You'll need some olive oil and some salt and pepper too.

  1. Bang your oven to reasonably hot, around 180 to 200 degrees Centigrade. Put the peppers onto a baking sheet, and pop into the oven for 30 minutes or so. You want the skin to have bubbled up and turned brown, while the pepper itself has collapsed and softened.
  2. Hook the peppers out of the oven. Let them cool a bit then peel off the skin, hook out the seeds and white bits, and cut the flesh into strips (or squares or whatever you fancy).
  3. Make up your stock - spend an hour boiling up bits of veg, or stick the kettle on and peel a cube - and keep it on a low simmer.
  4. Slice the garlic cloves. Chop up the parsley. Pour a tablespoon or so of oil into a large, heavy bottomed pan. Fling the garlic and parsley in too, then turn the heat on low.
  5. When the pan starts to sizzle, add the tomatoes and give everything a good stir. If you're using fresh tomatoes, let them cook for 10 minutes.
  6. Add the peppers. Stir it all around.
  7. Tip in the rice and give it a thorough stir. Make sure all the rice gets good and coated. Let it cook for a minute or two.
  8. Add a ladelful or two of stock. Stir around. Let it cook a moment. Stir again. Let it cook. Stir. Keep going until the liquid you've added has been absorbed by the rice. When that happens, add some more stock. Stir and wait, stir and wait, add more stock.
  9. Carry on like this for about 20 minutes. By then you'll have probably added nearly all your stock, and the rice should be nearly cooked. What you're aiming for is the rice to soft but still have a bit of resistance. The grains should still be distinct - it's not rice porridge you're after. Keep going with the stock for another few minutes until the rice is done. Use some boiling water if you run out of stock.
  10. Pour on a glug of olive oil, grind on some pepper, sprinkle over a scant pinch of chilli. Stir it all around one more time.
  11. Tear up the basil leaves, throw them over the top. Serve it up.

bob [e] said hello i thought that this recipe was supurb! i thought it was really creamy ;) [added 14th Oct 2005]

[Add a comment]
#[Arabica]XPath : following
Committed following axis implementation to CVS.
[Add a comment]
#Charlotte Church Mobile Phone Doh!
The Register : Charlotte Church topless pic busts onto mobes
Charlotte Church : Subscribe to the official Charlotte Church text message service

Doh!
Elliott Hannant [e] said askin for trouble really! [added 2nd Apr 2005]
divana said dear charlotte..

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]


[Add a comment]
#[linkfarm] The Horrors of Cobol
[Add a comment]
Wednesday 30 March, 2005
#W3C Schema for xml:space

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>


[Add a comment]
#[linkfarm] Elliotte Harold's Schemas talk slides
[Add a comment]
#[linkfarm] Texas already sets the national curriculum on sex ed
[Add a comment]
Tuesday 29 March, 2005
#[linkfarm] Feed me better
[Add a comment]
#

Just had a fantastic red pepper risotto for lunch. The Bean cooked it. What a little champ.

[Recipe]


[Add a comment]
#Resistance is futile?

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.)


[Add a comment]
#[linkfarm] STL Patterns: A Design Language of Generic Programming
[Add a comment]
#[linkfarm] xmlidfilter: A SAX XMLFilter for xml:id Processing
[Add a comment]
#[linkfarm] Manipulating Flash Projector Files Tutorial
[Add a comment]
Saturday 26 March, 2005
# Hal stood up and walked. Go him.
Pete the trucker said No never tried that Equal exchange brand. In fact I've only just found a shop in Edinburgh that has that sort of gear. Ta for the tip. [added 27th Mar 2005]

[Add a comment]
Thursday 24 March, 2005
#Outings

Deffo

Maybe

You know what I need? Someone to join me on my occasional trips out. A rock buddy, if you will.


[Add a comment]
#[Arabica]XPath : descendant-or-self axis
Just committed to CVS. Just following, preceding and namespace to go.
[Add a comment]
Wednesday 23 March, 2005
#[Arabica]XPath : descendant axis
Implemented the descendant axis. Just descendant-or-self, following, namespace and preceding to go.
[Add a comment]
#[elsewhere] Five years old - small, but tenacious.
[Add a comment]
Tuesday 22 March, 2005
#Just need to get them printed ...
JezUK business cards
anonymous said the dot above the Z is a bit confusing - unless it's too late to change it in which case it's smashing ;) [added 22nd Mar 2005]
it's to add a bit of mystery - "what's that dot doing there?" :) [added 22nd Mar 2005]
anonymous said so r u gonna have a website makeover as well to have a unified corporate theme :) [added 22nd Mar 2005]
wait and see ... [added 22nd Mar 2005]
Mailed them over to printing.com this afternoon. Should have them back next week. [added 23rd Mar 2005]
Marv said Where can we buy T-shirts? [added 24th Mar 2005]

[Add a comment]
#[linkfarm] ArsDigita Mission Statement
[Add a comment]
Monday 21 March, 2005
#[linkfarm] Billy and the Boingers
[Add a comment]
#[linkfarm] Mars still alive, experts agree
[Add a comment]
#[Arabica]SAX::ignorableWhitespace

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.

:(


[Add a comment]
Saturday 19 March, 2005
# Just seen the trailer for the new Doctor Who series. Am shaking and teary-eyed with excitement.[later]Welcome Googlers. You probably want look here http://www.bbc.co.uk/doctorwho/video/index.shtml [added 21st Mar 2005]

[Add a comment]
#Corporate website? At least try and hire someone half-competent

http://www.6nations.net/ vs http://6nations.net/

Wooden spoons all round.

mattb said yes I'm surprised at the number of sites that don't let you leave out the www... considering how simple it is to fix... [added 19th Mar 2005]

[Add a comment]
Friday 18 March, 2005
#[linkfarm] JagoClient, the Java Go Client
[Add a comment]
#[linkfarm] Lab fireball 'may be black hole'
[Add a comment]
#[linkfarm] Millennium Problems
[Add a comment]
#[linkfarm] 13 things that do not make sense
[Add a comment]
Thursday 17 March, 2005
#An Adventure in Generating XML->C++ Data-Bindings With XSLT : Getting on with the implementation

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.

[Continue the Adventure]

[next day] It was late when I put the drop together last night, and thought I might left a file out (accounting for the missing 62 lines). Turns out, I'd left a redundant one in, so wc now says 481. 481 isn't prime, I'm afraid John, but it is the product of two primes - 13 x 37. Will that do? [added 18th Mar 2005]

[Add a comment]
#[linkfarm] Welcome to Google Code
[Add a comment]
Wednesday 16 March, 2005
#An Adventure in Generating XML->C++ Data-Bindings With XSLT: Prime

    ...

    //////////////////////////
    // 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!

[Continue the Adventure]

Just done a bit more and hit 569 lines. Another prime. Rock and roll! [added 16th Mar 2005]

[Add a comment]
#To whoever smashed my car window last night

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

adm bevan [e] [w] said i would like to second that.. wateva little c*ck thinks there clever smasing my window.. please come back if you think your so bad boy.. il be happy to smash all the others with your HEAD! you little f*ckin chav [added 22nd Mar 2005]
J [e] said dont go on like your to bad if you cant back it up! find out who did it and teach the cunt a lesson if not just shut the fuck up! [added 18th Jul 2008]
anonymous said Served you right. Pussy. Stop crying and man up. I smashed your car window. Come and get me. [added 6th Jan 2010]
Victoria Salter [e] said Such terrible language! It did make me smile though! [added 31st May 2011]
shomrim [e] [w] said if id be you id find that person and get me the feeling to smash his balls up that bastard going around smashing windows [added 20th Sep 2011]
anonymous said i feel ya someone smashed my 2 windows in my car tonight people think thers so tuff next time i hope they wait around bc they wont walk away im tired of this [added 22nd Oct 2011]
The Mask said Kick the crap out of them, there's no justice in this world, but remember if you hurt them it is you that will get the 'nick' for it [added 5th Nov 2011]

[Add a comment]
Tuesday 15 March, 2005
#An Adventure in Generating XML->C++ Data-Bindings With XSLT : Acorns

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.

[Continue the Adventure]

smellygit said Maybe you should only do releases from now on when wc says a nice number. Maybe the next one should be a prime number :) [added 16th Mar 2005]

[Add a comment]
Friday 11 March, 2005
#An Adventure in Generating XML->C++ Data-Bindings With XSLT : Multiplicity

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.

[Continue the Adventure]


[Add a comment]
#[elsewhere] Microsoft developers revolting over VB
[Add a comment]
Thursday 10 March, 2005
#Welcome irate VB programmers!

Microsoft MVPs revolt

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

Simon Brunning [e] [w] said Why now? 'Cos VB6 support is just about to be chopped. [added 11th Mar 2005]
But that's hardly news. The death sentence was announced years ago. Surely the chance to get something done was then, not now. [added 11th Mar 2005]
Gevs said

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]

Yep, xsd.exe will happily generate large quantities of C#, JavaScript or VB.NET, and it entirely fine if that's what you want.

But I want an adventure! [added 11th Mar 2005]

[Add a comment]

# How tunes get stuck in your head - ... When familiar tunes played, the cortex activity continued during the blanks - and the volunteers indeed said they still mentally "heard" the tunes ...
Earworms explained. How can anyone say science is boring?

[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

smellygit said Useful functionality! That's not what writing software is about ;) [added 10th Mar 2005]
I know. And I'm sorry :) [added 10th Mar 2005]
mattb said Would be good to build that software plus a voice synthesiser into a small mobile plastic biped that could also maybe hoover the floor... p.s. did you see the latest Hitchhiker's Guide trailer

http://hitchhikers.movies.go.com/trailers/ [added 10th Mar 2005]

So you could hoover by IM? It'd put a whole new spin on home automation certainly. [added 10th Mar 2005]
That new trailer is loads better then the previous one. Perhaps we should have a trip out ... [added 10th Mar 2005]
smellygit said (13:43:34) jez: remind Nat to do the hovering in 30 minutes

.... [added 11th Mar 2005]

No need. She's much more organised than I am. [added 11th Mar 2005]

[Add a comment]
Wednesday 09 March, 2005
#An Adventure in Generating XML->C++ Data-Bindings With XSLT: With or without?

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.

[Continue the Adventure]


[Add a comment]
Tuesday 08 March, 2005
#An Adventure in Generating XML->C++ Data-Bindings With XSLT: Headguard

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.

[Continue the Adventure]


[Add a comment]
#An Adventure in Generating XML->C++ Data-Bindings With XSLT: Pat on the head

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!

[Continue the Adventure]


[Add a comment]
Monday 07 March, 2005
#An Adventure in Generating XML->C++ Data-Bindings With XSLT : Earworm

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.g
XMLRoot 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.

[Continue the Adventure]

allankellynet said Cool.

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]

You could do all those things.

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]

#
wakin' up, goin' okay, it's gig time, what t-shirt am I gonna wear?

[Add a comment]
Friday 04 March, 2005
#[linkfarm] what is scponly?
[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?

smellygit said software created, extended or destroyed ;) [added 7th Mar 2005]
It's a thought, but I was trying to create a more positive "brand image" :) [added 7th Mar 2005]

[Add a comment]
Wednesday 02 March, 2005
#[linkfarm] opensource.adobe.com
[Add a comment]
#A simple javax.xml.transform.URIResolver for hooking stuff out of the class path.

Got a groovy application that uses loads of XSLT stylesheets? Want 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

anonymous said Very helpfull thanks. [added 1st Dec 2006]
anonymous said This is what I was exactly looking for [added 2nd Apr 2009]
Satya said Thanks ... this saved me a lot of time ... [added 12th Jan 2010]
anonymous said Very good!, maybe your solution help me alot! Thx! [added 24th Feb 2010]
anonymous said This saved me a lot of time as well, thanks!! [added 4th May 2011]
anonymous said Awesome ... works the first time - you are my hero ;-D [added 2nd Aug 2011]

[Add a comment]
# Hal started walking yesterday. I was out all day. Bastard.
[Add a comment]
<< February 2005 April 2005 >>