change XML schema prefix impossible using WTP XML model [message #229902] |
Wed, 01 April 2009 12:05 |
Eclipse User |
|
|
|
Originally posted by: jacek.pospychala.pl.ibm.com
Hi WTP!
I'm loading an XSD model using following WTP code seen at
http://dev.eclipse.org/mhonarc/newsLists/news.eclipse.webtoo ls/msg18292.html
However, I'm not able to change it's schema prefix then (using
XSDSchema.setSchemaForSchemaQNamePrefix(String)). Should I take
additional steps before changing the prefix, or is this a bug?
I noticed the same code works when loading model with plan EMF-XSD.
String path = "c:\\path\\to\\xml.xsd";
IStructuredDocument document = null;
IStructuredModel model = null;
ModelHandlerForXML xmlModelHandler = new ModelHandlerForXML();
IDocumentLoader loader = xmlModelHandler.getDocumentLoader();
FileInputStream file;
try {
file = new FileInputStream(path);
InputStream inputStream =Utilities.getMarkSupportedStream(file);
document = (IStructuredDocument) loader.
createNewStructuredDocument(path, inputStream,
EncodingRule.FORCE_DEFAULT);
} catch (FileNotFoundException e) {
return null;
} catch (IOException e) {
return null;
}
IModelLoader xmlModelLoader = xmlModelHandler.getModelLoader();
model = xmlModelLoader.createModel(document, path, xmlModelHandler);
XSDSchema schema2 = XSDModelAdapter.lookupOrCreateSchema(((IDOMModel)
model).getDocument());
System.out.println(schema2.getSchemaForSchemaNamespace()); // Prints
"http://www.w3.org/2001/XMLSchema"
schema2.setSchemaForSchemaQNamePrefix("abc");
System.out.println(schema2.getSchemaForSchemaNamespace());
// prints "null", whereas should "abc"
thanks!
Jacek
|
|
|
Powered by
FUDForum. Page generated in 0.04255 seconds