Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Use DTD DOCTYPE to resolve an XMLSchema
Use DTD DOCTYPE to resolve an XMLSchema [message #536151] Thu, 27 May 2010 09:22 Go to next message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
Hi,

I have this XML instances (Reverse engineerd Hibernate mapping), which I
can't rework and come in like this:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD
3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated May 20, 2010 3:22:39 PM by Hibernate Tools 3.3.0.GA -->
<hibernate-mapping>


I have an ecore model, which can process these files, with a schema
definition: http://hibernate.sourceforge.net/hbm30


In order for the deserializer to work, I now need to manually add xmlns
with nsprefix as in this example:

<hbm30:hibernate-mapping
xmlns:hbm30="http://hibernate.sourceforge.net/hbm30">


the question is, can I somehow tell the deserializer to find the ecore
package from the DTD declaration in the XML instance?


Note: this work is to generate Teneo capable ecore models from ad-hoc
DB's using hibernate reverse engineering tools. It will be contributed
to the commnity if any use.

Cheers Christophe
Re: Use DTD DOCTYPE to resolve an XMLSchema [message #536200 is a reply to message #536151] Thu, 27 May 2010 11:02 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33216
Registered: July 2009
Senior Member
Christophe,

Comments below.

Christophe Bouhier wrote:
> Hi,
>
> I have this XML instances (Reverse engineerd Hibernate mapping), which
> I can't rework and come in like this:
>
> <?xml version="1.0"?>
> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD
> 3.0//EN"
> "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
> <!-- Generated May 20, 2010 3:22:39 PM by Hibernate Tools 3.3.0.GA -->
> <hibernate-mapping>
>
>
> I have an ecore model, which can process these files, with a schema
> definition: http://hibernate.sourceforge.net/hbm30
>
>
> In order for the deserializer to work, I now need to manually add
> xmlns with nsprefix as in this example:
>
> <hbm30:hibernate-mapping
> xmlns:hbm30="http://hibernate.sourceforge.net/hbm30">
>
>
> the question is, can I somehow tell the deserializer to find the ecore
> package from the DTD declaration in the XML instance?
I've never tried to do it from the doctype, but that information is
recorded in getSystemId and getPublicId in XMLResource.
>
>
> Note: this work is to generate Teneo capable ecore models from ad-hoc
> DB's using hibernate reverse engineering tools. It will be contributed
> to the commnity if any use.
Does your instance actually conform to the schema? I.e., is it a schema
with no target namespace?
>
> Cheers Christophe
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Use DTD DOCTYPE to resolve an XMLSchema [message #536262 is a reply to message #536200] Thu, 27 May 2010 13:32 Go to previous messageGo to next message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
Hi Ed,


> I've never tried to do it from the doctype, but that information is
> recorded in getSystemId and getPublicId in XMLResource.

The XMLResource doesn't get created if the schema is not present in the
instance. (I doubt I fully understand, what could be done with this?)


> Does your instance actually conform to the schema? I.e., is it a schema
> with no target namespace?

It is a chema with a targetnamespace., so if I remove it, would it work?

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://hibernate.sourceforge.net/hbm30"
xmlns="http://hibernate.sourceforge.net/hbm30"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore">
.....


rgds Christophe



Ed Merks wrote:
> Christophe,
>
> Comments below.
>
> Christophe Bouhier wrote:
>> Hi,
>>
>> I have this XML instances (Reverse engineerd Hibernate mapping), which
>> I can't rework and come in like this:
>>
>> <?xml version="1.0"?>
>> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD
>> 3.0//EN"
>> "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
>> <!-- Generated May 20, 2010 3:22:39 PM by Hibernate Tools 3.3.0.GA -->
>> <hibernate-mapping>
>>
>>
>> I have an ecore model, which can process these files, with a schema
>> definition: http://hibernate.sourceforge.net/hbm30
>>
>>
>> In order for the deserializer to work, I now need to manually add
>> xmlns with nsprefix as in this example:
>>
>> <hbm30:hibernate-mapping
>> xmlns:hbm30="http://hibernate.sourceforge.net/hbm30">
>>
>>
>> the question is, can I somehow tell the deserializer to find the ecore
>> package from the DTD declaration in the XML instance?
> I've never tried to do it from the doctype, but that information is
> recorded in getSystemId and getPublicId in XMLResource.
>>
>>
>> Note: this work is to generate Teneo capable ecore models from ad-hoc
>> DB's using hibernate reverse engineering tools. It will be contributed
>> to the commnity if any use.
> Does your instance actually conform to the schema? I.e., is it a schema
> with no target namespace?
>>
>> Cheers Christophe
>>
Re: Use DTD DOCTYPE to resolve an XMLSchema [message #536263 is a reply to message #536262] Thu, 27 May 2010 13:37 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33216
Registered: July 2009
Senior Member
Christophe,

Comments below.

Christophe Bouhier wrote:
> Hi Ed,
>
>
> > I've never tried to do it from the doctype, but that information is
> > recorded in getSystemId and getPublicId in XMLResource.
>
> The XMLResource doesn't get created if the schema is not present in
> the instance. (I doubt I fully understand, what could be done with this?)
The resource itself is doing the loading so it must be created. Just
because ResourceSet.getResource throws an exception doesn't mean the
resource didn't get created.
>
>
> > Does your instance actually conform to the schema? I.e., is it a
> schema
> > with no target namespace?
>
> It is a chema with a targetnamespace., so if I remove it, would it work?
>
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> targetNamespace="http://hibernate.sourceforge.net/hbm30"
> xmlns="http://hibernate.sourceforge.net/hbm30"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore">
> ....
Then the instance really must have that namespace to conform or you
should remove the target namespace and then the generated resource
factory should produce a resource that's able to open your content.
>
>
> rgds Christophe
>
>
>
> Ed Merks wrote:
>> Christophe,
>>
>> Comments below.
>>
>> Christophe Bouhier wrote:
>>> Hi,
>>>
>>> I have this XML instances (Reverse engineerd Hibernate mapping),
>>> which I can't rework and come in like this:
>>>
>>> <?xml version="1.0"?>
>>> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping
>>> DTD 3.0//EN"
>>> "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
>>> <!-- Generated May 20, 2010 3:22:39 PM by Hibernate Tools 3.3.0.GA -->
>>> <hibernate-mapping>
>>>
>>>
>>> I have an ecore model, which can process these files, with a schema
>>> definition: http://hibernate.sourceforge.net/hbm30
>>>
>>>
>>> In order for the deserializer to work, I now need to manually add
>>> xmlns with nsprefix as in this example:
>>>
>>> <hbm30:hibernate-mapping
>>> xmlns:hbm30="http://hibernate.sourceforge.net/hbm30">
>>>
>>>
>>> the question is, can I somehow tell the deserializer to find the
>>> ecore package from the DTD declaration in the XML instance?
>> I've never tried to do it from the doctype, but that information is
>> recorded in getSystemId and getPublicId in XMLResource.
>>>
>>>
>>> Note: this work is to generate Teneo capable ecore models from
>>> ad-hoc DB's using hibernate reverse engineering tools. It will be
>>> contributed to the commnity if any use.
>> Does your instance actually conform to the schema? I.e., is it a
>> schema with no target namespace?
>>>
>>> Cheers Christophe
>>>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Use DTD DOCTYPE to resolve an XMLSchema [message #536305 is a reply to message #536263] Thu, 27 May 2010 15:13 Go to previous messageGo to next message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
>>
>> The XMLResource doesn't get created if the schema is not present in
>> the instance. (I doubt I fully understand, what could be done with
this?)
> The resource itself is doing the loading so it must be created. Just
> because ResourceSet.getResource throws an exception doesn't mean the
> resource didn't get created.

mmmh, that's right XMLLoadImpl

this would happen before the parsing.

String resourceURI = resource.getURI().toString();
inputSource.setPublicId(resourceURI);
inputSource.setSystemId(resourceURI);
inputSource.setEncoding(resource.getEncoding());

Ok, so I would retrieve the getSystemId/GetPublicId, translate the DTD
URI to my schema URI with a custom loader and then...Not sure how I
should tell the loader that my instance would/should conform to the
resolved. Could I use one of the options, to point to the schema location?

> Then the instance really must have that namespace to conform or you
> should remove the target namespace and then the generated resource
> factory should produce a resource that's able to open your content.
>>

That's propably easier to achieve.

Thanks! Christophe

Ed Merks wrote:
> Christophe,
>
> Comments below.
>
> Christophe Bouhier wrote:
>> Hi Ed,
>>
>>
>> > I've never tried to do it from the doctype, but that information is
>> > recorded in getSystemId and getPublicId in XMLResource.
>>
>> The XMLResource doesn't get created if the schema is not present in
>> the instance. (I doubt I fully understand, what could be done with this?)
> The resource itself is doing the loading so it must be created. Just
> because ResourceSet.getResource throws an exception doesn't mean the
> resource didn't get created.
>>
>>
>> > Does your instance actually conform to the schema? I.e., is it a
>> schema
>> > with no target namespace?
>>
>> It is a chema with a targetnamespace., so if I remove it, would it work?
>>
>> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
>> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
>> targetNamespace="http://hibernate.sourceforge.net/hbm30"
>> xmlns="http://hibernate.sourceforge.net/hbm30"
>> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore">
>> ....
> Then the instance really must have that namespace to conform or you
> should remove the target namespace and then the generated resource
> factory should produce a resource that's able to open your content.
>>
>>
>> rgds Christophe
>>
>>
>>
>> Ed Merks wrote:
>>> Christophe,
>>>
>>> Comments below.
>>>
>>> Christophe Bouhier wrote:
>>>> Hi,
>>>>
>>>> I have this XML instances (Reverse engineerd Hibernate mapping),
>>>> which I can't rework and come in like this:
>>>>
>>>> <?xml version="1.0"?>
>>>> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping
>>>> DTD 3.0//EN"
>>>> "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
>>>> <!-- Generated May 20, 2010 3:22:39 PM by Hibernate Tools 3.3.0.GA -->
>>>> <hibernate-mapping>
>>>>
>>>>
>>>> I have an ecore model, which can process these files, with a schema
>>>> definition: http://hibernate.sourceforge.net/hbm30
>>>>
>>>>
>>>> In order for the deserializer to work, I now need to manually add
>>>> xmlns with nsprefix as in this example:
>>>>
>>>> <hbm30:hibernate-mapping
>>>> xmlns:hbm30="http://hibernate.sourceforge.net/hbm30">
>>>>
>>>>
>>>> the question is, can I somehow tell the deserializer to find the
>>>> ecore package from the DTD declaration in the XML instance?
>>> I've never tried to do it from the doctype, but that information is
>>> recorded in getSystemId and getPublicId in XMLResource.
>>>>
>>>>
>>>> Note: this work is to generate Teneo capable ecore models from
>>>> ad-hoc DB's using hibernate reverse engineering tools. It will be
>>>> contributed to the commnity if any use.
>>> Does your instance actually conform to the schema? I.e., is it a
>>> schema with no target namespace?
>>>>
>>>> Cheers Christophe
>>>>
Re: Use DTD DOCTYPE to resolve an XMLSchema [message #536327 is a reply to message #536305] Thu, 27 May 2010 16:16 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33216
Registered: July 2009
Senior Member
Christophe,

Comments below.

Christophe Bouhier wrote:
>
> >>
> >> The XMLResource doesn't get created if the schema is not present in
> >> the instance. (I doubt I fully understand, what could be done with
> this?)
> > The resource itself is doing the loading so it must be created. Just
> > because ResourceSet.getResource throws an exception doesn't mean the
> > resource didn't get created.
>
> mmmh, that's right XMLLoadImpl
>
> this would happen before the parsing.
>
> String resourceURI = resource.getURI().toString();
> inputSource.setPublicId(resourceURI);
> inputSource.setSystemId(resourceURI);
> inputSource.setEncoding(resource.getEncoding());
These things are populated from the information of what's being parsed.
>
> Ok, so I would retrieve the getSystemId/GetPublicId, translate the DTD
> URI to my schema URI with a custom loader and then...Not sure how I
> should tell the loader that my instance would/should conform to the
> resolved. Could I use one of the options, to point to the schema
> location?
While processing the root element, XMLHandler.getPackageForURI will be
called so that that point I suppose you could use the public/system ID
to locate package for the null namespace.
>
> > Then the instance really must have that namespace to conform or you
> > should remove the target namespace and then the generated resource
> > factory should produce a resource that's able to open your content.
> >>
>
> That's propably easier to achieve.
Yes, it should just work and in the end, one really ought to have a
schema to which the instance actually conforms...
>
> Thanks! Christophe
>
> Ed Merks wrote:
>> Christophe,
>>
>> Comments below.
>>
>> Christophe Bouhier wrote:
>>> Hi Ed,
>>>
>>>
>>> > I've never tried to do it from the doctype, but that information is
>>> > recorded in getSystemId and getPublicId in XMLResource.
>>>
>>> The XMLResource doesn't get created if the schema is not present in
>>> the instance. (I doubt I fully understand, what could be done with
>>> this?)
>> The resource itself is doing the loading so it must be created. Just
>> because ResourceSet.getResource throws an exception doesn't mean the
>> resource didn't get created.
>>>
>>>
>>> > Does your instance actually conform to the schema? I.e., is it a
>>> schema
>>> > with no target namespace?
>>>
>>> It is a chema with a targetnamespace., so if I remove it, would it
>>> work?
>>>
>>> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
>>> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
>>> targetNamespace="http://hibernate.sourceforge.net/hbm30"
>>> xmlns="http://hibernate.sourceforge.net/hbm30"
>>> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore">
>>> ....
>> Then the instance really must have that namespace to conform or you
>> should remove the target namespace and then the generated resource
>> factory should produce a resource that's able to open your content.
>>>
>>>
>>> rgds Christophe
>>>
>>>
>>>
>>> Ed Merks wrote:
>>>> Christophe,
>>>>
>>>> Comments below.
>>>>
>>>> Christophe Bouhier wrote:
>>>>> Hi,
>>>>>
>>>>> I have this XML instances (Reverse engineerd Hibernate mapping),
>>>>> which I can't rework and come in like this:
>>>>>
>>>>> <?xml version="1.0"?>
>>>>> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping
>>>>> DTD 3.0//EN"
>>>>> "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
>>>>> <!-- Generated May 20, 2010 3:22:39 PM by Hibernate Tools 3.3.0.GA
>>>>> -->
>>>>> <hibernate-mapping>
>>>>>
>>>>>
>>>>> I have an ecore model, which can process these files, with a schema
>>>>> definition: http://hibernate.sourceforge.net/hbm30
>>>>>
>>>>>
>>>>> In order for the deserializer to work, I now need to manually add
>>>>> xmlns with nsprefix as in this example:
>>>>>
>>>>> <hbm30:hibernate-mapping
>>>>> xmlns:hbm30="http://hibernate.sourceforge.net/hbm30">
>>>>>
>>>>>
>>>>> the question is, can I somehow tell the deserializer to find the
>>>>> ecore package from the DTD declaration in the XML instance?
>>>> I've never tried to do it from the doctype, but that information is
>>>> recorded in getSystemId and getPublicId in XMLResource.
>>>>>
>>>>>
>>>>> Note: this work is to generate Teneo capable ecore models from
>>>>> ad-hoc DB's using hibernate reverse engineering tools. It will be
>>>>> contributed to the commnity if any use.
>>>> Does your instance actually conform to the schema? I.e., is it a
>>>> schema with no target namespace?
>>>>>
>>>>> Cheers Christophe
>>>>>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:XSD to Ecore Mapping for typed References
Next Topic:[CDO Teneo] Composite key support
Goto Forum:
  


Current Time: Thu Sep 19 23:14:51 GMT 2024

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

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

Back to the top