SV: [jdom-interest] Building and XML Spreadsheet for Microsoft Excel - Office XP Prof essional

Per Norrman pernorrman at telia.com
Thu Nov 13 04:45:58 PST 2003


Hi,

Always used namespaces when creating elements. Add namespace
declarations as necessary to the root element.

For example:
-------------------------------------------------------------
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.Namespace;
import org.jdom.output.XMLOutputter;

public class Excel {

	public static void main(String[] args) throws Exception {
		Namespace ns =
			Namespace.getNamespace(
	
"urn:schemas-microsoft-com:office:spreadsheet");
		Namespace o =
			Namespace.getNamespace(
				"o",
				"urn:schemas-microsoft-com:office:office");

		Element wb = new Element("Workbook", ns);
            wb.addContent(new Element("OfficeStuff", o));
            wb.addContent(new Element("ExcelStuff", ns));
		wb.addNamespaceDeclaration(o);

		new XMLOutputter("   ", true).output(new Document(wb),
System.out);

	}
}

/pmn




More information about the jdom-interest mailing list