opendap/src/main/java/opendap/dap/parsers/DDSXMLParser.java
private void parseArray(Element ArrayElement, DArray da, String indent)
            throws DASException, NoSuchTypeException, BadSemanticsException {

        int countTemplateVars = 0;
        int numDims = 0;


      for (Element e : ArrayElement.getChildren()) {

        if (_Debug) System.out.println(indent + "Working on Array element: " + e.getName());

        // Is this element an Attribute of the Array?
        if (e.getName().equals("Attribute")) {
          //Then ignore it!
        }
        // Is this element an Attribute of the Alias?
        else if (e.getName().equals("Alias")) {
          //Then ignore it!
        }
        // Is this element an array dimension?
        else if (e.getName().equals("dimension")) {

          // Then count it,
          numDims++;

          // And now let's add it to the array...

          // Array dimension are not required to have names, so
          // the schema does not enforce the use of the name attribute.

          // try to get the dimension's name, and use it id it's there.
          String name = null;
          Attribute nameAttr = e.getAttribute("name");

          if (nameAttr != null)
            name = nameAttr.getValue();

          // The presence of the 'size' attribute is enforeced by the schema.
          // get it, parse it, use it.
          int size = Integer.parseInt(e.getAttribute("size").getValue());

          // add the dimension to the array.
          da.appendDim(size, (name));
        } else { // otherwise, it must be THE template element.

          // Just to make sure the schema validation didn't fail (because
          // I am basically paranoid about software) count the number of
          // template candidates we find and throw an Exception later
          // if there was more than one.
          countTemplateVars++;

          // The template element is just another BaseType
          // derived element. So, let's go build it!
          BaseType template = buildArrayTemplate(e, indent);

          // Oddly, in the OPeNDAP implementation of Array, the Array variable
          // takes it's name from it's (internal) template variable. This
          // is probably an artifact of the original DDSParser.

          // So, set the name of the template variable to the name of the Array.
          template.setClearName(da.getClearName());

          // Add the template variable to the Array
          da.addVariable(template);

        }
      }

        if (_Debug) {
            System.out.println(indent + "Built Array: ");
            da.printDecl(System.out, indent);
            System.out.println(indent + "dimensions: " + numDims + "  templates: " + countTemplateVars);
        }


        if (countTemplateVars != 1) {
            throw new NoSuchTypeException("ONLY ONE (1) TEMPLATE VARIABLE ALLOWED PER ARRAY!");
        }

    }
private void parseArray(Element ArrayElement, DArray da, String indent)
            throws DASException, NoSuchTypeException, BadSemanticsException {

        int countTemplateVars = 0;
        int numDims = 0;


      for (Element e : ArrayElement.getChildren()) {

        if (_Debug) System.out.println(indent + "Working on Array element: " + e.getName());

        // Is this element an Attribute of the Array?
        if (e.getName().equals("Attribute")) {
          //Then ignore it!
        }
        // Is this element an Attribute of the Alias?
        else if (e.getName().equals("Alias")) {
          //Then ignore it!
        }
        // Is this element an array dimension?
        else if (e.getName().equals("dimension")) {

          // Then count it,
          numDims++;

          // And now let's add it to the array...

          // Array dimension are not required to have names, so
          // the schema does not enforce the use of the name attribute.

          // try to get the dimension's name, and use it id it's there.
          String name = null;
          Attribute nameAttr = e.getAttribute("name");

          if (nameAttr != null)
            name = nameAttr.getValue();

          // The presence of the 'size' attribute is enforeced by the schema.
          // get it, parse it, use it.
          int size = Integer.parseInt(e.getAttribute("size").getValue());

          // add the dimension to the array.
          da.appendDim(size, (name));
        } else { // otherwise, it must be THE template element.

          // Just to make sure the schema validation didn't fail (because
          // I am basically paranoid about software) count the number of
          // template candidates we find and throw an Exception later
          // if there was more than one.
          countTemplateVars++;

          // The template element is just another BaseType
          // derived element. So, let's go build it!
          BaseType template = buildArrayTemplate(e, indent);

          // Oddly, in the OPeNDAP implementation of Array, the Array variable
          // takes it's name from it's (internal) template variable. This
          // is probably an artifact of the original DDSParser.

          // So, set the name of the template variable to the name of the Array.
          template.setClearName(da.getClearName());

          // Add the template variable to the Array
          da.addVariable(template);

        }
      }

        if (_Debug) {
            System.out.println(indent + "Built Array: ");
            da.printDecl(System.out, indent);
            System.out.println(indent + "dimensions: " + numDims + "  templates: " + countTemplateVars);
        }


        if (countTemplateVars != 1) {
            throw new NoSuchTypeException("ONLY ONE (1) TEMPLATE VARIABLE ALLOWED PER ARRAY!");
        }

    }
Arrays have special parsing need as their syntax is different from
that of a typical BaseType derived type or a container type. The
array is based on a template variable that can have ANY structure
that can be represented by the OPeNDAP data model. With the exception
of (you knew this was comming, right?) of other arrays. IE You can't
have Arrays of Arrays. This caveat is enforced by the XML schema.