Opened 13 years ago

Closed 13 years ago

#753 closed defect (fixed)

FDO XML: improper serializing of schemas with names starting with numbers

Reported by: brentrobinson Owned by: brentrobinson
Priority: minor Milestone:
Component: FDO API Version: 3.6.0
Severity: 3 Keywords: XML serialize namespace prefix
Cc: External ID:

Description

Steps:

  • Create a feature schema whose name has a numeric 1st character (e.g. "1Schema")
  • Add a feature class to the schema
  • serialize the schema, using FdoFeatureSchema::WriteXml()
  • deserialize the XML back into a feature schema collection.

An error similar to the following is issued:

Error reading schema '-x31-Schema' from XML, global element 
xs:schema/xs:element[@name=FeatureClass1] type is from a different 
schema: ''. 

XML element names cannot start with digits so the Schema name "1Schema" is encoded into "-x31-Schema" when serialized. However, element names cannot start with "-" either. By default, the XML serialization generates a namespace for the feature schema, using the schema name as the prefix. However, the namespace declaration is not written because the prefix is not a valid XML name. This corrupts the resulting XML document since the type for the XML element for the feature class is specified with an undeclared namespace.

Change History (1)

comment:1 by brentrobinson, 13 years ago

Resolution: fixed
Status: newclosed

Revision: 5915 Author: brentrobinson Date: 8:23:12 AM, Wednesday, March 16, 2011 Message: Ticket#753: Use leading '_', instead of '-' when the first character of a schema element is not valid in an XML name and needs to be encoded.


Modified : /trunk/Fdo/UnitTest/SchemaTest.cpp Modified : /trunk/Fdo/UnitTest/XmlTest.cpp Modified : /trunk/Fdo/UnitTest/schema_merge1b.xml Modified : /trunk/Fdo/UnitTest/schema_merge2b_master.txt Modified : /trunk/Fdo/UnitTest/schema_ref_err1_master.txt Modified : /trunk/Fdo/UnitTest/schema_ref_err2_master.txt Modified : /trunk/Fdo/UnitTest/schema_ref_err3_master.txt Modified : /trunk/Fdo/UnitTest/schema_refs1a_master.txt Modified : /trunk/Fdo/UnitTest/schema_refs1b_master.txt Modified : /trunk/Fdo/UnitTest/schema_refs1c_master.txt Modified : /trunk/Fdo/UnitTest/schema_refs2_master.txt Modified : /trunk/Fdo/UnitTest/schema_refs_err_master.txt Modified : /trunk/Fdo/Unmanaged/Src/Common/Xml/ReaderXrcs.cpp Modified : /trunk/Fdo/Unmanaged/Src/Common/Xml/WriterXrcs.cpp Modified : /trunk/Fdo/Unmanaged/Src/Fdo/Schema/SchemaFromExternal.h Modified : /trunk/Fdo/Unmanaged/Src/Fdo/Schema/SchemaFromExternal.xslt

Note: See TracTickets for help on using tickets.