legacy/src/main/java/ucar/nc2/dt/point/StationObsDatasetInfo.java
public Document makeStationObsDatasetDocument() {
    Element rootElem = new Element("stationObsDataset");
    Document doc = new Document(rootElem);
    rootElem.setAttribute("location", sobs.getLocationURI());
    if (null != path)
      rootElem.setAttribute("path", path);

    /* dimensions
    List dims = getDimensions(sobs);
    for (int j = 0; j < dims.size(); j++) {
      Dimension dim = (Dimension) dims.get(j);
      rootElem.addContent(ucar.nc2.ncml.NcMLWriter.writeDimension(dim, null));
    } */

    /* coordinate axes
    List coordAxes = getCoordAxes(sobs);
    for (int i = 0; i < coordAxes.size(); i++) {
      CoordinateAxis axis = (CoordinateAxis) coordAxes.get(i);
      rootElem.addContent(writeAxis(axis));
    } */

    // grids
    List vars = sobs.getDataVariables();
    Collections.sort(vars);
    for (int i = 0; i < vars.size(); i++) {
      VariableSimpleIF v = (VariableSimpleIF) vars.get(i);
      rootElem.addContent(writeVariable(v));
    }

    /* global attributes
    Iterator atts = sobs.getGlobalAttributes().iterator();
    while (atts.hasNext()) {
      ucar.nc2.Attribute att = (ucar.nc2.Attribute) atts.next();
      rootElem.addContent(ucar.nc2.ncml.NcMLWriter.writeAttribute(att, "attribute", null));
    } */

    // add lat/lon bounding box
    LatLonRect bb = sobs.getBoundingBox();
    if (bb != null)
      rootElem.addContent( writeBoundingBox( bb));

    // add date range
    Date start  = sobs.getStartDate();
    Date end  = sobs.getEndDate();
    if ((start != null) && (end != null)) {
      DateFormatter format = new DateFormatter();
      Element dateRange = new Element("TimeSpan");
      dateRange.addContent(new Element("begin").addContent(format.toDateTimeStringISO(start)));
      dateRange.addContent(new Element("end").addContent(format.toDateTimeStringISO(end)));
      rootElem.addContent( dateRange);
    }

    // add accept list
    Element elem = new Element("AcceptList");
    elem.addContent(new Element("accept").addContent("raw"));
    elem.addContent(new Element("accept").addContent("xml"));
    elem.addContent(new Element("accept").addContent("csv"));
    elem.addContent(new Element("accept").addContent("netcdf"));
    elem.addContent(new Element("accept").addContent("netcdfStream"));
    rootElem.addContent(elem);

    return doc;
  }
public Document makeStationObsDatasetDocument() {
    Element rootElem = new Element("stationObsDataset");
    Document doc = new Document(rootElem);
    rootElem.setAttribute("location", sobs.getLocationURI());
    if (null != path)
      rootElem.setAttribute("path", path);

    /* dimensions
    List dims = getDimensions(sobs);
    for (int j = 0; j < dims.size(); j++) {
      Dimension dim = (Dimension) dims.get(j);
      rootElem.addContent(ucar.nc2.ncml.NcMLWriter.writeDimension(dim, null));
    } */

    /* coordinate axes
    List coordAxes = getCoordAxes(sobs);
    for (int i = 0; i < coordAxes.size(); i++) {
      CoordinateAxis axis = (CoordinateAxis) coordAxes.get(i);
      rootElem.addContent(writeAxis(axis));
    } */

    // grids
    List vars = sobs.getDataVariables();
    Collections.sort(vars);
    for (int i = 0; i < vars.size(); i++) {
      VariableSimpleIF v = (VariableSimpleIF) vars.get(i);
      rootElem.addContent(writeVariable(v));
    }

    /* global attributes
    Iterator atts = sobs.getGlobalAttributes().iterator();
    while (atts.hasNext()) {
      ucar.nc2.Attribute att = (ucar.nc2.Attribute) atts.next();
      rootElem.addContent(ucar.nc2.ncml.NcMLWriter.writeAttribute(att, "attribute", null));
    } */

    // add lat/lon bounding box
    LatLonRect bb = sobs.getBoundingBox();
    if (bb != null)
      rootElem.addContent( writeBoundingBox( bb));

    // add date range
    Date start  = sobs.getStartDate();
    Date end  = sobs.getEndDate();
    if ((start != null) && (end != null)) {
      DateFormatter format = new DateFormatter();
      Element dateRange = new Element("TimeSpan");
      dateRange.addContent(new Element("begin").addContent(format.toDateTimeStringISO(start)));
      dateRange.addContent(new Element("end").addContent(format.toDateTimeStringISO(end)));
      rootElem.addContent( dateRange);
    }

    // add accept list
    Element elem = new Element("AcceptList");
    elem.addContent(new Element("accept").addContent("raw"));
    elem.addContent(new Element("accept").addContent("xml"));
    elem.addContent(new Element("accept").addContent("csv"));
    elem.addContent(new Element("accept").addContent("netcdf"));
    elem.addContent(new Element("accept").addContent("netcdfStream"));
    rootElem.addContent(elem);

    return doc;
  }
