[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[Wtp-wst-dev] Namespaces for Instances
|
I'm trying to fix a bug/feature that I found with the XML Instance
generation based off an XSD in the 1.5.x branch. The problem is that
not all Namespaces are being populated into the Namespace Table from the
Grammar selection dialog of the create NewXMLWizard, throught he
NewXMLGenerator. What happens is that if the root XSD does not have
any Import statements in it, it isn't picking up the import statements
that are farther down in the hierarchy of included XSDs. If the root
XSD does have imports, it only picks up those imports at the root level,
and not any that are included.
So it's only looking at the root level for namespaces to use.
As far as I can tell, the place where the XSD CMDocuments are created
for the ContentBuilder is within the XSDImpl.java. Which I believe the
correction needs to be made in the getImportedNamespaceInfo. This code
needs to search not only the current schema but any included schema to
and also needs to go into the Imported schema to correctly get all
possible namespaces that could be used. Here is the current code:
/**
* Gather information on namespaces used in external references.
*
* @param theXSDSchema -
* the corresponding schema node
* @param list -
* the list of imported namespaces.
*/
public void getImportedNamespaceInfo(XSDSchema theXSDSchema, List list)
{
for (Iterator iterator = theXSDSchema.getContents().iterator();
iterator.hasNext();)
{
XSDSchemaContent content = (XSDSchemaContent) iterator.next();
content.
if (content instanceof XSDImport)
{
XSDImport xImport = (XSDImport) content;
XSDSchema importedXSDSchema = xImport.getResolvedSchema();
NamespaceInfo info = new NamespaceInfo();
info.uri = xImport.getNamespace();
info.prefix = getPrefix(importedXSDSchema, info.uri);
info.locationHint = xImport.getSchemaLocation();
if (importedXSDSchema != null)
{
info.isPrefixRequired = isPrefixRequired(importedXSDSchema);
}
list.add(info);
}
}
}
The above just iterates the current Schema past and doesn't go into them
to find check to see if there are any additional ones it needs to pull.
Is there a way in the EMF XSDInfoSet to retrieve all the namespaces
including the ones that are in the imports or includes? If so then it
would seem you want to iterate the namespaces, and not necessarily just
the imports in the root schema.
Dave