Changes between Version 3 and Version 4 of FdoEnhancedSchemaNameSupport


Ignore:
Timestamp:
Oct 18, 2007, 2:45:54 PM (17 years ago)
Author:
gregboone
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • FdoEnhancedSchemaNameSupport

    v3 v4  
    111111As with the Schema Exchange use case, the default method does not work well for the Publish as WFS use case since all schema names end up prefixed with http://fdo.osgeo.org/schemas/feature/.
    112112
    113 
    114 
     113==== Customized Schema Prefix ====
     114
     115The !FdoXmlFlags class provides a url attribute that allows the default osgeo schema prefix to be overridden. This url is then used to prepend schema names on writing to GML and for stripping off prefixes when reading from GML.  For example, if the url is set to www.mycity.on.ca/departments/transportation, then the FDO schema named "Roads" becomes:
     116
     117        www.mycity.on.ca/departments/transportation/Roads
     118
     119when the schema is written to GML. If this schema is read back from GML. the url prefix is removed and the FDO schema name becomes "Roads".
     120
     121This method works better, for the Publish as WFS use case, than the default method. The customer can control what the GML schema name looks like and can make it reflect the URI's used by their organization. However, there is a limitation in that the same schema prefix gets applied to each schema in the schema collection. For example, if the schema contains a "Roads" and "!WaterService" schema, and the desired GML Schema names are:
     122
     123        www.mycity.on.ca/departments/transportation/Roads
     124        www.mycity.on.ca/departments/watersewer/WaterService
     125
     126then each schema must be written by a separate !WriteXml() invocation, with a different url flag.
     127
     128For the same reason, this method works better than the default method for the Schema Exchange use case. However, there is one caveat: round trip fidelity is only preserved if the same url is specified on both !ReadXml() and !WriteXml(). Also, the GML schema name must start with the url prefix for round trip fidelity to be preserved. This might be difficult for an application to manage, especially if a different prefix is required for each schema.
     129
     130This method would not likely be used in the Export/Import use case, due to these extra complications in managing the prefixes for each schema.
     131
     132This method is not applicable to the WFS Provider use case.
     133
     134==== Short Prefix as Schema Name ====
     135
     136Most GML schema documents associate a short prefix with each schema name. This short prefix is used to define references to the schema, in other parts of the document. This makes the GML document smaller and more readable. The short prefix is not guaranteed to be unique within a GML document. However, it is unique for the XML element where it is defined plus all sub-elements.
     137
     138The !FdoXmlFlags provides a !SchemaNameAsPrefix setting. When set to true (the default is false), the short prefix becomes the FDO Schema name, when reading from GML to FDO.  This setting is only applicable to the !ReadXml() function. !WriteXml() always uses the url setting to generate the GML schema names.
     139
     140This method is used by the WFS Provider and works well for this use case. Although not globally unique, these prefixes are unique for a particular WFS. The prefixes are also very similar in format to a typical FDO Schema name in that they tend to be short and easily readable by humans.
     141
     142This method is not applicable to the other use cases, since all of these require the use of the !WriteXml() function. GML to FDO to GML round trip fidelity is not preserved. The full URI for the schema name is lost when translating to FDO, so it cannot be reliably re-constituted when translating back to GML.
     143
     144=== Requirements and Gap Analysis ===
     145
     146The current API handles the Export/Import and WFS Provider uses cases fairly well. However, the handling of the Schema Exchange and Publish as WFS use cases is cumbersome for the following reasons:
     147
     148• customer must usually supply a schema  prefix and must ensure that consistent prefixes are used when reading and writing the feature schemas.
     149
     150• due to a bug, round trip fidelity of schema names is not preserved when the schema name does not start with the schema prefix.
     151
     152• For a single !ReadXml() or !WriteXml() operation, there is no way to apply a different schema prefix to each schema.
     153
     154• On !ReadXml(), if the GML schema name is not prefixed by the schema prefix, a messy looking FDO schema name is generated.
     155
     156The main requirement is to streamline the handling of these two use cases. !MapGuide currently (or plans to ) supports publishing FDO data sources through a WFS, so supporting this Publish as WFS likely takes priority over Schema Exchange. (TBD: verify !MapGuide's WFS publishing requirements).
     157
     158=== Recommendation Summary ===
     159
     160Section 'Solution Options' below explores a number of solution options. From these options, a number of recommendations can be made:
     161
     162• It is recommended that the  Schema Name Attributes option be implemented (see 5.2 Schema Name Attributes). Although not perfect, it is the best option mentioned in this document.
     163
     164• it is not currently recommended that we allow '.' and ':' in schema names (see 5.1 Simple Default Translation). However, this option would make schema names more readable so it should be explored further to see if the potential drawbacks can be addressed.
     165
     166=== Solution Options ===
     167
     168The following lists some options for improving schema name conversion. These options are not necessarily mutually exclusive. However, it is unlikely that we'd implement them all since that would add a lot of complexity to the FDO API
     169
     170==== Simple Default Translation ====
     171
     172Under this option, the url setting for !FdoXmlFlags would no longer have a default. When no !FdoXmlFlags are specified, !ReadXml() and !WriteXml() would not usually modify the schema name, meaning that the GML and FDO names would usually be identical.
     173
     174''!WriteXml()'' would only modify the name if it is not a valid URI. In this case, the name would be adjusted by escaping any non-conforming characters.
     175
     176''!ReadXml()'' would only modify the name if it contains any escaped characters, which it would unescape. !ReadXml() would no longer escape '.' and ':'. This has implications on the !FdoFeatureSchema object in that these two characters would have to be allowed in schema names. This can be done by removing the no '.' or ':' restriction from schema element names. However, we'd need a way to indicate when these are literal characters when they appear as qualified names. One possibility is to mandate that each component of a qualified schema element name must be enclosed in double quotes when it contains a '.' or ':'.
     177
     178When the url !FdoXmlFlag is specified, the behaviour would be as now: !WriteXml() would tack this url prefix onto the schema name and !ReadXml() would remove it if present.
     179
     180'''Pros'''
     181
     182• Simpler approach. For the default case, we don't need to worry about tacking on and stripping off prefixes.
     183
     184• FDO Schema Names derived from GML are more readable. The names can still be long but at least they won't contain the '-dot-' and '-colon-' sequences.
     185
     186• Works well for the Export/Import and Schema Exchange use cases as long as both !ReadXml() and !WriteXml() are done in FDO 3.3.0. Not applicable to the WFS Provider use case.
     187
     188'''Cons'''
     189
     190• Backward Compatibility. For the Export/Import and Schema Exchange use cases, schema name round trip fidelity is not preserved if !WriteXml() is done from pre-Slate and !ReadXml() from FDO 3.3.0 or vice versa. The reason is that one operation will use a different name translation method from the other. This is more of a problem for Export/Import. The bug mentioned above already introduces round trip fidelity problems for the Schema Exchange use case. The backward compatibility issues could be mitigated if we could detect when one of the operations was done using pre-slate. In this case the operation done in slate would use the pre-slate name translation rules. However, this eliminates the simplicity pro since we still have to keep the old name translation algorithms around.
     191
     192• Provider compatibility. Some providers might need changes, since current code based on assumption that schema element names do not contain '.' or ':'.
     193
     194• Qualified Schema Element name compatibility. This option changes the rules for constructing qualified element names. In pre-slate, double quotes are always literals but in Slate they would be delimiters. It is unlikely that any pre-existing schema names start and end with a double quote but it is possible.
     195
     196• GML Schema names no longer guaranteed to follow the http scheme. Almost every GML schema we've seen sofar follows this URI naming scheme, so customers might complain if we don't always follow it. Therefore, this option does not work well for the Publish as WFS use case. Clients doing this sort of publishing will likely start specifying FdoXmlFlags to WriteXml to ensure that the GML Schema name follows the http scheme.
     197
     198Conclusions:
     199
     200• If we were starting from scratch, this would be a good option. However, at this stage, it is not really viable, due to backward compatibility issues, since these issues wipe out the advantages in simplicity.
     201
     202==== Schema Name Attributes ====
     203
     204Under this option, attributes would be added to the GML and FDO schemas to specify the name of the schema in the other domain.
     205
     206An xs:schema/fdo:name attribute would be added to the  FDO XML format, to specify the equivalent FDO name for schema.
     207
     208!WriteXml() would write this attribute to the GML document.
     209
     210when present, !ReadXml() would take this attribute as the FDO schema name. Otherwise, the FDO Schema name would be generated from the GML name as is currently done.
     211
     212A globalName attribute would be added to the !FdoFeatureSchema class:
     213
     214!ReadXml() would set this attribute.
     215
     216when present, !WriteXml() would use this attribute as the GML schema name. Otherwise, the GML schema name would be generated from the FDO schema name, as is currently done. Hopefully, the !GlobalName would be set to a valid URI. If not then !WriteXml() would escape any non-conforming characters. Alternatively, we could restrict the !GlobalName to be a valid URI.
     217
     218From a semantic standpoint, the name attribute for !FdoFeatureSchema would be unique within a particular domain (e.g.: an FDO Datastore, an !FdoFeatureSchemaCollection in an application). The !GlobalName attribute would be intended to be universally unique, or least unique among all organizations that use the feature schema.
     219
     220Pros:
     221
     222• Good for Schema Exchange  use case. Customer no longer needs to ensure the same url !FdoXmlFlag is used for both !WriteXml() and !ReadXml(). For the Schema Exchange, case it also opens up the possibility of using the Short Prefix as Schema Name method, since it eliminates the problem of reconstituting the GML schema name on !WriteXml().
     223
     224• Flexible. The GML and FDO schema name correspondences can be set on a per-schema basis.
     225
     226• Still a relatively simple option. Much simpler than the Schema Overrides and Schema Namespaces options discussed below.
     227
     228• Good for Publish as WFS use cases. Publisher can set the GML name for each FDO schema explicitly.
     229
     230• GML schema name can be persisted in an FDO Datastore.
     231
     232• Alternatively, GML schema name can be set on the Feature Schema just before it is converted to GML. This can easily be done via the FDO API.
     233
     234Cons:
     235
     236• There is no guarantee that these new settings will be persisted. This limits the cases where these settings can be effective. If an FDO schema goes through the following steps:
     237
     238• Write to GML[[br]]
     239• Read GML into 3rd party application[[br]]
     240• Write from 3rd party application to GML[[br]]
     241• Read from GML[[br]]
     242
     243the fdo:schema name will likely be lost when the schema goes through the 3rd party application.
     244
     245FDO providers would not necessarily be immediately modified to support the GML namespace !FdoFeatureSchema attribute. Therefore, the following steps:
     246
     247• Read from GML[[br]]
     248• Apply schema to FDO datastore[[br]]
     249• Describe schema back from datastore[[br]]
     250• Write schema to GML[[br]]
     251
     252will lose the GML Schema name if the datastore's provider does not handle it. However, this particular problem can be mitigated by ensuring that the SDF and RDBMS providers support this attribute.
     253
     254This con would be applicable to the Schema Exchange and Publish as WFS use cases. Export/Import and WFS Provider would be unaffected.
     255
     256• For cases where the FDO schema name cannot be persisted in the GML document, it would be possible for the application to add it to the document just before it is read into FDO. This is possible to do but not quite straightforward since there is no simple FDO API to do this. It would have to be done via the Xerces DOM classes or by an XSL transformation.
     257
     258• There is overlap between the globalName attribute and the targetNamespace attribute on !FdoSchemaMapping (See next section), since both would represent the GML schema name. We could have a precedence rule (e.g. !FdoSchemaMapping.targetNamespace trumps !FdoFeatureSchema.globalName). However, having multiple places where the same attribute can be set makes the FDO API more complicated.
     259
     260Conclusions
     261
     262• This is a viable option. Although it doesn't help with Schema name translation in all cases, it would still handle a lot of cases
     263
     264• Despite the overlap with GML schema overrides, this would currently be the recommended option, since it is the best one mentioned in this document.