<?xml version="1.0" encoding="UTF-8"?>
<!--
The contents of this file are subject to the terms of the Common Development
and Distribution License (the License). You may not use this file except in
compliance with the License.

You can obtain a copy of the License at http://www.netbeans.org/cddl.html
or http://www.netbeans.org/cddl.txt.

When distributing Covered Code, include this CDDL Header Notice in each file
and include the License file at http://www.netbeans.org/cddl.txt.
If applicable, add the following below the CDDL Header, with the fields
enclosed by brackets [] replaced by your own identifying information:
"Portions Copyrighted [year] [name of copyright owner]"

The Original Software is NetBeans. The Initial Developer of the Original
Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
Microsystems, Inc. All Rights Reserved.
-->
<project basedir="." default="validate" name="nbbuild/validate-project-xmls">
    <target name="init">
        <property name="nbroot" location=".."/>
        <property name="validroot" location="${nbroot}"/>
        <ant dir="${nbroot}/ant/project/eg" antfile="create-sample.xml" target="validate-compile"/>
    </target>
    <target name="find-xmls" depends="init">
        <pathconvert property="xmls" pathsep=",">
            <path>
                <fileset dir="${validroot}">
                    <include name="**/nbproject/project.xml"/>
                    <include name="**/nbproject/private/private.xml"/>
                    <exclude name="**/test/results/"/>
                    <exclude name="**/test/work/"/>
                    <exclude name="xtest/instance/results/"/>
                    <exclude name="libs/www/template/"/>
                </fileset>
            </path>
        </pathconvert>
    </target>
    <target name="find-schemas" depends="init">
        <pathconvert property="schemas" pathsep=",">
            <path>
                <fileset dir="${nbroot}">
                    <include name="ant/project/src/**/*.xsd"/>
                    <include name="ant/freeform/src/**/*.xsd"/>
                    <include name="apisupport/project/src/**/*.xsd"/>
                    <include name="java/j2seproject/src/**/*.xsd"/>
                    <include name="j2ee/earproject/src/**/*.xsd"/>
                    <include name="j2ee/ejbjarproject/src/**/*.xsd"/>
                    <include name="web/project/src/**/*.xsd"/>
                </fileset>
            </path>
        </pathconvert>
    </target>
    <target name="validate" depends="init,find-xmls,find-schemas" description="Ensure that all project.xml files are valid acc. to schema.">
        <java classname="ValidateAllBySchema" failonerror="true" fork="true">
            <classpath>
                <pathelement location="${nbroot}/ant/project/eg"/>
                <fileset dir="${nbroot}/libs/external">
                    <include name="xerces*.jar"/>
                    <include name="xml-commons-dom-ranges*.jar"/>
                </fileset>
            </classpath>
            <arg value="${xmls}"/>
            <arg value="${schemas}"/>
        </java>
    </target>
    <!-- XXX the following should work, without requiring ValidateAllBySchema.java, if the external-schemaLocation is completed but inexplicably does not:
         /space/src/nb_all/ant/docs/nbproject/project.xml:14:55: cvc-elt.1: Cannot find the declaration of element 'project'.
    <property name="nbroot" location=".."/>
    <target name="validate" description="Ensure that all project.xml files are valid acc. to schema.">
        <xmlvalidate lenient="false" warn="true" failonerror="false">
            <fileset dir="${nbroot}">
                <include name="**/nbproject/project.xml"/>
                <include name="**/nbproject/private/private.xml"/>
                <exclude name="**/test/results/"/>
            </fileset>
            <attribute name="http://apache.org/xml/features/validation/schema" value="true"/>
            <attribute name="http://xml.org/sax/features/namespaces" value="true"/>
            <property name="http://apache.org/xml/properties/schema/external-schemaLocation" value="http://www.netbeans.org/ns/project/1 file:${nbroot}/ant/project/src/org/netbeans/modules/project/ant/project.xsd [etc.]"/>
        </xmlvalidate>
    </target>
    -->
</project>
