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:

Thanks. That's all I need to know. I will find a workaround for my specific
need.

Regards,

Pae

"Ed Merks" <merks@ca.ibm.com> wrote in message
news:3E6348D1.ED831EE7@ca.ibm.com...
Pae,
You cannot create this serialization with the XSD model.
<?xml version="1.0" encoding="UTF-8"?>
<schema/>
A schema with a null getSchemaForSchemaQNamePrefix and a
getQNamePrefixToNamespaceMap that maps null to null will serialize to this
syntactically equivalent form:
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns=""/>

Pae Choi wrote:
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.

Thanks. That's all I need to know. I will find a workaround for my specific
need.

Regards,

Pae

"Ed Merks" <merks@ca.ibm.com> wrote in message
news:3E6348D1.ED831EE7@ca.ibm.com...
Pae,
You cannot create this serialization with the XSD model.
<?xml version="1.0" encoding="UTF-8"?>
<schema/>
A schema with a null getSchemaForSchemaQNamePrefix and a
getQNamePrefixToNamespaceMap that maps null to null will serialize to this
syntactically equivalent form:
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns=""/>

Pae Choi wrote:
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.