|
Re: DTD to Ecore [message #407121 is a reply to message #407119] |
Wed, 14 February 2007 11:31 |
Eclipse User |
|
|
|
Originally posted by: joerg.von.frantzius.artnology.com
<!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">
Hello Annamalai,<br>
<br>
we made some good experiences with <a
href="http://www.thaiopensource.com/relaxng/trang.html">Trang</a> for
converting DTDs to XSDs. I don't know if that will help you with your
DTDs included in the actual XML files, though.<br>
<br>
<br>
Annamalai C wrote:
<blockquote
cite="mid:2daf51f966dd3a0b8d5ee983629567b7$1@www.eclipse.org"
type="cite">Hello All
<br>
<br>
I have a slightly different requirement. I tried to convert Schema to
Ecore programmatically and was successful in loading an XML file
corresponding to that XSD.
<br>
<br>
Now my problem is for all my XML i have DTD and not XSD. Therefore is
there any way that i can map an DTD to Ecore. Or atleast a DTD to XSD
Mapping, then i can do the XSD to Ecore and loading of XML.
<br>
<br>
Another information i need is, the DTD information is present inside
each XML File. So i need to even retrieve this information to find out
the DTD and then do the step as described above.
<br>
<br>
Why we want to do this is as each XML has its own DTD its not possible
to make static models for each of the XML. Therefore looking at Dynamic
EMF as the solution.
<br>
<br>
regards
<br>
Malai
<br>
<br>
</blockquote>
<br>
</body>
</html>
|
|
|
|
|
|
Re: DTD to Ecore [message #407133 is a reply to message #407128] |
Wed, 14 February 2007 15:04 |
Eclipse User |
|
|
|
Originally posted by: joerg.von.frantzius.artnology.com
Annamalai C wrote:
> Hello
> Thanks for your quick reply. Just one clarification in my doubt. The
> path of the DTD is present in the XML and not the whole DTD. Therefore
> now i need to retrieve this path and find the DTD and convert to XSD
> and then use the XSDEcoreGenerator.
By the way I think trang is open source and written in Java, so
theoretically you should be able to use Trang to do an on-the-fly
conversion from DTD to XSD...
>
> Or is it easier to write a DTDEcoreGenerator. Wouldnt writing an
> DTDEcoreGenerator be a huge task by itself.
>
> Awaiting your replies as its a little urgent. We are in the process of
> prototyping a solution.
>
> regards
> Malai
>
|
|
|
|
|
Re: DTD to Ecore [message #407167 is a reply to message #407165] |
Fri, 16 February 2007 11:36 |
Ed Merks Messages: 33141 Registered: July 2009 |
Senior Member |
|
|
This is a multi-part message in MIME format.
--------------030809020307030007050500
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit
Malai,
When loading from an input stream, XMLLoadImpl will create an input
source as follows:
InputSource inputSource = new InputSource(is);
if (resource.getURI() != null)
{
String resourceURI = resource.getURI().toString();
inputSource.setPublicId(resourceURI);
inputSource.setSystemId(resourceURI);
inputSource.setEncoding(encoding);
}
This will ensure that during SAX parsing, the XMLHandler.locator knows
the URI of the input stream itself. XMLHandler.startDTD does the following:
public void startDTD(String name, String publicId, String systemId)
{
xmlResource.setDoctypeInfo(publicId, systemId);
}
So that should correctly record the public ID and system ID of the DTD.
What you'll still need to do is specialize the resolveEntity method:
public InputSource resolveEntity(String publicId, String systemId)
throws SAXException
{
return null;
}
which is called when the SAX parser needs to locate the DTD (or entity).
Since no one has ever asked for this to be supported directly by EMF,
there is no default implementation, but it strikes me that we could
probably provide a pretty nice default implementation that uses the
entity's public/system ID to resolve an absolute URI (in the case of
relative URIs) and then use the containing resource's resource set's URI
converter to create an input stream and then wrap that as an input
source. If you care to send a small example of a document that
references a DTD along with its DTD, I'll probably be able to whip a
sample together very quickly (although I'll be away for the whole
morning and part of the afternoon). I can't do the DTD -> XSD part
though. Have a look at processSchemaLocations to see how it uses the
ecoreBuilder to process the schemas.
Annamalai C wrote:
> Hello Ed
>
> I tried to provide an XML with DOCTYPE SYSTEM pointing to a DTD and i
> landed up with an Exception during the parsing. If i use
> resource.load(options) he intern calls load(inputStream, options) and
> not load(node, options) which is to be used to call startDTD or even
> anything related to DTD.
>
> At the end if you trace through the PUBLIC ID and SYSTEM ID are found
> to be null as they are calling load(inputStream, options)
>
> now i am really lost of what should be my next step.
>
> My Problem again
> I have XML with has DTD Path inside the XML. I need to retrieve this
> path and convert the DTD into XSD and then load the XML into an Ecore
> that corresponds to the XSD created.
>
> Solution
> For DTD to XSD i can use Trang. XSD to Ecore i have the code working.
> XML Loading i have the code working.
>
> But then to convert the DTD to XSD, i need the DTD Path.
> After the XSD is created, how do i tell my loader to use this XSD and
> not the DTD information to load the XML.
>
> Hope i was clear enough to express my problem. Help would be really
> appreciated as i seem lost with lots to EMF Code as i run through
> XMLResourceImpl, XMLLoadImpl etc.
>
> regards
> Malai
>
>
--------------030809020307030007050500
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit
<!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">
Malai,<br>
<br>
When loading from an input stream, XMLLoadImpl will create an input
source as follows:<br>
<blockquote>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
|
|
|
|
Re: DTD to Ecore [message #407229 is a reply to message #407228] |
Mon, 19 February 2007 13:09 |
Ed Merks Messages: 33141 Registered: July 2009 |
Senior Member |
|
|
This is a multi-part message in MIME format.
--------------040401060201080408060403
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit
Malai,
XMLHandler has this method. First it processes the schema locations, if
there are any, and then, if it's supposed to process any XML whatsoever,
it makes sure to demand create a package to handle the root element.
protected void handleTopLocations(String prefix, String name)
{
processSchemaLocations(prefix, name);
if (processAnyXML)
{
// Ensure that anything can be handled, even if it's not
recognized.
//
String uri = helper.getURI(prefix);
if (extendedMetaData.getPackage(uri) == null)
{
extendedMetaData.demandFeature(uri, name, true);
}
}
}
So probably the processSchemaLocations is the best place to ensure that
a Ecore model can be found for the namespace of the root element.
Annamalai C wrote:
> Hello Ed
>
> Thank you for your support. I have requested an feature enhancement in
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=174617
>
> I have tested your patch. Works amazingly good. Thank you once again
> ... would look into it to see what i can do.
>
> My immd task is
> As of now if no XSD Information is provided inside the XML then EMF
> loads the resource with a default AnyType XSD. I would like to
> interrupt this and provide my own XSD as the default XSD if no XSD
> Information is found. How is this possible ?
>
> I am sure you would have the answer right away ... Thank you once again.
> regards
> Annamalai
>
--------------040401060201080408060403
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit
<!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">
Malai,<br>
<br>
XMLHandler has this method.
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: DTD to Ecore [message #418190 is a reply to message #418058] |
Fri, 04 April 2008 14:27 |
Eclipse User |
|
|
|
Originally posted by: joerg.von.frantzius.artnology.com
<!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">
Last time I had a look, Trang was the best one around. Does anybody
know of any good converters other than trang?<br>
<br>
Ed Merks schrieb:
<blockquote cite="mid:ft51sf$7hd$2@build.eclipse.org" type="cite">
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
Jurrie,<br>
<br>
Failing that, I think there are quite a few DTD -> XSD converters
around so perhaps indirectly you can solve your problem that way.<br>
<br>
<br>
Jurrie Overgoor wrote:
<blockquote cite="mid:ft50u2$o33$1@build.eclipse.org" type="cite">
<pre wrap="">Ed Merks wrote:
</pre>
<blockquote type="cite">
<pre wrap="">There's 175843 <a moz-do-not-send="true"
class="moz-txt-link-rfc2396E"
href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=175843"><https://bugs.eclipse.org/bugs/show_bug.cgi?id=175843></a>
open but I didn't monitor it closely. :-(
</pre>
</blockquote>
<pre wrap=""><!---->
Thanks for your reply Ed. I did not see any updates regarding bug
175843. Nevertheless I've voted for it. Maybe, just maybe it'll trigger
some development by someone.
Woohoo! Go bug 175843! GO!! :)
With kind regards,
Jurrie
</pre>
</blockquote>
<br>
</blockquote>
<br>
</body>
</html>
|
|
|