Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » XML Schema Definition (XSD) » "xmlns" in the <schema> element
"xmlns" in the <schema> element [message #565496] Sat, 01 March 2003 14:43
Eclipse UserFriend
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.
Previous Topic:prohibiting attributes in extension
Next Topic:XSDWildcard.getNamespaceConstraint
Goto Forum:
  


Current Time: Wed Nov 26 15:42:01 GMT 2014

Powered by FUDForum. Page generated in 0.03079 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software