Saturday, October 02, 2004

The wonders of trang

I have been using trang a lot for quite a long time. So, it came as a great shock to me to realise that I had somehow missed some very powerful capabilities it posesses.
There I was, flicking my way through XML Hacks when the book fairly shouted out at me that trang can generate schemas from instance documents. I never knew that. I have no idea how come I never managed to internalise that (now blindingly obvious) fact.

You create an XML instance:

    <bar baz="bork"/>
    Hello World

You run:

    java -jar d:\data\utils\trang.jar -I xml -O rnc foo.xml foo.rnc

You get:

    default namespace = ""

    start =
    element foo {
    | element bar {
    attribute baz { xsd:NCName }

Wonderful! This riffs rather nicely with an upcoming ITWorld article on the subject of ex post facto formalisation of schemas in XML app dev.

No comments: