"xmlns" in the <schema> element [message #565496] |
Sat, 01 March 2003 14:43 |
Eclipse User |
|
|
|
Originally posted by: paechoi.earthlink.net
When I tried to create a schema that contains only the plain <schema>
element without
any attribute, I don't see how to do it at this moment with Eclipse/XSD. The
following
code snippet shows the schema as follows:
// ####################### CODE SNIPPET #########################
public class XMLSchemaDemo {
/** Save the schema */
private void saveXMLSchema(XSDSchema xmlSchema, String
xmlSchemaURIToSave) {
try {
ResourceSet resourceSet = new ResourceSetImpl();
Resource resource = new
XSDResourceImpl(URI.createDeviceURI(xmlSchemaURIToSave));
resource.getContents().add(xmlSchema);
resourceSet.getResources().add(resource);
resource.save(Collections.EMPTY_MAP);
} catch (Exception ex) {
System.out.println(ex.getLocalizedMessage());
ex.printStackTrace();
}
}
/** doIt -- the initial method */
private void doIt() {
XSDSchema xmlSchema = XSDFactory.eINSTANCE.createXSDSchema();
System.out.println(xmlSchema);
saveXMLSchema(xmlSchema, "./test-xsd.xsd");
}
/** main - the main entry */
public static void main(String[] args) {
XMLSchemaDemo app = new XMLSchemaDemo ();
app.doIt();
}
}
// ####################### Print Out #############################
org.eclipse.xsd.impl.XSDSchemaImpl@276af2 (element: null) (document: null,
schemaLocation: null, targetNamespace: null, attributeFormDefault: <unset>,
elementFormDefault: <unset>, finalDefault: null, blockDefault: null,
version: null)
As you can see the "element" is null same as others, but the *actual* output
is as follows:
//###################### Schema Output ##########################
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns=""/>
In the XSDSchemaImpl class, there is a method called,
getQNamePrefixToNamespaceMap(),
which returns java.util.Map. But it returns 0 for its size. How can we make
an initial schema
as follows:
<?xml version="1.0" encoding="UTF-8"?>
<schema/>
Any comments?
Pae
P.S.: This is not related to the validation nor well-formedness so that no
comment
needed for that.
|
|
|
Powered by
FUDForum. Page generated in 0.04035 seconds