Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » loading XML without namepace declaration
loading XML without namepace declaration [message #430553] Wed, 27 May 2009 09:44 Go to next message
Henrik Rentz-Reichert is currently offline Henrik Rentz-ReichertFriend
Messages: 261
Registered: July 2009
Senior Member
Hi,

I have a set of XML files exported by a tool with names like
example.a.model
example.b.model
example.c.model

Each of them has its own XML schema (schema_a.xsd, schema_b.xsd, ...).

The beginning e.g. looks like

<?xml version="1.0" encoding="UTF-8"?>
<ComponentMain xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="path/to/schema_a.xsd"
toolVersion="V6.0.0" schemaVersion="5.2.1.0">

I can successfully deal with those files (create a EMF model and load them).

The new version of the tool now omits the schema declaration in the header:

<?xml version="1.0" encoding="UTF-8"?>
<ComponentMain toolVersion="V6.0.0" schemaVersion="6.0.0.0">

This means I can only rely on the filename to distinguish the package.

Is there a way to handle this?

Regards,
Henrik
Re: loading XML without namepace declaration [message #430556 is a reply to message #430553] Wed, 27 May 2009 10:14 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Henrik,

Comments below.

Henrik Rentz-Reichert wrote:
> Hi,
>
> I have a set of XML files exported by a tool with names like
> example.a.model
> example.b.model
> example.c.model
>
> Each of them has its own XML schema (schema_a.xsd, schema_b.xsd, ...).
>
> The beginning e.g. looks like
>
> <?xml version="1.0" encoding="UTF-8"?>
> <ComponentMain xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:noNamespaceSchemaLocation="path/to/schema_a.xsd"
> toolVersion="V6.0.0" schemaVersion="5.2.1.0">
>
> I can successfully deal with those files (create a EMF model and load them).
>
> The new version of the tool now omits the schema declaration in the header:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <ComponentMain toolVersion="V6.0.0" schemaVersion="6.0.0.0">
>
> This means I can only rely on the filename to distinguish the package.
>
> Is there a way to handle this?
>
Given they are all no-namespace schemas, you could import them all at
once (specify all three location URIs in the wizard) so that EMF creates
a single EPackage from the composition of them.

Failing that, you could define EMF content types based on the name of
the root element.
> Regards,
> Henrik
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: loading XML without namepace declaration [message #430566 is a reply to message #430556] Wed, 27 May 2009 14:43 Go to previous messageGo to next message
Henrik Rentz-Reichert is currently offline Henrik Rentz-ReichertFriend
Messages: 261
Registered: July 2009
Senior Member
Thanks Ed,

I already did it that way.

I also solved the problem described in my previous post. I just
registered my package in the ResourceSet's PackageRegistry with the null
namespace (since I now the right package from the file extension).

But when I save my model again, I get
<?xml version="1.0" encoding="UTF-8"?>
<ComponentMain xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
xmlns:_1="http://www.w3.org/2000/09/xmldsig#" schemaVersion="6.0.0.0"
toolVersion="V6.0.0">

The third party tool issues a schema validation error when trying to
load my saved file.

When I omit the XMI stuff
<?xml version="1.0" encoding="UTF-8"?>
<ComponentMain xmlns:_1="http://www.w3.org/2000/09/xmldsig#"
schemaVersion="6.0.0.0" toolVersion="V6.0.0">

everything works fine.

Is there a way to get rid of the XMI namespace?

Thanks,
Henrik

Ed Merks wrote:
> Henrik,
>
> Comments below.
>
> Henrik Rentz-Reichert wrote:
>> Hi,
>>
>> I have a set of XML files exported by a tool with names like
>> example.a.model
>> example.b.model
>> example.c.model
>>
>> Each of them has its own XML schema (schema_a.xsd, schema_b.xsd, ...).
>>
>> The beginning e.g. looks like
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <ComponentMain xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xsi:noNamespaceSchemaLocation="path/to/schema_a.xsd"
>> toolVersion="V6.0.0" schemaVersion="5.2.1.0">
>>
>> I can successfully deal with those files (create a EMF model and load
>> them).
>>
>> The new version of the tool now omits the schema declaration in the
>> header:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <ComponentMain toolVersion="V6.0.0" schemaVersion="6.0.0.0">
>>
>> This means I can only rely on the filename to distinguish the package.
>>
>> Is there a way to handle this?
>>
> Given they are all no-namespace schemas, you could import them all at
> once (specify all three location URIs in the wizard) so that EMF creates
> a single EPackage from the composition of them.
>
> Failing that, you could define EMF content types based on the name of
> the root element.
>> Regards,
>> Henrik
>>
Re: loading XML without namepace declaration [message #430568 is a reply to message #430566] Wed, 27 May 2009 15:03 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Henrik,

Be sure to use an XMLResourceImpl not an XMIResourceImpl for saving.
(It sounds like you aren't using the generated XyzResourceFactoryImpl.)


Henrik Rentz-Reichert wrote:
> Thanks Ed,
>
> I already did it that way.
>
> I also solved the problem described in my previous post. I just
> registered my package in the ResourceSet's PackageRegistry with the null
> namespace (since I now the right package from the file extension).
>
> But when I save my model again, I get
> <?xml version="1.0" encoding="UTF-8"?>
> <ComponentMain xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
> xmlns:_1="http://www.w3.org/2000/09/xmldsig#" schemaVersion="6.0.0.0"
> toolVersion="V6.0.0">
>
> The third party tool issues a schema validation error when trying to
> load my saved file.
>
> When I omit the XMI stuff
> <?xml version="1.0" encoding="UTF-8"?>
> <ComponentMain xmlns:_1="http://www.w3.org/2000/09/xmldsig#"
> schemaVersion="6.0.0.0" toolVersion="V6.0.0">
>
> everything works fine.
>
> Is there a way to get rid of the XMI namespace?
>
> Thanks,
> Henrik
>
> Ed Merks wrote:
>
>> Henrik,
>>
>> Comments below.
>>
>> Henrik Rentz-Reichert wrote:
>>
>>> Hi,
>>>
>>> I have a set of XML files exported by a tool with names like
>>> example.a.model
>>> example.b.model
>>> example.c.model
>>>
>>> Each of them has its own XML schema (schema_a.xsd, schema_b.xsd, ...).
>>>
>>> The beginning e.g. looks like
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <ComponentMain xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>> xsi:noNamespaceSchemaLocation="path/to/schema_a.xsd"
>>> toolVersion="V6.0.0" schemaVersion="5.2.1.0">
>>>
>>> I can successfully deal with those files (create a EMF model and load
>>> them).
>>>
>>> The new version of the tool now omits the schema declaration in the
>>> header:
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <ComponentMain toolVersion="V6.0.0" schemaVersion="6.0.0.0">
>>>
>>> This means I can only rely on the filename to distinguish the package.
>>>
>>> Is there a way to handle this?
>>>
>>>
>> Given they are all no-namespace schemas, you could import them all at
>> once (specify all three location URIs in the wizard) so that EMF creates
>> a single EPackage from the composition of them.
>>
>> Failing that, you could define EMF content types based on the name of
>> the root element.
>>
>>> Regards,
>>> Henrik
>>>
>>>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: loading XML without namepace declaration [message #430575 is a reply to message #430568] Wed, 27 May 2009 15:42 Go to previous message
Henrik Rentz-Reichert is currently offline Henrik Rentz-ReichertFriend
Messages: 261
Registered: July 2009
Senior Member
yes, thanks, now it works as desired

Ed Merks wrote:
> Henrik,
>
> Be sure to use an XMLResourceImpl not an XMIResourceImpl for saving.
> (It sounds like you aren't using the generated XyzResourceFactoryImpl.)
>
>
> Henrik Rentz-Reichert wrote:
>> Thanks Ed,
>>
>> I already did it that way.
>>
>> I also solved the problem described in my previous post. I just
>> registered my package in the ResourceSet's PackageRegistry with the null
>> namespace (since I now the right package from the file extension).
>>
>> But when I save my model again, I get
>> <?xml version="1.0" encoding="UTF-8"?>
>> <ComponentMain xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
>> xmlns:_1="http://www.w3.org/2000/09/xmldsig#" schemaVersion="6.0.0.0"
>> toolVersion="V6.0.0">
>>
>> The third party tool issues a schema validation error when trying to
>> load my saved file.
>>
>> When I omit the XMI stuff
>> <?xml version="1.0" encoding="UTF-8"?>
>> <ComponentMain xmlns:_1="http://www.w3.org/2000/09/xmldsig#"
>> schemaVersion="6.0.0.0" toolVersion="V6.0.0">
>>
>> everything works fine.
>>
>> Is there a way to get rid of the XMI namespace?
>>
>> Thanks,
>> Henrik
>>
>> Ed Merks wrote:
>>
>>> Henrik,
>>>
>>> Comments below.
>>>
>>> Henrik Rentz-Reichert wrote:
>>>
>>>> Hi,
>>>>
>>>> I have a set of XML files exported by a tool with names like
>>>> example.a.model
>>>> example.b.model
>>>> example.c.model
>>>>
>>>> Each of them has its own XML schema (schema_a.xsd, schema_b.xsd, ...).
>>>>
>>>> The beginning e.g. looks like
>>>>
>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>> <ComponentMain xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
>>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>>> xsi:noNamespaceSchemaLocation="path/to/schema_a.xsd"
>>>> toolVersion="V6.0.0" schemaVersion="5.2.1.0">
>>>>
>>>> I can successfully deal with those files (create a EMF model and load
>>>> them).
>>>>
>>>> The new version of the tool now omits the schema declaration in the
>>>> header:
>>>>
>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>> <ComponentMain toolVersion="V6.0.0" schemaVersion="6.0.0.0">
>>>>
>>>> This means I can only rely on the filename to distinguish the package.
>>>>
>>>> Is there a way to handle this?
>>>>
>>> Given they are all no-namespace schemas, you could import them all at
>>> once (specify all three location URIs in the wizard) so that EMF creates
>>> a single EPackage from the composition of them.
>>>
>>> Failing that, you could define EMF content types based on the name of
>>> the root element.
>>>
>>>> Regards,
>>>> Henrik
>>>>
Previous Topic:Override behavior of KEEP_DEFAULT_CONTENT
Next Topic:Dynamic EMF: the feature 'xyz' is not a valid feature
Goto Forum:
  


Current Time: Thu Apr 25 07:11:15 GMT 2024

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

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

Back to the top