public Document makeStationObsDatasetDocument ( ) { Element rootElem = new Element ( "stationObsDataset" ) ; Document doc = new Document ( rootElem ) ; rootElem . setAttribute ( "location" , sobs . getLocationURI ( ) ) ; if ( null != path ) rootElem . setAttribute ( "path" , path ) ; /* dimensions
    List dims = getDimensions(sobs);
    for (int j = 0; j < dims.size(); j++) {
      Dimension dim = (Dimension) dims.get(j);
      rootElem.addContent(ucar.nc2.ncml.NcMLWriter.writeDimension(dim, null));
    } */ /* coordinate axes
    List coordAxes = getCoordAxes(sobs);
    for (int i = 0; i < coordAxes.size(); i++) {
      CoordinateAxis axis = (CoordinateAxis) coordAxes.get(i);
      rootElem.addContent(writeAxis(axis));
    } */ // grids List vars = sobs . getDataVariables ( ) ; Collections . sort ( vars ) ; for ( int i = 0 ; i < vars . size ( ) ; i ++ ) { VariableSimpleIF v = ( VariableSimpleIF ) vars . get ( i ) ; rootElem . addContent ( writeVariable ( v ) ) ; } /* global attributes
    Iterator atts = sobs.getGlobalAttributes().iterator();
    while (atts.hasNext()) {
      ucar.nc2.Attribute att = (ucar.nc2.Attribute) atts.next();
      rootElem.addContent(ucar.nc2.ncml.NcMLWriter.writeAttribute(att, "attribute", null));
    } */ // add lat/lon bounding box LatLonRect bb = sobs . getBoundingBox ( ) ; if ( bb != null ) rootElem . addContent ( writeBoundingBox ( bb ) ) ; // add date range Date start = sobs . getStartDate ( ) ; Date end = sobs . getEndDate ( ) ; if ( ( start != null ) && ( end != null ) ) { DateFormatter format = new DateFormatter ( ) ; Element dateRange = new Element ( "TimeSpan" ) ; dateRange . addContent ( new Element ( "begin" ) . addContent ( format . toDateTimeStringISO ( start ) ) ) ; dateRange . addContent ( new Element ( "end" ) . addContent ( format . toDateTimeStringISO ( end ) ) ) ; rootElem . addContent ( dateRange ) ; } // add accept list Element elem = new Element ( "AcceptList" ) ; elem . addContent ( new Element ( "accept" ) . addContent ( "raw" ) ) ; elem . addContent ( new Element ( "accept" ) . addContent ( "xml" ) ) ; elem . addContent ( new Element ( "accept" ) . addContent ( "csv" ) ) ; elem . addContent ( new Element ( "accept" ) . addContent ( "netcdf" ) ) ; elem . addContent ( new Element ( "accept" ) . addContent ( "netcdfStream" ) ) ; rootElem . addContent ( elem ) ; return doc ; }
Create an XML document from this info
Create an XML document from this info