Skip to main content



      Home
Home » Language IDEs » ServerTools (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 UserFriend
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: Sat Jul 05 02:56:21 EDT 2025

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

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

Back to the top