You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@depot.apache.org by ni...@apache.org on 2004/05/16 08:53:22 UTC

svn commit: rev 10697 - incubator/depot/trunk/update/src/java/org/apache/depot/update/ant

Author: nickchalko
Date: Sun May 16 01:53:21 2004
New Revision: 10697

Modified:
   incubator/depot/trunk/update/src/java/org/apache/depot/update/ant/CachedResourceSetExportTask.java
Log:
Added xml declaration.
Added doctype.
Formating.

Modified: incubator/depot/trunk/update/src/java/org/apache/depot/update/ant/CachedResourceSetExportTask.java
==============================================================================
--- incubator/depot/trunk/update/src/java/org/apache/depot/update/ant/CachedResourceSetExportTask.java	(original)
+++ incubator/depot/trunk/update/src/java/org/apache/depot/update/ant/CachedResourceSetExportTask.java	Sun May 16 01:53:21 2004
@@ -25,6 +25,7 @@
 import java.util.List;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Task;
+import org.apache.xml.utils.XMLChar;
 /**
  * Export a cached resource set to xml file. <code>
  * <cachedresourceset>
@@ -86,21 +87,32 @@
 			Writer writer = new FileWriter(getToFile());
 			PrintWriter out = new PrintWriter(writer);
 			List resourceList = cachedResourceSet.getResourceList();
-			out.println("<cachedresourceset id=\"" + getRefid() + "\">");
+			out.println("<?xml " + nameValue("version", "1.0") + "?>");
+			out
+					.println("<!DOCTYPE cachedresourceset PUBLIC \"-//APACHE//DTD CachedResource V0.1//EN\" \"http://incubator.apache.org/depot/dtd/cachedresource-v01.dtd\">");
+			out.println("<cachedresourceset " + nameValue("id", getRefid())
+					+ ">");
 			for (Iterator i = resourceList.iterator(); i.hasNext();) {
 				ResourceElement resource = (ResourceElement) i.next();
-				out.println("<resource" + " name=\"" + resource.getName()
-						+ "\"" + " version=\"" + resource.getVersion() + "\""
-						+ " href=\"" + resource.getDownloadedFrom() + "\"" + ""
-						+ "/>");
+				out.println("    <resource "
+						+ nameValue("name", resource.getName()));
+				out.println("              "
+						+ nameValue("version", resource.getVersion()));
+				out.println("              "
+						+ nameValue("href", resource.getDownloadedFrom()));
+				out.println("     />");
 				log(resource + "  from  " + resource.getDownloadedFrom());
 			}
-			out.println("</cachedresourceset >");
+			out.println("</cachedresourceset>");
 			out.close();
 			writer.close();
 		} catch (Exception e) {
 			throw new BuildException("Error exporting cached resource set "
 					+ getRefid(), e);
 		}
+	}
+	private String nameValue(final String name, final String value) {
+		String togther = name + "=\"" + value + "\"";
+		return togther;
 	}
 }