Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » change XML schema prefix impossible using WTP XML model
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
Previous Topic:Upgrade to 3.4.1 - Run on server no longer launches initial page
Next Topic:ATTN: Konstantin - FlexibleProjectContainer.java changes from 1.34 to 1.36
Goto Forum:
  


Current Time: Thu Apr 24 11:29:44 EDT 2014

Powered by FUDForum. Page generated in 0.04817 seconds