Sesat > Docs + Support > Development using the SFC > Search modes schema generator

The Search modes schema generator

To keep the modes.xml files correct we can use different schema files, and validate against them when writing the modes.xml files. In the sesat-mojo we have introdusced the searchModeSchemaGenerator which is capable of generating schema files for RelaxNG, XML Schema and DTD's.

Generating the schema files.

The use of this is done through the build script. See an example below.

pom.xml part-1
<plugin>
    <groupId>sesat</groupId>
    <artifactId>sesat-mojo</artifactId>
    <executions>
        <execution>
            <configuration>
                <outputDir>
                    src/main/conf/
                </outputDir>
                <classpaths>
                    <classpath>../query-transform-config/src/main/java/</classpath>
                    <classpath>../search-command-config/src/main/java/</classpath>
                    <classpath>../result-handler-config/src/main/java/</classpath>
                        
                    <classpath>../../query-transform-config-spi/src/main/java/</classpath>
                    <classpath>../../search-command-config-spi/src/main/java/</classpath>
                    <classpath>../../result-handler-config-spi/src/main/java/</classpath>
                </classpaths>
            </configuration>
            <phase>compile</phase>
            <goals>
                <goal>searchModesSchemaGenerator</goal>
            </goals>
        </execution>
    </executions>
</plugin>

There is two ting to note in this configuration.

The first thing is where the generated files should be placed.

<outputDir>
    src/main/conf/
</outputDir>

And the second thing is where the source files are located.

<classpaths>
    <classpath>../query-transform-config/src/main/java/</classpath>
    ....

Validating during a normal build.

This is the a snippet showing how to turn validation on.

pom.xml part-2
<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>xml-maven-plugin</artifactId>
    <executions>
        <execution>
            <phase>test</phase>
            <goals>
                <goal>validate</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <validationSets>
            <validationSet>
                <dir>.</dir>
                <includes>
                    <include>**/modes.xml</include>
                </includes>
                <excludes>
                    <exclude>**/target/**</exclude>
                </excludes>
                <validating>true</validating>
            </validationSet>
        </validationSets>
    </configuration>
</plugin>

Validating in your favorite editor.

Normally this will just work.

 © 2007-2009 Schibsted ASA
Contact us