Skip to content

need ways to generate both xs:sequence and xs:attribute into a same xs:complexType, for maven #482

Open
@XenoAmess

Description

@XenoAmess

@slachiewicz
Hi.
In maven we need such grammar like:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>acm_test</artifactId>
    <version>1.0-SNAPSHOT</version>
    <name>acm_test</name>

    <properties>
        <maven.compiler.source>23</maven.compiler.source>
        <maven.compiler.target>23</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-plugin-plugin</artifactId>
                <configuration>
                    <goalPrefix combine.self="override"/>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>2.5.1</version>
                <configuration combine.self="override">
                    <goals>deploy</goals>
                    <localCheckout>true</localCheckout>
                    <mavenExecutorId>forked-path</mavenExecutorId>
                    <tagNameFormat>${reactor.name}-@{project.version}</tagNameFormat>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.maven.scm</groupId>
                        <artifactId>maven-scm-provider-hg</artifactId>
                        <version>1.9.2</version>
                    </dependency>
                    <dependency>
                        <groupId>org.apache.maven.scm</groupId>
                        <artifactId>maven-scm-provider-gitexe</artifactId>
                        <version>1.9.2</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>

</project>

please focuse on the <configuration combine.self="override"> part.

so we need the output xsd be:

    <xs:complexType>
      <xs:sequence>
        <xs:any minOccurs="0" maxOccurs="unbounded" processContents="skip"/>
      </xs:sequence>
      <xs:attribute name="combine.children" type="xs:string" use="optional">
  <xs:annotation>
    <xs:documentation source="version">4.0.0+</xs:documentation>
    <xs:documentation source="description">
        
        {@code combine.children}: available values are {@code merge} (default) and {@code append}.
        @see &amp;lt;a href=&amp;quot;https://maven.apache.org/pom.html#Plugins&amp;quot;&amp;gt;POM Reference documentation&amp;lt;/a&amp;gt;
        @see &amp;lt;a href=&amp;quot;https://codehaus-plexus.github.io/plexus-utils/apidocs/org/codehaus/plexus/util/xml/Xpp3DomUtils.html&amp;quot;&amp;gt;Xpp3DomUtils&amp;lt;/a&amp;gt;
        
      </xs:documentation>
  </xs:annotation>
</xs:attribute>
      <xs:attribute name="combine.self" type="xs:string" use="optional">
        <xs:annotation>
          <xs:documentation source="version">4.0.0+</xs:documentation>
          <xs:documentation source="description">
                  
                  {@code combine.self}: available values are {@code merge} (default) and {@code override}.
                  @see &amp;lt;a href=&amp;quot;https://maven.apache.org/pom.html#Plugins&amp;quot;&amp;gt;POM Reference documentation&amp;lt;/a&amp;gt;
                  @see &amp;lt;a href=&amp;quot;https://codehaus-plexus.github.io/plexus-utils/apidocs/org/codehaus/plexus/util/xml/Xpp3DomUtils.html&amp;quot;&amp;gt;Xpp3DomUtils&amp;lt;/a&amp;gt;
                  
                </xs:documentation>
        </xs:annotation>
      </xs:attribute>
    </xs:complexType>

though actually there be no ways for us to do it in modello now, as far as I get from modello sources codes.
so I want to modify some grammar of modello to add such feature.

one way be allow <fields> in <field>, and there be of course other ways, but I want to know about your ideas first.

thought1: <fields> in <field> approach?

    <class>
      <name>ConfigurationContainer</name>
      <version>4.0.0+</version>
      <description>Contains the configuration information of the container like Plugin.</description>
      <fields>
        <field>
          <name>inherited</name>
          <version>4.0.0+</version>
          <description>
            Whether any configuration should be propagated to child POMs. Note: While the type
            of this field is {@code String} for technical reasons, the semantic type is actually
            {@code Boolean}. Default value is {@code true}.
          </description>
          <type>String</type>
        </field>
        <field>
          <description>
            <![CDATA[
            <p>The configuration as DOM object.</p>
            <p>By default, every element content is trimmed, but starting with Maven 3.1.0, you can add
            {@code xml:space="preserve"} to elements you want to preserve whitespace.</p>
            <p>You can control how child POMs inherit configuration from parent POMs by adding {@code combine.children}
            or {@code combine.self} attributes to the children of the configuration element:</p>
            <ul>
            <li>{@code combine.children}: available values are {@code merge} (default) and {@code append},</li>
            <li>{@code combine.self}: available values are {@code merge} (default) and {@code override}.</li>
            </ul>

            @see <a href="https://maven.apache.org/pom.html#Plugins">POM Reference documentation</a>
            @see <a href="https://codehaus-plexus.github.io/plexus-utils/apidocs/org/codehaus/plexus/util/xml/Xpp3DomUtils.html">Xpp3DomUtils</a>
            ]]>
          </description>
          <name>configuration</name>
          <type>DOM</type>
          <fields>
            <field xml.attribute="true" xml.tagName="combine.children">
                <name>configurationCombineChildren</name>
                <version>4.0.0+</version>
                <description>
                  <![CDATA[
                  {@code combine.children}: available values are {@code merge} (default) and {@code append}.
                  @see &lt;a href=&quot;https://maven.apache.org/pom.html#Plugins&quot;&gt;POM Reference documentation&lt;/a&gt;
                  @see &lt;a href=&quot;https://codehaus-plexus.github.io/plexus-utils/apidocs/org/codehaus/plexus/util/xml/Xpp3DomUtils.html&quot;&gt;Xpp3DomUtils&lt;/a&gt;
                  ]]>
                </description>
                <type>String</type>
              </field>
              <field xml.attribute="true" xml.tagName="combine.self">
                <name>configurationCombineSelf</name>
                <version>4.0.0+</version>
                <description>
                  <![CDATA[
                  {@code combine.self}: available values are {@code merge} (default) and {@code override}.
                  @see &lt;a href=&quot;https://maven.apache.org/pom.html#Plugins&quot;&gt;POM Reference documentation&lt;/a&gt;
                  @see &lt;a href=&quot;https://codehaus-plexus.github.io/plexus-utils/apidocs/org/codehaus/plexus/util/xml/Xpp3DomUtils.html&quot;&gt;Xpp3DomUtils&lt;/a&gt;
                  ]]>
                </description>
                <type>String</type>
              </field>
          </fields>
        </field>
      </fields>
      <codeSegments>
        <codeSegment>
          <version>4.0.0+</version>
          <code>
            <![CDATA[
    public boolean isInherited() {
        return ( getInherited() != null ) ? Boolean.parseBoolean( getInherited() ) : true;
    }

            ]]>
          </code>
        </codeSegment>
        <codeSegment>
          <version>4.0.0/4.0.99</version>
          <code>
            <![CDATA[
    @Deprecated
    public void unsetInheritanceApplied() {
    }

            ]]>
          </code>
        </codeSegment>
      </codeSegments>
    </class>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions