Hi! I'm writing an interface to Google KML files. I've been pretty successful using XMLBeans for several months now, but I can't seem to figure out why there is a difference in xsi:type namespaces if I am starting from an existing document vs. building it through Java. Is there a reason the "ns" prefix is left off of the second KML file? <?xml version="1.0" encoding="UTF-8"?> <ns:kml xmlns:ns="http://earth.google.com/kml/2.1"> <ns:Feature xsi:type="ns:DocumentType" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <ns:Feature xsi:type="ns:NetworkLinkType"/> </ns:Feature> </ns:kml> <?xml version="1.0" encoding="UTF-8"?> <ns:kml xmlns:ns="http://earth.google.com/kml/2.1"> <ns:Feature xsi:type="ns:DocumentType" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <ns:Feature xsi:type="NetworkLinkType"/> </ns:Feature> </ns:kml> import com.google.earth.kml.DocumentType; import com.google.earth.kml.FeatureType; import com.google.earth.kml.KmlDocument; import com.google.earth.kml.KmlType; import com.google.earth.kml.NetworkLinkType; import org.apache.xmlbeans.XmlOptions; /** * @author Daniel.McCann */ public class KmlTest { public static void main(String[] args) { try { DocumentType dt = DocumentType.Factory.newInstance(); NetworkLinkType nt = NetworkLinkType.Factory.newInstance(); dt.addChildFeature(nt); save(dt); System.out.println(); KmlDocument d = KmlDocument.Factory .parse("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<kml xmlns=\"http://earth.google.com/kml/2.1\">" + "<Document></Document></kml>"); nt = NetworkLinkType.Factory.newInstance(); ((DocumentType) d.getKml().getFeature()).addChildFeature(nt); save((DocumentType) d.getKml().getFeature()); } catch (Exception ex) { ex.printStackTrace(); } } public static void save(FeatureType f) throws Exception { KmlDocument doc = KmlDocument.Factory.newInstance(); KmlType kml = doc.addNewKml(); kml.setFeature(f); XmlOptions xmlOptions = new XmlOptions(); xmlOptions.setSavePrettyPrint(); // xmlOptions.setUseDefaultNamespace(); doc.save(System.out, xmlOptions); } } Thanks, Dan ________________________________
Daniel McCann General Dynamics Advanced Information Systems (703) 835-1036 --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

