Uploaded image for project: 'logback'
  1. logback
  2. LOGBACK-210

Minimal XSD schema for the Logback XML configuration file

    XMLWordPrintable

Details

    • Icon: New Feature New Feature
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • None
    • logback-core
    • None

    Description

      Although it's probably impossible to have an XSD schema that has every possible configuration element,
      it's possible to provide a valid XSD that allows any element at certain places, but does have a list of the common (= minimal set) of configuration elements, such as <configuration>, <appender> and <root>.

      How to have a specific element that can have any child element?

      <!-- The element  "appender" can have any child element, for example "foo" or "bar" or "myOwnElement" -->
            <xs:element name="appender" minOccurs="0">
              <xs:annotation>
                <xs:documentation source="version">1.0.0</xs:documentation>
                <xs:documentation source="description">TODO The appender ...</xs:documentation>
              </xs:annotation>
              <xs:complexType>
                <xs:sequence>
                  <xs:any minOccurs="0" maxOccurs="unbounded" processContents="skip"/>
                </xs:sequence>
              </xs:complexType>
            </xs:element>
      

      Benefits:

      • Can be used to validate the xml in IntelliJ/Eclipse, without having to run it.
      • Code completion for XML in IntelliJ/Eclipse
      • The XSD description can explain what those "minimal" elements do. With IntelliJ (and Eclipse?) that "javadoc" pops up when writing it.
      • Can also be used by logback itself to validate the xml at runtime.

      Attachments

        Activity

          People

            logback-dev Logback dev list
            ge0ffrey Geoffrey De Smet
            Votes:
            6 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated: