static public void writeNcML(NetcdfFile ncfile, Formatter out, WantValues showValues, String url) throws IOException { out.format("<?xml version='1.0' encoding='UTF-8'?>%n"); out.format("<netcdf xmlns='http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2'%n"); if (url != null) out.format(" location='%s' >%n%n", StringUtil2.quoteXmlAttribute(url)); else out.format(" location='%s' >%n%n", StringUtil2.quoteXmlAttribute(URLnaming.canonicalizeWrite(ncfile.getLocation()))); if (ncfile.getId() != null) out.format(" id='%s'%n", StringUtil2.quoteXmlAttribute(ncfile.getId())); if (ncfile.getTitle() != null) out.format(" title='%s'%n", StringUtil2.quoteXmlAttribute(ncfile.getTitle())); writeNcMLGroup(ncfile, ncfile.getRootGroup(), out, new Indent(2), showValues); out.format("</netcdf>%n"); out.flush(); }
static public void writeNcML(NetcdfFile ncfile, Formatter out, WantValues showValues, String url) throws IOException { out.format("<?xml version='1.0' encoding='UTF-8'?>%n"); out.format("<netcdf xmlns='http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2'%n"); if (url != null) out.format(" location='%s' >%n%n", StringUtil2.quoteXmlAttribute(url)); else out.format(" location='%s' >%n%n", StringUtil2.quoteXmlAttribute(URLnaming.canonicalizeWrite(ncfile.getLocation()))); if (ncfile.getId() != null) out.format(" id='%s'%n", StringUtil2.quoteXmlAttribute(ncfile.getId())); if (ncfile.getTitle() != null) out.format(" title='%s'%n", StringUtil2.quoteXmlAttribute(ncfile.getTitle())); writeNcMLGroup(ncfile, ncfile.getRootGroup(), out, new Indent(2), showValues); out.format("</netcdf>%n"); out.flush(); }
/** * Write the NcML representation for a file. * Note that ucar.nc2.dataset.NcMLWriter has a JDOM implementation, for complete NcML. * This method implements only the "core" NcML for plain ole netcdf files. * * @param ncfile write NcML for this file * @param os write to this Output Stream. * @param showCoords show coordinate variable values. * @param uri use this for the url attribute; if null use getLocation(). // ?? * @throws IOException on write error */ static public void writeNcML( NetcdfFile ncfile, java.io.OutputStream os, boolean showCoords, String uri) throws IOException { PrintStream out = new PrintStream( os); out.print("<?xml version='1.0' encoding='UTF-8'?>\n"); out.print("<netcdf xmlns='http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2'\n"); // out.print(" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'\n"); // out.print(" xsi:schemaLocation='http://www.unidata.edu/schemas/ncml-2.2 http://www.unidata.ucar.edu/schemas/ncml-2.2.xsd'\n"); if (uri != null) out.print(" location='"+ StringUtil2.quoteXmlAttribute(uri)+"' >\n\n"); else out.print(" location='"+ StringUtil2.quoteXmlAttribute(URLnaming.canonicalizeWrite(ncfile.getLocation()))+"' >\n\n"); if (ncfile.getId() != null) out.print(" id='"+ StringUtil2.quoteXmlAttribute(ncfile.getId())+"' >\n"); if (ncfile.getTitle() != null) out.print(" title='"+ StringUtil2.quoteXmlAttribute(ncfile.getTitle())+"' >\n"); writeNcMLGroup( ncfile, ncfile.getRootGroup(), out, new Indent(2), showCoords); out.print("</netcdf>\n"); out.flush(); }
/** * Write the NcML representation for a file. * Note that ucar.nc2.dataset.NcMLWriter has a JDOM implementation, for complete NcML. * This method implements only the "core" NcML for plain ole netcdf files. * * @param ncfile write NcML for this file * @param os write to this Output Stream. * @param showCoords show coordinate variable values. * @param uri use this for the url attribute; if null use getLocation(). // ?? * @throws IOException on write error */ static public void writeNcML( NetcdfFile ncfile, java.io.OutputStream os, boolean showCoords, String uri) throws IOException { PrintStream out = new PrintStream( os); out.print("<?xml version='1.0' encoding='UTF-8'?>\n"); out.print("<netcdf xmlns='http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2'\n"); // out.print(" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'\n"); // out.print(" xsi:schemaLocation='http://www.unidata.edu/schemas/ncml-2.2 http://www.unidata.ucar.edu/schemas/ncml-2.2.xsd'\n"); if (uri != null) out.print(" location='"+ StringUtil2.quoteXmlAttribute(uri)+"' >\n\n"); else out.print(" location='"+ StringUtil2.quoteXmlAttribute(URLnaming.canonicalizeWrite(ncfile.getLocation()))+"' >\n\n"); if (ncfile.getId() != null) out.print(" id='"+ StringUtil2.quoteXmlAttribute(ncfile.getId())+"' >\n"); if (ncfile.getTitle() != null) out.print(" title='"+ StringUtil2.quoteXmlAttribute(ncfile.getTitle())+"' >\n"); writeNcMLGroup( ncfile, ncfile.getRootGroup(), out, new Indent(2), showCoords); out.print("</netcdf>\n"); out.flush(); }
public Element makeNetcdfElement(NetcdfFile ncFile, String location) { Element rootElem = makeGroupElement(ncFile.getRootGroup()); // rootElem isn't just like any other group element; we must undo some of the changes made to it in writeGroup(). rootElem.setName("netcdf"); // Was "group". rootElem.removeAttribute("name"); // This attribute is not defined on the root "netcdf" element. rootElem.addNamespaceDeclaration(namespace); if (null == location) location = ncFile.getLocation(); if (null != location) { rootElem.setAttribute("location", URLnaming.canonicalizeWrite(location)); } if (null != ncFile.getId()) rootElem.setAttribute("id", ncFile.getId()); if (null != ncFile.getTitle()) rootElem.setAttribute("title", ncFile.getTitle()); return rootElem; }
rootElem.setAttribute("location", URLnaming.canonicalizeWrite(location));
rootElem.setAttribute("location", URLnaming.canonicalizeWrite(location));