Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Proper namespace generation in document root
Proper namespace generation in document root [message #431147] Tue, 30 June 2009 09:45 Go to next message
Guido Schnider is currently offline Guido SchniderFriend
Messages: 6
Registered: July 2009
Junior Member
I have a model that has been generated from an xml schema (Learning Object
Metadata) (ecore file see
here:http://www.olat.org/downloads/material/lom.ecore)

When I save the model to xml I get a namespace section like this:

<?xml version="1.0" encoding="utf-8"?>
<lom:Lom xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:lom="http://ltsc.ieee.org/xsd/LOM">
</lom:Lom>

But this is wrong, as I need something like this:

<?xml version="1.0" encoding="UTF-8"?>
<lom xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://ltsc.ieee.org/xsd/LOM"
xsi:schemaLocation="http://ltsc.ieee.org/xsd/lomv1.0/lom.xsd">
</lom>

I played with several setting of the xmlresource options but nothing
helped.

thanks for you time!

guido
Re: Proper namespace generation in document root [message #431154 is a reply to message #431147] Tue, 30 June 2009 10:57 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------030200070809050003070806
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Guido,

Comments below.

Guido Schnider wrote:
> I have a model that has been generated from an xml schema (Learning
> Object Metadata) (ecore file see
> here:http://www.olat.org/downloads/material/lom.ecore)
>
> When I save the model to xml I get a namespace section like this:
>
> <?xml version="1.0" encoding="utf-8"?>
> <lom:Lom xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:lom="http://ltsc.ieee.org/xsd/LOM">
> </lom:Lom>
>
> But this is wrong, as I need something like this:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <lom xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns="http://ltsc.ieee.org/xsd/LOM"
> xsi:schemaLocation="http://ltsc.ieee.org/xsd/lomv1.0/lom.xsd">
> </lom>
They're semantically equivalent and your schemaLocation attribute is
invalid.

http://wiki.eclipse.org/index.php/EMF/FAQ#How_can_I_ensure_t hat_an_xsi:schemaLocation_is_serialized_for_my_packages.3F

You can use documentRoot.getXMLNSPrefixMap().put("", LOMPackage.eNS_URI)
to map the null prefix to some non-null target namespace, but keep in
mind that once you do this, the null namespace is no longer available
for nested element, which will result in an invalid serialization if you
need access to unqualified local element declarations.
>
> I played with several setting of the xmlresource options but nothing
> helped.
>
> thanks for you time!
>
> guido
>

--------------030200070809050003070806
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Guido,<br>
<br>
Comments below.<br>
<br>
Guido Schnider wrote:
<blockquote
cite="mid:0ee027148d986e26d174dadd7738595f$1@www.eclipse.org"
type="cite">I have a model that has been generated from an xml schema
(Learning Object Metadata) (ecore file see
here:<a class="moz-txt-link-freetext" href="http://www.olat.org/downloads/material/lom.ecore">http://www.olat.org/downloads/material/lom.ecore</a>)
<br>
<br>
When I save the model to xml I get a namespace section like this:
<br>
<br>
&lt;?xml version="1.0" encoding="utf-8"?&gt;
<br>
&lt;lom:Lom xmlns:xsi=<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/2001/XMLSchema-instance">"http://www.w3.org/2001/XMLSchema-instance"</a>
xmlns:lom=<a class="moz-txt-link-rfc2396E" href="http://ltsc.ieee.org/xsd/LOM">"http://ltsc.ieee.org/xsd/LOM"</a>&gt;
<br>
&lt;/lom:Lom&gt;
<br>
<br>
But this is wrong, as I need something like this:
<br>
<br>
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
<br>
&lt;lom xmlns:xsi=<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/2001/XMLSchema-instance">"http://www.w3.org/2001/XMLSchema-instance"</a>
xmlns=<a class="moz-txt-link-rfc2396E" href="http://ltsc.ieee.org/xsd/LOM">"http://ltsc.ieee.org/xsd/LOM"</a>
xsi:schemaLocation=<a class="moz-txt-link-rfc2396E" href="http://ltsc.ieee.org/xsd/lomv1.0/lom.xsd">"http://ltsc.ieee.org/xsd/lomv1.0/lom.xsd"</a>&gt;
<br>
&lt;/lom&gt;
<br>
</blockquote>
They're semantically equivalent and your schemaLocation attribute is
invalid. <br>
<blockquote><a
href=" http://wiki.eclipse.org/index.php/EMF/FAQ#How_can_I_ensure_t hat_an_xsi:schemaLocation_is_serialized_for_my_packages.3F"> http://wiki.eclipse.org/index.php/EMF/FAQ#How_can_I_ensure_t hat_an_xsi:schemaLocation_is_serialized_for_my_packages.3F</a><br>
</blockquote>
You can use documentRoot.getXMLNSPrefixMap().put("",
LOMPackage.eNS_URI) to map the null prefix to some non-null target
namespace, but keep in mind that once you do this, the null namespace
is no longer available for nested element, which will result in an
invalid serialization if you need access to unqualified local element
declarations.<br>
<blockquote
cite="mid:0ee027148d986e26d174dadd7738595f$1@www.eclipse.org"
type="cite"><br>
I played with several setting of the xmlresource options but nothing
helped.
<br>
<br>
thanks for you time!
<br>
<br>
guido
<br>
<br>
</blockquote>
</body>
</html>

--------------030200070809050003070806--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Proper namespace generation in document root [message #431158 is a reply to message #431154] Tue, 30 June 2009 13:46 Go to previous messageGo to next message
Guido Schnider is currently offline Guido SchniderFriend
Messages: 6
Registered: July 2009
Junior Member
Thanks for the response, I thought I understand a bit of XML but with this
namespace stuff I'm bit confused.

When you say this both are equivalend why does loading this one with my
emf modelthrows an error:

<?xml version="1.0" encoding="utf-8"?>
<lom xmlns="http://ltsc.ieee.org/xsd/LOM">
</lom>

guido
Re: Proper namespace generation in document root [message #431159 is a reply to message #431158] Tue, 30 June 2009 13:52 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Guido,

Comments below.

Guido Schnider wrote:
> Thanks for the response, I thought I understand a bit of XML but with
> this namespace stuff I'm bit confused.
Yes, I've found that despite the common assertion that XML is simple,
very few people understand the rules for prefix qualification very well
because it's relatively complex.
>
> When you say this both are equivalend why does loading this one with
> my emf modelthrows an error:
>
> <?xml version="1.0" encoding="utf-8"?>
> <lom xmlns="http://ltsc.ieee.org/xsd/LOM">
> </lom>
I don't expect differences in behavior for the root element, but I
suspect there is nested stuff (you haven't told me about yet) that will
cause a problem.

What I described works for the Library XML Schema model, for example.
>
> guido
>
>
>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:EReference on a default ID
Next Topic:TENEO: Problems with AttributeOverride
Goto Forum:
  


Current Time: Tue Apr 23 17:57:41 GMT 2024

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

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

Back to the top