Featured Post

Linkedin

 These days, I mostly post my tech musings on Linkedin.  https://www.linkedin.com/in/seanmcgrath/

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:

    <foo>
    <bar baz="bork"/>
    Hello World
    </foo>


You run:

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


You get:


    default namespace = ""

    start =
    element foo {
    (text
    | 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: