Home » Modeling » EMF » saving objects
|
Re: saving objects [message #407400 is a reply to message #407399] |
Fri, 23 February 2007 21:28 |
Ed Merks Messages: 33140 Registered: July 2009 |
Senior Member |
|
|
This is a multi-part message in MIME format.
--------------030505030604040202090309
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Alex,
Stepping through XMLSaveImpl.addNamespaceDeclarations should be
informative.
protected void addNamespaceDeclarations()
{
EPackage *noNamespacePackage *= helper.getNoNamespacePackage();
Using OPTION_SCHEMA_LOCATION will be partly to blame, but the instance
serialization as you show it really does have a null namespace, so I
suspect that you've specialized something to make the system think that
your package should be treated as the no namespace package.
Aleksandr Kravets wrote:
> Hello,
>
> Before I load my XML document it looks like this:
>
> <iway xmlns="http://www.iwaysoftware.com/designer/model"
> creation_date="02/21/07 10:54:35">
> ....
> ....
> </iway>
>
> But when I save the document, the root element is saved as:
>
> <iway xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:noNamespaceSchemaLocation="http://www.iwaysoftware.com/designer/model"
> creation_date="02/21/07 10:54:35">
>
> My schema does have a target namespace:
>
> xs:schema targetNamespace="http://www.iwaysoftware.com/designer/model">
>
> So why is noNamespaceSchemaLocation inserted?
>
> thanks,
> Alex
>
--------------030505030604040202090309
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Alex,<br>
<br>
Stepping through XMLSaveImpl.addNamespaceDeclarations should be
informative. <br>
<blockquote> protected void addNamespaceDeclarations()<br>
{<br>
EPackage <b>noNamespacePackage </b>=
helper.getNoNamespacePackage();<br>
</blockquote>
<br>
Using OPTION_SCHEMA_LOCATION will be partly to blame, but the instance
serialization as you show it really does have a null namespace, so I
suspect that you've specialized something to make the system think that
your package should be treated as the no namespace package.<br>
<br>
<br>
Aleksandr Kravets wrote:
<blockquote cite="midernlti$tuf$1@utils.eclipse.org" type="cite">Hello,
<br>
<br>
Before I load my XML document it looks like this:
<br>
<br>
<iway xmlns=<a class="moz-txt-link-rfc2396E" href="http://www.iwaysoftware.com/designer/model">"http://www.iwaysoftware.com/designer/model"</a>
creation_date="02/21/07 10:54:35">
<br>
.....
<br>
.....
<br>
</iway>
<br>
<br>
But when I save the document, the root element is saved as:
<br>
<br>
<iway xmlns:xsi=<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/2001/XMLSchema-instance">"http://www.w3.org/2001/XMLSchema-instance"</a>
xsi:noNamespaceSchemaLocation=<a class="moz-txt-link-rfc2396E" href="http://www.iwaysoftware.com/designer/model">"http://www.iwaysoftware.com/designer/model"</a>
creation_date="02/21/07 10:54:35">
<br>
<br>
My schema does have a target namespace:
<br>
<br>
xs:schema
targetNamespace=<a class="moz-txt-link-rfc2396E" href="http://www.iwaysoftware.com/designer/model">"http://www.iwaysoftware.com/designer/model"</a>>
<br>
<br>
So why is noNamespaceSchemaLocation inserted?
<br>
<br>
thanks,
<br>
Alex
<br>
<br>
</blockquote>
<br>
</body>
</html>
--------------030505030604040202090309--
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: saving objects [message #407401 is a reply to message #407400] |
Fri, 23 February 2007 21:56 |
Aleksandr Kravets Messages: 55 Registered: July 2009 |
Member |
|
|
You're right, I created specialized BasicExtendedMetaData class and
overridden String getNamespace(EPackage ePackage) and just returned
null...my mistake.
Another question if I can without starting another thread. I asked
similar question earlier where I needed to load XML file converting
upper case element names to lower. I did that by creating class from
BasicExtendedMetaData, so now I need to save the data converting lower
case letters to upper again. I tried doing it with similar specialized
class but it doesn't work. Are there other methods that I should
override other than getLocalAttribute, getLocalElement and getType. I
tried debugging XMLSaveImpl but can't seem to pinpoint where
ExtendedMetaData is used.
thanks,
Alex
Ed Merks wrote:
> Alex,
>
> Stepping through XMLSaveImpl.addNamespaceDeclarations should be
> informative.
>
> protected void addNamespaceDeclarations()
> {
> EPackage *noNamespacePackage *= helper.getNoNamespacePackage();
>
>
> Using OPTION_SCHEMA_LOCATION will be partly to blame, but the instance
> serialization as you show it really does have a null namespace, so I
> suspect that you've specialized something to make the system think that
> your package should be treated as the no namespace package.
>
>
> Aleksandr Kravets wrote:
>> Hello,
>>
>> Before I load my XML document it looks like this:
>>
>> <iway xmlns="http://www.iwaysoftware.com/designer/model"
>> creation_date="02/21/07 10:54:35">
>> ....
>> ....
>> </iway>
>>
>> But when I save the document, the root element is saved as:
>>
>> <iway xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xsi:noNamespaceSchemaLocation="http://www.iwaysoftware.com/designer/model"
>> creation_date="02/21/07 10:54:35">
>>
>> My schema does have a target namespace:
>>
>> xs:schema targetNamespace="http://www.iwaysoftware.com/designer/model">
>>
>> So why is noNamespaceSchemaLocation inserted?
>>
>> thanks,
>> Alex
>>
>
|
|
|
Re: saving objects [message #407402 is a reply to message #407401] |
Fri, 23 February 2007 22:12 |
Ed Merks Messages: 33140 Registered: July 2009 |
Senior Member |
|
|
Alex,
You'll want to override getName(EStructuralFeature) and possibly
getName(EClassifier) if there are any xsi:types being written.
Aleksandr Kravets wrote:
> You're right, I created specialized BasicExtendedMetaData class and
> overridden String getNamespace(EPackage ePackage) and just returned
> null...my mistake.
>
> Another question if I can without starting another thread. I asked
> similar question earlier where I needed to load XML file converting
> upper case element names to lower. I did that by creating class from
> BasicExtendedMetaData, so now I need to save the data converting lower
> case letters to upper again. I tried doing it with similar specialized
> class but it doesn't work. Are there other methods that I should
> override other than getLocalAttribute, getLocalElement and getType. I
> tried debugging XMLSaveImpl but can't seem to pinpoint where
> ExtendedMetaData is used.
>
> thanks,
> Alex
>
> Ed Merks wrote:
>> Alex,
>>
>> Stepping through XMLSaveImpl.addNamespaceDeclarations should be
>> informative.
>> protected void addNamespaceDeclarations()
>> {
>> EPackage *noNamespacePackage *= helper.getNoNamespacePackage();
>>
>>
>> Using OPTION_SCHEMA_LOCATION will be partly to blame, but the
>> instance serialization as you show it really does have a null
>> namespace, so I suspect that you've specialized something to make the
>> system think that your package should be treated as the no namespace
>> package.
>>
>>
>> Aleksandr Kravets wrote:
>>> Hello,
>>>
>>> Before I load my XML document it looks like this:
>>>
>>> <iway xmlns="http://www.iwaysoftware.com/designer/model"
>>> creation_date="02/21/07 10:54:35">
>>> ....
>>> ....
>>> </iway>
>>>
>>> But when I save the document, the root element is saved as:
>>>
>>> <iway xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>> xsi:noNamespaceSchemaLocation="http://www.iwaysoftware.com/designer/model"
>>> creation_date="02/21/07 10:54:35">
>>>
>>> My schema does have a target namespace:
>>>
>>> xs:schema targetNamespace="http://www.iwaysoftware.com/designer/model">
>>>
>>> So why is noNamespaceSchemaLocation inserted?
>>>
>>> thanks,
>>> Alex
>>>
>>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: saving objects [message #407403 is a reply to message #407402] |
Fri, 23 February 2007 22:17 |
Aleksandr Kravets Messages: 55 Registered: July 2009 |
Member |
|
|
Thank you.
Ed Merks wrote:
> Alex,
>
> You'll want to override getName(EStructuralFeature) and possibly
> getName(EClassifier) if there are any xsi:types being written.
>
>
> Aleksandr Kravets wrote:
>> You're right, I created specialized BasicExtendedMetaData class and
>> overridden String getNamespace(EPackage ePackage) and just returned
>> null...my mistake.
>>
>> Another question if I can without starting another thread. I asked
>> similar question earlier where I needed to load XML file converting
>> upper case element names to lower. I did that by creating class from
>> BasicExtendedMetaData, so now I need to save the data converting lower
>> case letters to upper again. I tried doing it with similar specialized
>> class but it doesn't work. Are there other methods that I should
>> override other than getLocalAttribute, getLocalElement and getType. I
>> tried debugging XMLSaveImpl but can't seem to pinpoint where
>> ExtendedMetaData is used.
>>
>> thanks,
>> Alex
>>
>> Ed Merks wrote:
>>> Alex,
>>>
>>> Stepping through XMLSaveImpl.addNamespaceDeclarations should be
>>> informative.
>>> protected void addNamespaceDeclarations()
>>> {
>>> EPackage *noNamespacePackage *= helper.getNoNamespacePackage();
>>>
>>>
>>> Using OPTION_SCHEMA_LOCATION will be partly to blame, but the
>>> instance serialization as you show it really does have a null
>>> namespace, so I suspect that you've specialized something to make the
>>> system think that your package should be treated as the no namespace
>>> package.
>>>
>>>
>>> Aleksandr Kravets wrote:
>>>> Hello,
>>>>
>>>> Before I load my XML document it looks like this:
>>>>
>>>> <iway xmlns="http://www.iwaysoftware.com/designer/model"
>>>> creation_date="02/21/07 10:54:35">
>>>> ....
>>>> ....
>>>> </iway>
>>>>
>>>> But when I save the document, the root element is saved as:
>>>>
>>>> <iway xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>>> xsi:noNamespaceSchemaLocation="http://www.iwaysoftware.com/designer/model"
>>>> creation_date="02/21/07 10:54:35">
>>>>
>>>> My schema does have a target namespace:
>>>>
>>>> xs:schema targetNamespace="http://www.iwaysoftware.com/designer/model">
>>>>
>>>> So why is noNamespaceSchemaLocation inserted?
>>>>
>>>> thanks,
>>>> Alex
>>>>
>>>
|
|
| | | | | |
Re: saving objects [message #529821 is a reply to message #529762] |
Tue, 27 April 2010 11:03 |
Ed Merks Messages: 33140 Registered: July 2009 |
Senior Member |
|
|
Claus,
Comments below.
Claus Kricke wrote:
> I implemented the method of the FAQ as described but with no luck
> (still no noNamespaceSchemaLocation in the result).
>
> I found the getXSISchemaLocation EMap readily
>
> public EMap<?, ?> getXSISchemaLocation() {
> if (xSISchemaLocation == null) {
> xSISchemaLocation = new
> EcoreEMap(EcorePackage.Literals.ESTRING_TO_STRING_MAP_ENTRY,
> EStringToStringMapEntryImpl.class, this,
> MyPackage.MYP__XSI_SCHEMA_LOCATION);
> }
> return xSISchemaLocation;
> }
>
> but it returns an empty xSISchemaLocation.
It's always empty at first.
> This is why the XMLHandler will not write the location to the file.
> From the code of the XMLHandler, it seams that it'll write the
> noNamespaceSchemaLocation when the key in the <key ,value > pair is
> null and the value is !null.
Yes, I'd expect that.
>
> So I'd like to do something like this in the getXSISchemaLocation():
>
> if ( xSISchemaLocation.isEmpty()) {
> Map<?,String> map = null;
> map.put(null, "MyPack.xsd");
I assume this causes a null pointer exception.
> xSISchemaLocation.set(map);
> }
>
> but can't get it to work ( I'm not familiar enough with the EMF data
> types).
Did you try modifying the generated wizard?
Modifying the generated XyzExample.java like this:
Resource resource =
resourceSet.createResource(URI.createURI("http:///My.library"));
DocumentRoot documentRoot =
LibraryFactory.eINSTANCE.createDocumentRoot();
documentRoot.getXSISchemaLocation().put(null, "foo");
Library root = LibraryFactory.eINSTANCE.createLibrary();
documentRoot.setLibrary(root);
resource.getContents().add(documentRoot);
resource.save(System.out, null);
produces
<?xml version="1.0" encoding="ASCII"?>
<library xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="foo"/>
so I know that works.
>
> Any hints ?
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
| | | |
Goto Forum:
Current Time: Thu Apr 25 06:10:59 GMT 2024
Powered by FUDForum. Page generated in 0.03478 seconds
|