XML Schema: case of a "simple" element with text and one attribute
It has been a while since I worked with XML Schemas. But after immersing myself in delicious XML Schema material (to revamp Woodstox XML Schema support), I realized that it has not been nearly enough time.
That XML Schema is a very complex way of doing not so much more than what DTDs allow (basically, main tangible useful thing you get is plaing nice with namespaces -- necessary, but not much to write home about) is not news, but rather a recognized fact. But just how complicated AND verbose it is isn't obvious when you do not have write schemas. So here is the very first thing I had to do again: write a schema for single element with text as content, and a single text attribute. How much xml would that be? One or two lines?
No such luck. Unless I am mistaken, here's how to do it (adapted from Eric van der List's XML Schema book, highly recommended):
<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'> <xs:element name='price'> <xs:complexType> <xs:simpleContent> <xs:extension base='xs:int'> <xs:attribute name='currency' type='xs:string' /> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element> </xs:schema>"
God have mercy on us... this makes Java look like Forth in comparison. What were they thinking?