Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » XSD as XML representation for JET
XSD as XML representation for JET [message #14609] Wed, 02 May 2007 09:57 Go to next message
Vladimir Sosnin is currently offline Vladimir SosninFriend
Messages: 19
Registered: July 2009
Junior Member
Hello,

I have an XSD schema and try to use it as input for JET2 transformation.
But this schema either loaded as Ecore XSD model or not loaded at all.
Even if I try to rename it to *.xml it can't be loaded by
org.eclipse.jet.emfxml model loader.

How can I load schema document as a simple XML file?

P.S Debug log of org.eclipse.jet.emfxml on loading XSD:
templates/dump.jet(3,1): <c:load var="simpleSchema"
loader="org.eclipse.jet.emfxml" url="simpleSchemas/xsd_complexType.xsd">
Error: Unable to load: simpleSchemas/xsd_complexType.xsd

Regards,
Vladimir
Re: XSD as XML representation for JET [message #14640 is a reply to message #14609] Wed, 02 May 2007 15:19 Go to previous messageGo to next message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
Vladimir:

This is a limitation of the EMF-based XML loader JET am using. When the XML
loader sees a XML namespace definition, it attempts to find the
corresponding XSD. If it cannot, then it refuses to load the document.

The good news is, I have figured out how to overcome it. Bug 185143
(https://bugs.eclipse.org/bugs/show_bug.cgi?id=185143) tracks this. It
should be committed this week.

Once this is in, you will need to do the following on you c:load:

<c:load var="simpleSchema" loader="org.eclipse.jet.emf.xml" type="xml"
url="simpleSchemas/xsd_complexType.xsd"/>

The 'type' attribute tells the loader to pretend that the file has an XML
extension for the purposes of selecting the EMF loader.

Paul

"Vladimir Sosnin" <antiso@gmail.com> wrote in message
news:f19nb0$6i2$3@build.eclipse.org...
> Hello,
>
> I have an XSD schema and try to use it as input for JET2 transformation.
> But this schema either loaded as Ecore XSD model or not loaded at all.
> Even if I try to rename it to *.xml it can't be loaded by
> org.eclipse.jet.emfxml model loader.
>
> How can I load schema document as a simple XML file?
>
> P.S Debug log of org.eclipse.jet.emfxml on loading XSD:
> templates/dump.jet(3,1): <c:load var="simpleSchema"
> loader="org.eclipse.jet.emfxml" url="simpleSchemas/xsd_complexType.xsd">
> Error: Unable to load: simpleSchemas/xsd_complexType.xsd
>
> Regards,
> Vladimir
Re: XSD as XML representation for JET [message #14699 is a reply to message #14640] Wed, 02 May 2007 15:48 Go to previous messageGo to next message
Vladimir Sosnin is currently offline Vladimir SosninFriend
Messages: 19
Registered: July 2009
Junior Member
Paul,

I've found solution. It can be done by following code in template body:

--------------------------
<%
try {

String filePath=
" /export/work/workspace/myproject/simpleSchemas/xsd_complexTy pe.xsd ";
File file = new File(filePath);
context.logInfo("Loading file: " + file.getAbsolutePath());
DocumentBuilder builder =
DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc = builder.parse(file);
context.setVariable("simpleSchema", doc);
} catch (Exception e) {
e.printStackTrace();
}

%>
<c:log>
<c:addElement
select="$simpleSchema/descendant-or-self::*[name()='appinfo'] "
name="foo" var="new"/>
<c:dump select="$simpleSchema/descendant-or-self::*" format="true"
entities="true" />
<c:dump select="$new" format="true" entities="true" />
</c:log>
------------------------------

Moreover, tag "c:addElement" works with this model! It's exactly what I
was looking for.

Regards,
Vladimir

Paul Elder wrote:
> Vladimir:
>
> This is a limitation of the EMF-based XML loader JET am using. When the XML
> loader sees a XML namespace definition, it attempts to find the
> corresponding XSD. If it cannot, then it refuses to load the document.
>
> The good news is, I have figured out how to overcome it. Bug 185143
> (https://bugs.eclipse.org/bugs/show_bug.cgi?id=185143) tracks this. It
> should be committed this week.
>
> Once this is in, you will need to do the following on you c:load:
>
> <c:load var="simpleSchema" loader="org.eclipse.jet.emf.xml" type="xml"
> url="simpleSchemas/xsd_complexType.xsd"/>
>
> The 'type' attribute tells the loader to pretend that the file has an XML
> extension for the purposes of selecting the EMF loader.
>
> Paul
>
> "Vladimir Sosnin" <antiso@gmail.com> wrote in message
> news:f19nb0$6i2$3@build.eclipse.org...
>> Hello,
>>
>> I have an XSD schema and try to use it as input for JET2 transformation.
>> But this schema either loaded as Ecore XSD model or not loaded at all.
>> Even if I try to rename it to *.xml it can't be loaded by
>> org.eclipse.jet.emfxml model loader.
>>
>> How can I load schema document as a simple XML file?
>>
>> P.S Debug log of org.eclipse.jet.emfxml on loading XSD:
>> templates/dump.jet(3,1): <c:load var="simpleSchema"
>> loader="org.eclipse.jet.emfxml" url="simpleSchemas/xsd_complexType.xsd">
>> Error: Unable to load: simpleSchemas/xsd_complexType.xsd
>>
>> Regards,
>> Vladimir
>
>
Re: XSD as XML representation for JET [message #14729 is a reply to message #14699] Wed, 02 May 2007 17:28 Go to previous message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
Vladimir:

Glad you're making some progress. I'll consider adding a model loader that
uses XML DOM, too.

Paul

"Vladimir Sosnin" <antiso@gmail.com> wrote in message
news:f1abt9$12i$1@build.eclipse.org...
> Paul,
>
> I've found solution. It can be done by following code in template body:
>
> --------------------------
> <%
> try {
>
> String filePath=
> " /export/work/workspace/myproject/simpleSchemas/xsd_complexTy pe.xsd ";
> File file = new File(filePath);
> context.logInfo("Loading file: " + file.getAbsolutePath());
> DocumentBuilder builder =
> DocumentBuilderFactory.newInstance().newDocumentBuilder();
> Document doc = builder.parse(file);
> context.setVariable("simpleSchema", doc);
> } catch (Exception e) {
> e.printStackTrace();
> }
>
> %>
> <c:log>
> <c:addElement
> select="$simpleSchema/descendant-or-self::*[name()='appinfo'] "
> name="foo" var="new"/>
> <c:dump select="$simpleSchema/descendant-or-self::*" format="true"
> entities="true" />
> <c:dump select="$new" format="true" entities="true" />
> </c:log>
> ------------------------------
>
> Moreover, tag "c:addElement" works with this model! It's exactly what I
> was looking for.
>
> Regards,
> Vladimir
>
> Paul Elder wrote:
>> Vladimir:
>>
>> This is a limitation of the EMF-based XML loader JET am using. When the
>> XML
>> loader sees a XML namespace definition, it attempts to find the
>> corresponding XSD. If it cannot, then it refuses to load the document.
>>
>> The good news is, I have figured out how to overcome it. Bug 185143
>> (https://bugs.eclipse.org/bugs/show_bug.cgi?id=185143) tracks this. It
>> should be committed this week.
>>
>> Once this is in, you will need to do the following on you c:load:
>>
>> <c:load var="simpleSchema" loader="org.eclipse.jet.emf.xml" type="xml"
>> url="simpleSchemas/xsd_complexType.xsd"/>
>>
>> The 'type' attribute tells the loader to pretend that the file has an XML
>> extension for the purposes of selecting the EMF loader.
>>
>> Paul
>>
>> "Vladimir Sosnin" <antiso@gmail.com> wrote in message
>> news:f19nb0$6i2$3@build.eclipse.org...
>>> Hello,
>>>
>>> I have an XSD schema and try to use it as input for JET2 transformation.
>>> But this schema either loaded as Ecore XSD model or not loaded at all.
>>> Even if I try to rename it to *.xml it can't be loaded by
>>> org.eclipse.jet.emfxml model loader.
>>>
>>> How can I load schema document as a simple XML file?
>>>
>>> P.S Debug log of org.eclipse.jet.emfxml on loading XSD:
>>> templates/dump.jet(3,1): <c:load var="simpleSchema"
>>> loader="org.eclipse.jet.emfxml" url="simpleSchemas/xsd_complexType.xsd">
>>> Error: Unable to load: simpleSchemas/xsd_complexType.xsd
>>>
>>> Regards,
>>> Vladimir
>>
>>
Previous Topic:Jet modules
Next Topic:[JET2] Starnge behavior with xmi:type tags
Goto Forum:
  


Current Time: Thu Apr 18 06:33:10 GMT 2024

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

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

Back to the top