Opened 14 years ago

#738 new defect

XmlFeatureSerialiser Does not Handle XMLFlags

Reported by: crispinatime Owned by: gregboone
Priority: minor Milestone: 3.6.0
Component: FDO API Version: 3.6.0
Severity: 3 Keywords:
Cc: External ID:

Description

When the XmlFeatureSerialiser has xmlFlags, but the XmlFeatureWriter does not, then xmlSerializer.Serialize should temporarily pass the flags down to the XmlFeatureWriter

This would mean that that application would only need to set the flags on the topmost object rather than on both of them.

I have set priority as minor as there is a workaround

WORKING EXAMPLE

 // set flags first so that can be included in writer 
 OSGeo_FDO.Xml.XmlFeatureFlags xmlFlags = new OSGeo.FDO.Xml.XmlFeatureFlags();
 xmlFlags.DefaultNamespace = "1Spatial";

 // set options for GML format
 #if FDO36
 try
 {
       if (radioGML311.Checked)
               xmlFlags.GmlVersion = OSGeo.FDO.Xml.GmlVersion.GmlVersion_311;
 }
 catch
 {
       MessageBox.Show("Failed to Set GML Version to 3.1.1 - Reverting to GML 2.1.2");
       xmlFlags.GmlVersion = OSGeo.FDO.Xml.GmlVersion.GmlVersion_212;
 }
 #endif

 // create writer with flags, then serialize
 String szTemp = System.IO.Path.GetTempFileName();
 OSGeo_FDO.Common.Xml.XmlWriter xmlWriter = new OSGeo.FDO.Common.Xml.XmlWriter(szTemp, true, OSGeo.FDO.Common.Xml.XmlWriter.LineFormat.LineFormat_Indent);
 OSGeo_FDO.Xml.XmlFeatureWriter xmlFtWriter = new OSGeo.FDO.Xml.XmlFeatureWriter(xmlWriter, xmlFlags);

 OSGeo_FDO.Xml.XmlFeatureSerializer.XmlSerialize(readFeature, xmlFtWriter);

FAILING (DOES NOT SET GML311) EXAMPLE

 String szTemp = System.IO.Path.GetTempFileName(); 
 OSGeo_FDO.Common.Xml.XmlWriter xmlWriter = new OSGeo.FDO.Common.Xml.XmlWriter(szTemp, true, OSGeo.FDO.Common.Xml.XmlWriter.LineFormat.LineFormat_Indent);
 OSGeo_FDO.Xml.XmlFeatureWriter xmlFtWriter = new OSGeo.FDO.Xml.XmlFeatureWriter(xmlWriter);

 OSGeo_FDO.Xml.XmlFeatureFlags xmlFlags = new OSGeo.FDO.Xml.XmlFeatureFlags();
 xmlFlags.DefaultNamespace = "1Spatial";

 // set options for GML format
 #if FDO36
 try
 {
       if (radioGML311.Checked)
               xmlFlags.GmlVersion = OSGeo.FDO.Xml.GmlVersion.GmlVersion_311;
 }
 catch
 {
       MessageBox.Show("Failed to Set GML Version to 3.1.1 - Reverting to GML 2.1.2");
       xmlFlags.GmlVersion = OSGeo.FDO.Xml.GmlVersion.GmlVersion_212;
 }
 #endif

 // despite serialising with xmlFlags they are *NOT* applied
 OSGeo_FDO.Xml.XmlFeatureSerializer.XmlSerialize(readFeature, xmlFtWriter, xmlFlags);

Change History (0)

Note: See TracTickets for help on using tickets.