Java Code Examples for org.jdom2.JDOMException#getMessage()

The following examples show how to use org.jdom2.JDOMException#getMessage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NcmlCollectionReader.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Read an NcML file from a URL location, and construct a NcmlCollectionReader from its scan or scanFmrc element.
 *
 * @param ncmlLocation the URL location string of the NcML document
 * @param errlog put error messages here
 * @return the resulting NetcdfDataset
 * @throws IOException on read error, or bad referencedDatasetUri URI
 */
public static NcmlCollectionReader open(String ncmlLocation, Formatter errlog) throws IOException {
  if (!ncmlLocation.startsWith("http:") && !ncmlLocation.startsWith("file:"))
    ncmlLocation = "file:" + ncmlLocation;

  URL url = new URL(ncmlLocation);

  org.jdom2.Document doc;
  try {
    SAXBuilder builder = new SAXBuilder();
    if (debugURL)
      System.out.println(" NetcdfDataset URL = <" + url + ">");
    doc = builder.build(url);
  } catch (JDOMException e) {
    throw new IOException(e.getMessage());
  }
  if (debugXML)
    System.out.println(" SAXBuilder done");

  return readXML(doc, errlog, ncmlLocation);
}
 
Example 2
Source File: NcmlCollectionReader.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Read an NcML file from a String, and construct a NcmlCollectionReader from its scan or scanFmrc element.
 *
 * @param ncmlString the NcML to construct the reader from
 * @param errlog put error messages here
 * @return the resulting NetcdfDataset
 * @throws IOException on read error, or bad referencedDatasetUri URI
 */
public static NcmlCollectionReader readNcML(String ncmlString, Formatter errlog) throws IOException {
  StringReader reader = new StringReader(ncmlString);

  org.jdom2.Document doc;
  try {
    SAXBuilder builder = new SAXBuilder();
    if (debugURL)
      System.out.println(" NetcdfDataset NcML String = <" + ncmlString + ">");
    doc = builder.build(new StringReader(ncmlString));
  } catch (JDOMException e) {
    throw new IOException(e.getMessage());
  }
  if (debugXML)
    System.out.println(" SAXBuilder done");

  return readXML(doc, errlog, null);
}
 
Example 3
Source File: NcMLReader.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Use NCML to modify the dataset, getting NcML from a URL
 *
 * @param ncDataset modify this dataset
 * @param ncmlLocation URL location of NcML
 * @param cancelTask allow user to cancel task; may be null
 * @throws IOException on read error
 */
public static void wrapNcML(NetcdfDataset ncDataset, String ncmlLocation, CancelTask cancelTask) throws IOException {
  org.jdom2.Document doc;
  try {
    SAXBuilder builder = new SAXBuilder();
    if (debugURL)
      System.out.println(" NetcdfDataset URL = <" + ncmlLocation + ">");
    doc = builder.build(ncmlLocation);
  } catch (JDOMException e) {
    throw new IOException(e.getMessage());
  }
  if (debugXML)
    System.out.println(" SAXBuilder done");

  if (showParsedXML) {
    XMLOutputter xmlOut = new XMLOutputter();
    System.out.println("*** NetcdfDataset/showParsedXML = \n" + xmlOut.outputString(doc) + "\n*******");
  }

  Element netcdfElem = doc.getRootElement();

  NcMLReader reader = new NcMLReader();
  reader.readNetcdf(ncmlLocation, ncDataset, ncDataset, netcdfElem, cancelTask);
  if (debugOpen)
    System.out.println("***NcMLReader.wrapNcML result= \n" + ncDataset);
}
 
Example 4
Source File: NcMLReader.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Read NcML doc from an InputStream, and construct a NetcdfDataset.
 *
 * @param ins the InputStream containing the NcML document
 * @param cancelTask allow user to cancel the task; may be null
 * @return the resulting NetcdfDataset
 * @throws IOException on read error, or bad referencedDatasetUri URI
 */
public static NetcdfDataset readNcML(InputStream ins, CancelTask cancelTask) throws IOException {

  org.jdom2.Document doc;
  try {
    SAXBuilder builder = new SAXBuilder();
    doc = builder.build(ins);
  } catch (JDOMException e) {
    throw new IOException(e.getMessage());
  }
  if (debugXML)
    System.out.println(" SAXBuilder done");

  if (showParsedXML) {
    XMLOutputter xmlOut = new XMLOutputter();
    System.out.println("*** NetcdfDataset/showParsedXML = \n" + xmlOut.outputString(doc) + "\n*******");
  }

  Element netcdfElem = doc.getRootElement();
  NetcdfDataset ncd = readNcML(null, netcdfElem, cancelTask);
  if (debugOpen)
    System.out.println("***NcMLReader.readNcML (stream) result= \n" + ncd);
  return ncd;
}
 
Example 5
Source File: NcMLReader.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Read NcML doc from a Reader, and construct a NetcdfDataset.
 * eg: NcMLReader.readNcML(new StringReader(ncml), location, null);
 *
 * @param r the Reader containing the NcML document
 * @param ncmlLocation the URL location string of the NcML document, used to resolve reletive path of the referenced
 *        dataset,
 *        or may be just a unique name for caching purposes.
 * @param cancelTask allow user to cancel the task; may be null
 * @return the resulting NetcdfDataset
 * @throws IOException on read error, or bad referencedDatasetUri URI
 */
public static NetcdfDataset readNcML(Reader r, String ncmlLocation, CancelTask cancelTask) throws IOException {

  org.jdom2.Document doc;
  try {
    SAXBuilder builder = new SAXBuilder();
    doc = builder.build(r);
  } catch (JDOMException e) {
    throw new IOException(e.getMessage());
  }
  if (debugXML)
    System.out.println(" SAXBuilder done");

  if (showParsedXML) {
    XMLOutputter xmlOut = new XMLOutputter();
    System.out.println("*** NetcdfDataset/showParsedXML = \n" + xmlOut.outputString(doc) + "\n*******");
  }

  Element netcdfElem = doc.getRootElement();
  NetcdfDataset ncd = readNcML(ncmlLocation, netcdfElem, cancelTask);
  if (debugOpen)
    System.out.println("***NcMLReader.readNcML (stream) result= \n" + ncd);
  return ncd;
}
 
Example 6
Source File: NcmlConstructor.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public boolean populate(InputStream ncml, NetcdfFile target) throws IOException {
  org.jdom2.Document doc;
  try {
    SAXBuilder builder = new SAXBuilder();
    doc = builder.build(ncml);
  } catch (JDOMException e) {
    throw new IOException(e.getMessage());
  }
  if (showParsedXML) {
    XMLOutputter xmlOut = new XMLOutputter();
    System.out.println("*** NetcdfDataset/showParsedXML = \n" + xmlOut.outputString(doc) + "\n*******");
  }

  Element netcdfElem = doc.getRootElement();
  readGroup(target, target.getRootGroup(), netcdfElem);
  return errlog.toString().isEmpty();
}
 
Example 7
Source File: CompareTableD.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void readBmt() throws IOException {
  org.jdom2.Document doc;
  try {
    SAXBuilder builder = new SAXBuilder();
    doc = builder.build(bmt);
    Element root = doc.getRootElement();
    int count = makeBmtTable(root.getChildren("featureCatalogue"));
    System.out.println(" bmt count= " + count);

    /*
     * Format pretty = Format.getPrettyFormat();
     * 
     * // wierd - cant pretty print ??!!
     * XMLOutputter fmt = new XMLOutputter(pretty);
     * //Writer pw = new FileWriter("C:/docs/bufr/wmo/wordNice.txt");
     * fmt.output(doc, new PrintWriter(System.out));
     */

  } catch (JDOMException e) {
    throw new IOException(e.getMessage());
  }
}
 
Example 8
Source File: CompareTableB.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void readBmt() throws IOException {
  org.jdom2.Document doc;
  try {
    SAXBuilder builder = new SAXBuilder();
    doc = builder.build(bmt);
    Element root = doc.getRootElement();
    int count = makeBmtTable(root.getChildren("featureCatalogue"));
    System.out.println(" bmt count= " + count);

    /*
     * Format pretty = Format.getPrettyFormat();
     * 
     * // wierd - cant pretty print ??!!
     * XMLOutputter fmt = new XMLOutputter(pretty);
     * //Writer pw = new FileWriter("C:/docs/bufr/wmo/wordNice.txt");
     * fmt.output(doc, new PrintWriter(System.out));
     */

  } catch (JDOMException e) {
    throw new IOException(e.getMessage());
  }
}
 
Example 9
Source File: RoleDatabase.java    From tds with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
RoleDatabase(String filename) throws IOException {

    InputStream is = new BufferedInputStream(new FileInputStream(filename));
    org.jdom2.Document doc;
    try {
      SAXBuilder builder = new SAXBuilder();
      doc = builder.build(is);
    } catch (JDOMException e) {
      throw new IOException(e.getMessage());
    }

    // <user username="ccsmData" roles="ccsmData, restrictedDatasetUser"/>

    Element rootElem = doc.getRootElement();
    List<Element> elems = rootElem.getChildren("user");
    for (Element elem : elems) {
      String username = elem.getAttributeValue("username");
      User user = new User(username);
      String roles = elem.getAttributeValue("roles");
      StringTokenizer stoke = new StringTokenizer(roles, ", ");
      while (stoke.hasMoreTokens()) {
        String role = stoke.nextToken();
        user.add(role);
      }
      users.put(username, user);
    }

  }
 
Example 10
Source File: CompareTableD.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void readTable() throws IOException {
  org.jdom2.Document doc;
  try {
    SAXBuilder builder = new SAXBuilder();
    doc = builder.build(robbxml);
    Element root = doc.getRootElement();
    int count = makeTable(root.getChildren("sequence"));
    System.out.println(" robb count= " + count);

  } catch (JDOMException e) {
    throw new IOException(e.getMessage());
  }
}
 
Example 11
Source File: RuntimeConfigParser.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void read(InputStream is, StringBuilder errlog) throws IOException {

    Document doc;
    SAXBuilder saxBuilder = new SAXBuilder();
    try {
      doc = saxBuilder.build(is);
    } catch (JDOMException e) {
      throw new IOException(e.getMessage());
    }

    read(doc.getRootElement(), errlog);
  }
 
Example 12
Source File: Parse.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Read an XML Document from a URL and return the root element.
 *
 * @param location the URL location
 * @return the root element of the Document
 * @throws java.io.IOException on read error
 */
public static Element readRootElement(String location) throws IOException {
  org.jdom2.Document doc;
  try {
    SAXBuilder builder = new SAXBuilder();
    doc = builder.build(location);
  } catch (JDOMException e) {
    throw new IOException(e.getMessage());
  }

  return doc.getRootElement();
}
 
Example 13
Source File: PointConfigXML.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public TableConfig readConfigXML(String fileLocation, FeatureType wantFeatureType, NetcdfDataset ds, Formatter errlog)
    throws IOException {

  org.jdom2.Document doc;
  try {
    SAXBuilder builder = new SAXBuilder();
    if (debugURL)
      System.out.println(" PointConfig URL = <" + fileLocation + ">");
    doc = builder.build(fileLocation);
  } catch (JDOMException e) {
    throw new IOException(e.getMessage());
  }
  if (debugXML)
    System.out.println(" SAXBuilder done");

  if (showParsedXML) {
    XMLOutputter xmlOut = new XMLOutputter();
    System.out.println("*** PointConfig/showParsedXML = \n" + xmlOut.outputString(doc) + "\n*******");
  }

  Element configElem = doc.getRootElement();
  String featureType = configElem.getAttributeValue("featureType");
  Element tableElem = configElem.getChild("table");
  TableConfig tc = parseTableConfig(ds, tableElem, null);
  tc.featureType = FeatureType.valueOf(featureType);

  return tc;
}
 
Example 14
Source File: NcMLReaderNew.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Read NcML doc from a Reader, and construct a NetcdfDataset.
 * eg: NcMLReader.readNcML(new StringReader(ncml), location, null);
 *
 * @param r the Reader containing the NcML document
 * @param ncmlLocation the URL location string of the NcML document, used to resolve reletive path of the referenced
 *        dataset,
 *        or may be just a unique name for caching purposes.
 * @param cancelTask allow user to cancel the task; may be null
 * @return the resulting NetcdfDataset
 * @throws IOException on read error, or bad referencedDatasetUri URI
 */
public static NetcdfDataset.Builder readNcML(Reader r, String ncmlLocation, CancelTask cancelTask)
    throws IOException {

  org.jdom2.Document doc;
  try {
    SAXBuilder builder = new SAXBuilder();
    doc = builder.build(r);
  } catch (JDOMException e) {
    throw new IOException(e.getMessage());
  }
  if (debugXML)
    System.out.println(" SAXBuilder done");

  if (showParsedXML) {
    XMLOutputter xmlOut = new XMLOutputter();
    System.out.println("*** NetcdfDataset/showParsedXML = \n" + xmlOut.outputString(doc) + "\n*******");
  }
  Element netcdfElem = doc.getRootElement();

  // the ncml probably refers to another dataset, but doesnt have to
  String referencedDatasetUri = netcdfElem.getAttributeValue("location");
  if (referencedDatasetUri == null)
    referencedDatasetUri = netcdfElem.getAttributeValue("url");
  if (referencedDatasetUri != null)
    referencedDatasetUri = AliasTranslator.translateAlias(referencedDatasetUri);

  NcMLReaderNew reader = new NcMLReaderNew();
  return reader.readNcML(ncmlLocation, referencedDatasetUri, netcdfElem, cancelTask);
}
 
Example 15
Source File: NcMLReaderNew.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Use NCML to modify the dataset, getting NcML from a URL. Used by CoordSysFactory.
 *
 * @param ncDataset modify this dataset
 * @param ncmlLocation URL location of NcML
 * @param cancelTask allow user to cancel task; may be null
 * @throws IOException on read error
 */
public static void wrapNcML(NetcdfDataset.Builder ncDataset, String ncmlLocation, CancelTask cancelTask)
    throws IOException {
  org.jdom2.Document doc;
  try {
    SAXBuilder builder = new SAXBuilder();
    if (debugURL) {
      System.out.println(" NetcdfDataset URL = <" + ncmlLocation + ">");
    }
    doc = builder.build(ncmlLocation);
  } catch (JDOMException e) {
    throw new IOException(e.getMessage());
  }
  if (debugXML) {
    System.out.println(" SAXBuilder done");
  }

  if (showParsedXML) {
    XMLOutputter xmlOut = new XMLOutputter();
    System.out.println("*** NetcdfDataset/showParsedXML = \n" + xmlOut.outputString(doc) + "\n*******");
  }

  Element netcdfElem = doc.getRootElement();

  NcMLReaderNew reader = new NcMLReaderNew();
  reader.readNetcdf(ncmlLocation, ncDataset, netcdfElem, cancelTask);
  if (debugOpen) {
    System.out.println("***NcMLReader.wrapNcML result= \n" + ncDataset);
  }
}
 
Example 16
Source File: NcMLReader.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Use NCML to modify a dataset, getting the NcML document as a resource stream.
 * Uses ClassLoader.getResourceAsStream(ncmlResourceLocation), so the NcML can be inside of a jar file, for example.
 *
 * @param ncDataset modify this dataset
 * @param ncmlResourceLocation resource location of NcML
 * @param cancelTask allow user to cancel task; may be null
 * @throws IOException on read error
 */
public static void wrapNcMLresource(NetcdfDataset ncDataset, String ncmlResourceLocation, CancelTask cancelTask)
    throws IOException {
  ClassLoader cl = ncDataset.getClass().getClassLoader();
  try (InputStream is = cl.getResourceAsStream(ncmlResourceLocation)) {
    if (is == null)
      throw new FileNotFoundException(ncmlResourceLocation);

    if (debugXML) {
      System.out.println(" NetcdfDataset URL = <" + ncmlResourceLocation + ">");
      try (InputStream is2 = cl.getResourceAsStream(ncmlResourceLocation)) {
        System.out.println(" contents=\n" + IO.readContents(is2));
      }
    }

    org.jdom2.Document doc;
    try {
      SAXBuilder builder = new SAXBuilder();
      if (debugURL)
        System.out.println(" NetcdfDataset URL = <" + ncmlResourceLocation + ">");
      doc = builder.build(is);
    } catch (JDOMException e) {
      throw new IOException(e.getMessage());
    }
    if (debugXML)
      System.out.println(" SAXBuilder done");

    if (showParsedXML) {
      XMLOutputter xmlOut = new XMLOutputter();
      System.out.println("*** NetcdfDataset/showParsedXML = \n" + xmlOut.outputString(doc) + "\n*******");
    }

    Element netcdfElem = doc.getRootElement();

    NcMLReader reader = new NcMLReader();
    reader.readNetcdf(ncDataset.getLocation(), ncDataset, ncDataset, netcdfElem, cancelTask);
    if (debugOpen)
      System.out.println("***NcMLReader.wrapNcML result= \n" + ncDataset);
  }
}
 
Example 17
Source File: NcMLReaderNew.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Read an NcML file from a URL location, and construct a NetcdfDataset.
 *
 * @param ncmlLocation the URL location string of the NcML document
 * @param referencedDatasetUri if null (usual case) get this from NcML, otherwise use URI as the location of the
 *        referenced dataset.
 * @param cancelTask allow user to cancel the task; may be null
 * @return the resulting NetcdfDataset
 * @throws IOException on read error, or bad referencedDatasetUri URI
 */
public static NetcdfDataset.Builder readNcML(String ncmlLocation, String referencedDatasetUri, CancelTask cancelTask)
    throws IOException {
  URL url = new URL(ncmlLocation);

  if (debugURL) {
    System.out.println(" NcMLReader open " + ncmlLocation);
    System.out.println("   URL = " + url);
    System.out.println("   external form = " + url.toExternalForm());
    System.out.println("   protocol = " + url.getProtocol());
    System.out.println("   host = " + url.getHost());
    System.out.println("   path = " + url.getPath());
    System.out.println("  file = " + url.getFile());
  }

  org.jdom2.Document doc;
  try {
    SAXBuilder builder = new SAXBuilder();
    if (debugURL) {
      System.out.println(" NetcdfDataset URL = <" + url + ">");
    }
    doc = builder.build(url);
  } catch (JDOMException e) {
    throw new IOException(e.getMessage());
  }
  if (debugXML) {
    System.out.println(" SAXBuilder done");
  }

  if (showParsedXML) {
    XMLOutputter xmlOut = new XMLOutputter();
    System.out.println("*** NetcdfDataset/showParsedXML = \n" + xmlOut.outputString(doc) + "\n*******");
  }

  Element netcdfElem = doc.getRootElement();

  if (referencedDatasetUri == null) {
    // the ncml probably refers to another dataset, but doesnt have to
    referencedDatasetUri = netcdfElem.getAttributeValue("location");
    if (referencedDatasetUri == null) {
      referencedDatasetUri = netcdfElem.getAttributeValue("url");
    }
  }
  if (referencedDatasetUri != null) {
    referencedDatasetUri = AliasTranslator.translateAlias(referencedDatasetUri);
  }

  NcMLReaderNew reader = new NcMLReaderNew();
  return reader.readNcML(ncmlLocation, referencedDatasetUri, netcdfElem, cancelTask);
}
 
Example 18
Source File: NcMLReaderNew.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Use NCML to modify a dataset, getting the NcML document as a resource stream. Uses
 * ClassLoader.getResourceAsStream(ncmlResourceLocation),
 * so the NcML can be inside of a jar file, for example.
 *
 * @param ncDataset modify this dataset
 * @param ncmlResourceLocation resource location of NcML
 * @param cancelTask allow user to cancel task; may be null
 * @throws IOException on read error
 */
public static void wrapNcMLresource(NetcdfDataset.Builder ncDataset, String ncmlResourceLocation,
    CancelTask cancelTask) throws IOException {
  ClassLoader cl = ncDataset.getClass().getClassLoader();
  try (InputStream is = cl.getResourceAsStream(ncmlResourceLocation)) {
    if (is == null) {
      throw new FileNotFoundException(ncmlResourceLocation);
    }

    if (debugXML) {
      System.out.println(" NetcdfDataset URL = <" + ncmlResourceLocation + ">");
      try (InputStream is2 = cl.getResourceAsStream(ncmlResourceLocation)) {
        System.out.println(" contents=\n" + IO.readContents(is2));
      }
    }

    org.jdom2.Document doc;
    try {
      SAXBuilder builder = new SAXBuilder();
      if (debugURL) {
        System.out.println(" NetcdfDataset URL = <" + ncmlResourceLocation + ">");
      }
      doc = builder.build(is);
    } catch (JDOMException e) {
      throw new IOException(e.getMessage());
    }
    if (debugXML) {
      System.out.println(" SAXBuilder done");
    }

    if (showParsedXML) {
      XMLOutputter xmlOut = new XMLOutputter();
      System.out.println("*** NetcdfDataset/showParsedXML = \n" + xmlOut.outputString(doc) + "\n*******");
    }

    Element netcdfElem = doc.getRootElement();

    NcMLReaderNew reader = new NcMLReaderNew();
    reader.readNetcdf(ncDataset.location, ncDataset, netcdfElem, cancelTask);
    if (debugOpen) {
      System.out.println("***NcMLReader.wrapNcML result= \n" + ncDataset);
    }
  }
}
 
Example 19
Source File: NcMLReader.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Read an NcML file from a URL location, and construct a NetcdfDataset.
 *
 * @param ncmlLocation the URL location string of the NcML document
 * @param referencedDatasetUri if null (usual case) get this from NcML, otherwise use URI as the location of the
 *        referenced dataset.
 * @param cancelTask allow user to cancel the task; may be null
 * @return the resulting NetcdfDataset
 * @throws IOException on read error, or bad referencedDatasetUri URI
 */
public static NetcdfDataset readNcML(String ncmlLocation, String referencedDatasetUri, CancelTask cancelTask)
    throws IOException {
  URL url = new URL(ncmlLocation);

  if (debugURL) {
    System.out.println(" NcMLReader open " + ncmlLocation);
    System.out.println("   URL = " + url);
    System.out.println("   external form = " + url.toExternalForm());
    System.out.println("   protocol = " + url.getProtocol());
    System.out.println("   host = " + url.getHost());
    System.out.println("   path = " + url.getPath());
    System.out.println("  file = " + url.getFile());
  }

  org.jdom2.Document doc;
  try {
    SAXBuilder builder = new SAXBuilder();
    if (debugURL)
      System.out.println(" NetcdfDataset URL = <" + url + ">");
    doc = builder.build(url);
  } catch (JDOMException e) {
    throw new IOException(e.getMessage());
  }
  if (debugXML)
    System.out.println(" SAXBuilder done");

  if (showParsedXML) {
    XMLOutputter xmlOut = new XMLOutputter();
    System.out.println("*** NetcdfDataset/showParsedXML = \n" + xmlOut.outputString(doc) + "\n*******");
  }

  Element netcdfElem = doc.getRootElement();

  if (referencedDatasetUri == null) {
    // the ncml probably refers to another dataset, but doesnt have to
    referencedDatasetUri = netcdfElem.getAttributeValue("location");
    if (referencedDatasetUri == null)
      referencedDatasetUri = netcdfElem.getAttributeValue("url");
  }
  if (referencedDatasetUri != null)
    referencedDatasetUri = AliasTranslator.translateAlias(referencedDatasetUri);

  NcMLReader reader = new NcMLReader();
  NetcdfDataset ncd = reader._readNcML(ncmlLocation, referencedDatasetUri, netcdfElem, cancelTask);
  if (debugOpen)
    System.out.println("***NcMLReader.readNcML result= \n" + ncd);
  return ncd;
}