opendap/src/main/java/opendap/dap/parsers/DDSXMLParser.java
private void parseGrid(Element gridElement, String indent)
            throws DASException, NoSuchTypeException, BadSemanticsException {

        parseLevel++;

        // Grab the parent object (which better be a Grid!)
        // just to elminate the hassle of casting everytime...
        DGrid myGrid = (DGrid) parentDC;

        if (_Debug) {
            System.out.println("Parsing Grid Element: " + gridElement);
            System.out.println("Grid Elements: ");
            //showXMLElement(gridElement, indent);
          for (Element element : gridElement.getChildren()) System.out.println(element);
        }

        // Get and parse the grid's Array element.
        String eName = "Array";
        if (_Debug) {
            System.out.println("Parsing Array element.");
            System.out.println("Asking for element: '" + eName + "' in namespace: '" + opendapNameSpace + "'");
        }
        Element arrayElement = gridElement.getChild(eName, opendapNameSpace);
        if (_Debug) System.out.println("Got Array element: " + arrayElement);
        DArray gridArray = (DArray) newBaseType(arrayElement);
        parseArray(arrayElement, gridArray, indent + "    ");

        // Add it to the Grid
        myGrid.addVariable(gridArray, DGrid.ARRAY);

        // Get the Map elements
        eName = "Map";
        if (_Debug) {
            System.out.println("Parsing Map elements.");
            System.out.println("Asking for element: '" + eName + "' in namespace: '" + opendapNameSpace + "'");
        }
        List<Element> mapElements = gridElement.getChildren("Map", opendapNameSpace);

        // Make sure the number of Map elements matches the dimension of the Grid Array.
        if (mapElements.size() != gridArray.numDimensions())
            throw new BadSemanticsException("Error in Grid syntax: " +
                    "The number of Map arrays must " +
                    "equal the number of dimensions " +
                    "of the data array.");

        // Parse each Map element and poke it into the Grid.
      for (Element mapElement : mapElements) {
        DArray thisMap = (DArray) newBaseType(mapElement);
        parseArray(mapElement, thisMap, indent + "    ");

        if (thisMap.numDimensions() != 1)
          throw new BadSemanticsException("Error in Grid syntax: " +
                  "Maps may have only one dimension.");

        myGrid.addVariable(thisMap, DGrid.MAPS);

      }

        parseLevel--;

    }
private void parseGrid(Element gridElement, String indent)
            throws DASException, NoSuchTypeException, BadSemanticsException {

        parseLevel++;

        // Grab the parent object (which better be a Grid!)
        // just to elminate the hassle of casting everytime...
        DGrid myGrid = (DGrid) parentDC;

        if (_Debug) {
            System.out.println("Parsing Grid Element: " + gridElement);
            System.out.println("Grid Elements: ");
            //showXMLElement(gridElement, indent);
          for (Element element : gridElement.getChildren()) System.out.println(element);
        }

        // Get and parse the grid's Array element.
        String eName = "Array";
        if (_Debug) {
            System.out.println("Parsing Array element.");
            System.out.println("Asking for element: '" + eName + "' in namespace: '" + opendapNameSpace + "'");
        }
        Element arrayElement = gridElement.getChild(eName, opendapNameSpace);
        if (_Debug) System.out.println("Got Array element: " + arrayElement);
        DArray gridArray = (DArray) newBaseType(arrayElement);
        parseArray(arrayElement, gridArray, indent + "    ");

        // Add it to the Grid
        myGrid.addVariable(gridArray, DGrid.ARRAY);

        // Get the Map elements
        eName = "Map";
        if (_Debug) {
            System.out.println("Parsing Map elements.");
            System.out.println("Asking for element: '" + eName + "' in namespace: '" + opendapNameSpace + "'");
        }
        List<Element> mapElements = gridElement.getChildren("Map", opendapNameSpace);

        // Make sure the number of Map elements matches the dimension of the Grid Array.
        if (mapElements.size() != gridArray.numDimensions())
            throw new BadSemanticsException("Error in Grid syntax: " +
                    "The number of Map arrays must " +
                    "equal the number of dimensions " +
                    "of the data array.");

        // Parse each Map element and poke it into the Grid.
      for (Element mapElement : mapElements) {
        DArray thisMap = (DArray) newBaseType(mapElement);
        parseArray(mapElement, thisMap, indent + "    ");

        if (thisMap.numDimensions() != 1)
          throw new BadSemanticsException("Error in Grid syntax: " +
                  "Maps may have only one dimension.");

        myGrid.addVariable(thisMap, DGrid.MAPS);

      }

        parseLevel--;

    }
private void parseGrid ( Element gridElement , String indent ) throws DASException , NoSuchTypeException , BadSemanticsException { parseLevel ++ ; // Grab the parent object (which better be a Grid!)
 // just to elminate the hassle of casting everytime...
 DGrid myGrid = ( DGrid ) parentDC ; if ( _Debug ) { System . out . println ( "Parsing Grid Element: " + gridElement ) ; System . out . println ( "Grid Elements: " ) ; //showXMLElement(gridElement, indent);
 for ( Element element : gridElement . getChildren ( ) ) System . out . println ( element ) ; } // Get and parse the grid's Array element.
 String eName = "Array" ; if ( _Debug ) { System . out . println ( "Parsing Array element." ) ; System . out . println ( "Asking for element: '" + eName + "' in namespace: '" + opendapNameSpace + "'" ) ; } Element arrayElement = gridElement . getChild ( eName , opendapNameSpace ) ; if ( _Debug ) System . out . println ( "Got Array element: " + arrayElement ) ; DArray gridArray = ( DArray ) newBaseType ( arrayElement ) ; parseArray ( arrayElement , gridArray , indent + "    " ) ; // Add it to the Grid
 myGrid . addVariable ( gridArray , DGrid . ARRAY ) ; // Get the Map elements
 eName = "Map" ; if ( _Debug ) { System . out . println ( "Parsing Map elements." ) ; System . out . println ( "Asking for element: '" + eName + "' in namespace: '" + opendapNameSpace + "'" ) ; } List < Element > mapElements = gridElement . getChildren ( "Map" , opendapNameSpace ) ; // Make sure the number of Map elements matches the dimension of the Grid Array.
 if ( mapElements . size ( ) != gridArray . numDimensions ( ) ) throw new BadSemanticsException ( "Error in Grid syntax: " + "The number of Map arrays must " + "equal the number of dimensions " + "of the data array." ) ; // Parse each Map element and poke it into the Grid.
 for ( Element mapElement : mapElements ) { DArray thisMap = ( DArray ) newBaseType ( mapElement ) ; parseArray ( mapElement , thisMap , indent + "    " ) ; if ( thisMap . numDimensions ( ) != 1 ) throw new BadSemanticsException ( "Error in Grid syntax: " + "Maps may have only one dimension." ) ; myGrid . addVariable ( thisMap , DGrid . MAPS ) ; } parseLevel -- ; }
Grids are unusual examples of DConstructor and require special
handling when parsing.
Grids are unusual examples of DConstructor and require special handling when parsing .