<?xml version="1.0"?>
<!--

    Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved.

    This program and the accompanying materials are made available under the
    terms of the Eclipse Distribution License v. 1.0, which is available at
    http://www.eclipse.org/org/documents/edl-v10.php.

    SPDX-License-Identifier: BSD-3-Clause

-->

<grammar
 xmlns="http://relaxng.org/ns/structure/1.0"
 xmlns:r="http://relaxng.org/ns/structure/1.0"
 xmlns:a="http://relaxng.org/ns/annotation/1.0"
 xmlns:ref="urn:crossreference"
 xmlns:c="http://www.xml.gr.jp/xmlns/relaxngcc"
 c:runtime-type="com.sun.tools.jxc.NGCCRuntimeEx"
 datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"
 c:package="com.sun.tools.jxc.gen.config">


<start c:class="Config" c:access="public">

 <c:java-import>
    import java.util.List;
    import java.util.ArrayList;
    import java.io.File;
 </c:java-import>

<c:java-body>
   private File baseDir;
   private Classes classes;
   private List schema = new ArrayList();
   public Classes getClasses() { return this.classes;}
   public File getBaseDir() { return baseDir;}
   public List getSchema() { return this.schema;}
</c:java-body>

  <element name="config">
     <attribute name="baseDir">
        bd = <data type="string"/>
        baseDir = $runtime.getBaseDir(bd);
     </attribute>
     <ref name="Classes" c:alias="classes"/>
     <zeroOrMore>
        <ref name="Schema" c:alias="_schema" />(baseDir);
        this.schema.add (_schema);
     </zeroOrMore>
     </element>
  </start>


   <define name="Classes" c:access="public">
   <c:java-import>
    import java.util.List;
    import java.util.ArrayList;
    </c:java-import>
     <c:java-body>
       private List includes = new ArrayList();
       public List getIncludes() { return $runtime.getIncludePatterns(this.includes);}
       private List excludes = new ArrayList();
       public List getExcludes() { return $runtime.getExcludePatterns(this.excludes);}
       </c:java-body>
     <element name="classes">

        <element name="includes">
            <list>
               <oneOrMore>
                <data type="string" c:alias="include_content"/>
                <c:java> this.includes.add(include_content); </c:java>
               </oneOrMore>
            </list>

         </element>
        <optional>
        <element name="excludes">
            <list>
               <zeroOrMore>
                <data type="string" c:alias="exclude_content"/>
                <c:java> this.excludes.add(exclude_content); </c:java>
               </zeroOrMore>
            </list>

         </element>
        </optional>
     </element>
    </define>


   <define name="Schema" c:access="public" c:params="File baseDir">
     <c:java-import>
       import java.io.File;
     </c:java-import>
     <c:java-body>
       private File location;
       private String namespace;
       public String getNamespace() { return this.namespace;}
       public File getLocation() { return this.location;}
     </c:java-body>
     <element name="schema">
       <optional>
         <attribute name="namespace">
           namespace = <data type="string" />
         </attribute>
       </optional>

       <optional>
         <attribute name="location">
           loc = <data type="string" />
           location = new File(baseDir,loc);
         </attribute>
       </optional>
     </element>
  </define>
</grammar>
