Sample on how to generate code that can be and should be subject to
namespace validation:
//important imports
import org.jdom.Attribute;
import org.jdom.output.Format;
import org.jdom.output.XMLOutputter;
import org.jdom.Document;
import org.jdom.Element;
//code sample
Document document = new Document();
Namespace xmlns =
Namespace.getNamespace("http://www.sitemaps.org/schemas/sitemap/0.9");
Namespace xsi = Namespace.getNamespace("xsi",
"http://www.w3.org/2001/XMLSchema-instance");
Element rootElement = new Element("urlset", xmlns);
rootElement.addNamespaceDeclaration(xsi);
Attribute schemaLocation = new Attribute("schemaLocation",
"http://www.sitemaps.org/schemas/sitemap/0.9" +
" http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd", xsi);
rootElement.setAttribute(schemaLocation);
document.setRootElement(rootElement);
//begin url harvesting
Element url = new Element("url", xmlns);
Element loc = new Element("loc", xmlns);
Element lastmod = new Element("lastmod", xmlns);
Element changefreq = new Element("changefreq", xmlns);
Element priority = new Element("priority", xmlns);
loc.addContent("");
lastmod.addContent("");
changefreq.addContent("");
priority.addContent("");
url.addContent(loc);
url.addContent(lastmod);
url.addContent(changefreq);
url.addContent(priority);
rootElement.addContent(url);
//end loop
createSitemapFile(document);
Original issue reported on code.google.com by ban...@gmail.com on 16 Mar 2010 at 2:17
Original issue reported on code.google.com by
ban...@gmail.com
on 16 Mar 2010 at 2:17