On Wed, Sep 26, 2012 at 2:21 AM, Ivan Habunek <ivan.habu...@gmail.com>wrote:
> On 26 September 2012 08:12, Gary Gregory <garydgreg...@gmail.com> wrote: > > Furthermore, if we do XML, we should deliver an XML Schema. > > Having a schema is always good. But if you're tempted to do automatic > validation of config files using the schema, I suggest you don't. > > I implemented automatic XSD validation in log4php to see how it works, > but i found it too restrictive. The main problem is that it does not > allow out of order elements. Incorrect! If you want to allow: <?xml version="1.0" encoding="UTF-8"?> <Root xsi:noNamespaceSchemaLocation="Untitled1.xsd" xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance"> <B>text</B> <A>text</A> </Root> and: <?xml version="1.0" encoding="UTF-8"?> <Root xsi:noNamespaceSchemaLocation="Untitled1.xsd" xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance"> <A>text</A> <B>text</B> </Root> then just say: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:element name="Root"> <xs:annotation> <xs:documentation>Comment describing your root element</xs:documentation> </xs:annotation> <xs:complexType> <xs:all> <xs:element name="A"/> <xs:element name="B"/> </xs:all> </xs:complexType> </xs:element> </xs:schema> Gary > For example, if you define first > <appender> then <logger> node in schema, the validation will report > errors if it's the config file has them the other way around. So I > decided to remove it. > > Just my 2p. > > Regards, > Ivan > > --------------------------------------------------------------------- > To unsubscribe, e-mail: log4j-dev-unsubscr...@logging.apache.org > For additional commands, e-mail: log4j-dev-h...@logging.apache.org > > -- E-Mail: garydgreg...@gmail.com | ggreg...@apache.org JUnit in Action, 2nd Ed: <http://goog_1249600977>http://bit.ly/ECvg0 Spring Batch in Action: <http://s.apache.org/HOq>http://bit.ly/bqpbCK Blog: http://garygregory.wordpress.com Home: http://garygregory.com/ Tweet! http://twitter.com/GaryGregory