cdm/src/main/java/ucar/nc2/ncml/NcMLGWriter.java
private Element makeVariable( VariableDS var) {

    Element varElem = new Element("variable", thredds.client.catalog.Catalog.ncmlNS);

    varElem.setAttribute("name", var.getFullName());

    StringBuffer buff = new StringBuffer();
    List dims = var.getDimensions();
    for (int i=0; i<dims.size(); i++) {
      Dimension dim = (Dimension) dims.get(i);
      if (i > 0) buff.append( " ");
      buff.append( dim.getShortName());
    }
    if (buff.length() > 0)
      varElem.setAttribute("shape", buff.toString());

    DataType dt = var.getDataType();
    if (dt != null)
      varElem.setAttribute("type", dt.toString());

        // attributes
    for (Attribute att : var.getAttributes()) {
      varElem.addContent(makeAttribute(att, "attribute"));
    }

    if (var.isMetadata())
      varElem.addContent( makeValues( var));

    // coordinate systems
    List csys = var.getCoordinateSystems();
    if (csys.size() > 0) {
      buff.setLength(0);
      for (int i=0; i<csys.size(); i++) {
        CoordinateSystem cs = (CoordinateSystem) csys.get(i);
        if (i>0) buff.append(" ");
        buff.append( cs.getName());
      }
      varElem.setAttribute("coordinateSystems", buff.toString());
    }

    return varElem;
  }
private Element makeVariable( VariableDS var) {

    Element varElem = new Element("variable", thredds.client.catalog.Catalog.ncmlNS);

    varElem.setAttribute("name", var.getFullName());

    StringBuffer buff = new StringBuffer();
    List dims = var.getDimensions();
    for (int i=0; i<dims.size(); i++) {
      Dimension dim = (Dimension) dims.get(i);
      if (i > 0) buff.append( " ");
      buff.append( dim.getShortName());
    }
    if (buff.length() > 0)
      varElem.setAttribute("shape", buff.toString());

    DataType dt = var.getDataType();
    if (dt != null)
      varElem.setAttribute("type", dt.toString());

        // attributes
    for (Attribute att : var.getAttributes()) {
      varElem.addContent(makeAttribute(att, "attribute"));
    }

    if (var.isMetadata())
      varElem.addContent( makeValues( var));

    // coordinate systems
    List csys = var.getCoordinateSystems();
    if (csys.size() > 0) {
      buff.setLength(0);
      for (int i=0; i<csys.size(); i++) {
        CoordinateSystem cs = (CoordinateSystem) csys.get(i);
        if (i>0) buff.append(" ");
        buff.append( cs.getName());
      }
      varElem.setAttribute("coordinateSystems", buff.toString());
    }

    return varElem;
  }
/* private Element makeReferenceSys( ReferenceSystem referenceSystem) {
Element elem = new Element("referenceCoordinateSystem", thredds.client.catalog.Catalog.ncmlNS);
elem.setAttribute("name", referenceSystem.getName());
elem.setAttribute("authority", referenceSystem.getAuthority());
if (referenceSystem.getReferenceType() != null)
elem.setAttribute("type", referenceSystem.getReferenceType().toString());

ArrayList params = referenceSystem.getParameters();
for (int i=0; i<params.size(); i++) {
ucar.nc2.Attribute att = (ucar.nc2.Attribute) params.get(i);
elem.addContent( makeAttribute(att, "parameter"));
}
return elem;
}