Skip to main content



      Home
Home » Modeling » EMF » Creating XML with n Models created using XSD
Creating XML with n Models created using XSD [message #393060] Tue, 24 May 2005 12:45 Go to next message
Eclipse UserFriend
Originally posted by: ismet.celebi.cs.tcd.ie

The goal is to create the following XML-File by using the emf created
methods.

<?xml version="1.0" encoding="UTF-8"?>

<o-ex:rights
xmlns:o-ex="http://odrl.net/1.1/ODRL-EX"
xmlns:o-dd="http://odrl.net/1.1/ODRL-DD">

<ex:agreement>
<ex:asset id="1">
<ex:context>
<dd:dLocation>URIofApplication</o-dd:dLocation>
</ex:context>
</ex:asset>
</ex:agreement>
</ex:rights>

So, now I have 2 models representing different XSD specifications.
The first model (o-ex) is used as the primary data model for my
application.

Up to now I created it so far:

<ex:rights xmlns:o-ex="http://odrl.net/1.1/ODRL-EX">
<ex:agreement>
<ex:asset id="1">
<ex:context/>
</ex:asset>
</ex:agreement>
</ex:rights>

Now I don't know, how to connect the two models to use now the
<o-dd:dLocation>

thats my code until now:
------------------------------------------------------------ ------
Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
Map m = reg.getExtensionToFactoryMap();
m.put("parmamodel", new ExFactoryImpl());

ResourceSet resSet = new ResourceSetImpl();
URI.createURI("model/"+packageName+"model");

ExPackageImpl.init();
ExFactory factory = ExFactory.eINSTANCE;

RightsType rightstype = factory.createRightsType();

OfferAgreeType agreement = factory.createOfferAgreeType();
rightstype.getAgreement().add( agreement );

AssetType asset = factory.createAssetType();
agreement.getAsset().add(asset);
asset.setId("1");

ContextType conttype = factory.createContextType();
asset.getContext().add(conttype);

DocumentRoot docroot = ddfactory.createDocumentRoot();

URI fileURI = URI.createFileURI(System.getProperty("user.home")
+"/"
+"result.xml");
ExResourceFactoryImpl erfi = new ExResourceFactoryImpl();
Resource resource = erfi.createResource(fileURI);

resource.getContents().add( rightstype );
resource.save(Collections.EMPTY_MAP);
------------------------------------------------------------ ------

How to implement now the DD-Object dLocation ?

I tried to use an extra ddfactory like:

DdPackageImpl.init();
DdFactory ddfactory = DdFactory.eINSTANCE;
DocumentRoot docroot = ddfactory.createDocumentRoot();
docroot.setDLocation("URIofApplication");

because i couldn't merge it into the context part...

Cheers!
Ismet
Re: Creating XML with n Models created using XSD [message #393062 is a reply to message #393060] Tue, 24 May 2005 13:16 Go to previous messageGo to next message
Eclipse UserFriend
Ismet,

Since you haven't shown the schema, I don't know if the "context"
element's complex type has a getDLocation() feature or if there is a
wildcard being used? If the former, you can just do
setDLocation("...."). If the later, there will be a getAny feature
corresponding to the wildcard and you can do
context.getAny().add(DdPackage.eINSTANCE.getDocumentRoot_DLo cation(),
"....").

One trick you can always use to answer questions like this is to create
the XML, parse it, and see how it's represented...


Ismet Celebi wrote:

> The goal is to create the following XML-File by using the emf created
> methods.
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <o-ex:rights
> xmlns:o-ex="http://odrl.net/1.1/ODRL-EX"
> xmlns:o-dd="http://odrl.net/1.1/ODRL-DD">
>
> <ex:agreement>
> <ex:asset id="1">
> <ex:context>
> <dd:dLocation>URIofApplication</o-dd:dLocation>
> </ex:context>
> </ex:asset>
> </ex:agreement>
> </ex:rights>
>
> So, now I have 2 models representing different XSD specifications.
> The first model (o-ex) is used as the primary data model for my
> application.
>
> Up to now I created it so far:
>
> <ex:rights xmlns:o-ex="http://odrl.net/1.1/ODRL-EX">
> <ex:agreement>
> <ex:asset id="1">
> <ex:context/>
> </ex:asset>
> </ex:agreement>
> </ex:rights>
>
> Now I don't know, how to connect the two models to use now the
> <o-dd:dLocation>
>
> thats my code until now:
> ------------------------------------------------------------ ------
> Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
> Map m = reg.getExtensionToFactoryMap();
> m.put("parmamodel", new ExFactoryImpl());
>
> ResourceSet resSet = new ResourceSetImpl();
> URI.createURI("model/"+packageName+"model");
>
> ExPackageImpl.init();
> ExFactory factory = ExFactory.eINSTANCE;
>
> RightsType rightstype = factory.createRightsType();
>
> OfferAgreeType agreement = factory.createOfferAgreeType();
> rightstype.getAgreement().add( agreement );
>
> AssetType asset = factory.createAssetType();
> agreement.getAsset().add(asset);
> asset.setId("1");
>
> ContextType conttype = factory.createContextType();
> asset.getContext().add(conttype);
>
> DocumentRoot docroot = ddfactory.createDocumentRoot();
>
> URI fileURI = URI.createFileURI(System.getProperty("user.home")
> +"/"
> +"result.xml");
> ExResourceFactoryImpl erfi = new ExResourceFactoryImpl();
> Resource resource = erfi.createResource(fileURI);
>
> resource.getContents().add( rightstype );
> resource.save(Collections.EMPTY_MAP);
> ------------------------------------------------------------ ------
>
> How to implement now the DD-Object dLocation ?
>
> I tried to use an extra ddfactory like:
>
> DdPackageImpl.init();
> DdFactory ddfactory = DdFactory.eINSTANCE;
> DocumentRoot docroot = ddfactory.createDocumentRoot();
> docroot.setDLocation("URIofApplication");
>
> because i couldn't merge it into the context part...
>
> Cheers!
> Ismet
>
Re: Creating XML with n Models created using XSD [message #393066 is a reply to message #393062] Wed, 25 May 2005 03:34 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ismet.celebi.cs.tcd.ie

Ed,

Sorry, you are right, I forgot the liks to the Schemas:

schema Locations:
http://odrl.net/1.1/ODRL-EX-11.xsd
http://odrl.net/1.1/ODRL-DD-11.xsd

The Object context sadly don't have getDLocation() or getAny() Methods.
Re: Creating XML with n Models created using XSD [message #393074 is a reply to message #393066] Wed, 25 May 2005 07:43 Go to previous messageGo to next message
Eclipse UserFriend
This is a multi-part message in MIME format.
--------------010502030508020709030002
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Ismet,

The way this is modeled is rather unfortunate:

<xsd:complexType name="contextType">
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element ref="o-ex:context" minOccurs="0"
maxOccurs="unbounded"/>
<xsd:element ref="o-ex:contextElement" minOccurs="0"
maxOccurs="unbounded"/>
</xsd:choice>
<xsd:attributeGroup ref="o-ex:IDGroup"/>
</xsd:complexType>

The repeating group will give you a getGroup() feature that will work
the same way as I described for getAny().


Ismet Celebi wrote:

> Ed,
>
> Sorry, you are right, I forgot the liks to the Schemas:
>
> schema Locations:
> http://odrl.net/1.1/ODRL-EX-11.xsd
> http://odrl.net/1.1/ODRL-DD-11.xsd
>
> The Object context sadly don't have getDLocation() or getAny() Methods.
>


--------------010502030508020709030002
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">
Ismet,<br>
<br>
The way this is modeled is rather unfortunate:<br>
<blockquote>
Re: Creating XML with n Models created using XSD [message #393077 is a reply to message #393074] Wed, 25 May 2005 08:44 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ismet.celebi.cs.tcd.ie

Ed,

thank that was great. I have now the same problem with the object
"execute". It couldn't set with the Method getGroup(...).

<o-ex:agreement>
<o-ex:asset id="1">
<o-ex:context>
<o-dd:dLocation>URIofApplication</o-dd:dLocation>
</o-ex:context>
</o-ex:asset>
<o-ex:permission>
<o-dd:execute>
<o-ex:constraint>
<o-dd:count>2</o-dd:count>
<parma:pointcut>
<parma:adviceType>after</parma:adviceType>
<parma:package>
<parma:packageName>packageName</parma:packageName>
<parma:class isMain="true">
<parma:className>Main</parma:className>
<parma:method>
<parma:methodName>startApp</parma:methodName>
<parma:returnType>void</parma:returnType>
</parma:method>
</parma:class>
</parma:package>
</parma:pointcut>
</o-ex:constraint>
</o-dd:execute>

Is it something different? It should be the same way?
Re: Creating XML with n Models created using XSD [message #393078 is a reply to message #393074] Wed, 25 May 2005 08:55 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ismet.celebi.cs.tcd.ie

Here ist the link to the (parma) Schema:
https://www.cs.tcd.ie/Ismet.Celebi/parma-1.2.xsd
Re: Creating XML with n Models created using XSD [message #393084 is a reply to message #393077] Wed, 25 May 2005 17:03 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ismet.celebi.cs.tcd.ie

I concretize and update the question.

The output is currently:

<?xml version="1.0" encoding="ASCII"?>
<ex:rightsType xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dd="http://odrl.net/1.1/ODRL-DD"
xmlns:ex="http://odrl.net/1.1/ODRL-EX"
xsi:schemaLocation="http://odrl.net/1.1/ODRL-DD
http://odrl.net/1.1/ODRL-EX#//dd">
<ex:agreement>
<ex:asset ex:id="doi:1234567-9876">
<ex:context>
<dd:dLocation>URIofApplication</dd:dLocation>
</ex:context>
</ex:asset>
<ex:permission>
<ex:constraint>
<ex:constraint xsi:nil="true"/>
</ex:constraint>
</ex:permission>
</ex:agreement>
</ex:rightsType>

Thats what I do until now in the problem part:

...
PermissionType permission = factory.createPermissionType();
ConstraintType constrain = factory.createConstraintType();

permission.getConstraint().add(constrain);
agreement.getPermission().add(permission);
rightstype.getAgreement().add(agreement);

I don't know how to treating the other Types, like: Execute, Count,
pointcut...

For example there is not data type of Execute. I tried with:
permission.getGroup().add(DdPackageImpl.eINSTANCE.getDocumen tRoot_Execute());
or
DdFactory.eINSTANCE.createDocumentRoot().setExecute(constrai n);

but I don't get it.
Re: Creating XML with n Models created using XSD [message #393087 is a reply to message #393084] Wed, 25 May 2005 17:42 Go to previous messageGo to next message
Eclipse UserFriend
This is a multi-part message in MIME format.
--------------020101090306060904070000
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Ismet,

From what I gather from the schema:

<xsd:element name="execute" type="o-ex:permissionType"
substitutionGroup="o-ex:permissionElement"/>

The type of "execute" is just a PermissionType, so you'd create a
permission type and do

permission.getGroup().add(DdPackageImpl.eINSTANCE.getDocumen tRoot_Execute(),
factory.createPermissionType());

Note that the eINSTANCE is on the DdPackage interface. You should not
ever need to access the Impl classes directly like this.)


Ismet Celebi wrote:

> I concretize and update the question.
>
> The output is currently:
>
> <?xml version="1.0" encoding="ASCII"?>
> <ex:rightsType xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:dd="http://odrl.net/1.1/ODRL-DD"
> xmlns:ex="http://odrl.net/1.1/ODRL-EX"
> xsi:schemaLocation="http://odrl.net/1.1/ODRL-DD
> http://odrl.net/1.1/ODRL-EX#//dd">
> <ex:agreement>
> <ex:asset ex:id="doi:1234567-9876">
> <ex:context>
> <dd:dLocation>URIofApplication</dd:dLocation>
> </ex:context>
> </ex:asset>
> <ex:permission>
> <ex:constraint>
> <ex:constraint xsi:nil="true"/>
> </ex:constraint>
> </ex:permission>
> </ex:agreement>
> </ex:rightsType>
>
> Thats what I do until now in the problem part:
>
> ..
> PermissionType permission = factory.createPermissionType();
> ConstraintType constrain = factory.createConstraintType();
>
> permission.getConstraint().add(constrain);
> agreement.getPermission().add(permission);
> rightstype.getAgreement().add(agreement);
>
> I don't know how to treating the other Types, like: Execute, Count,
> pointcut...
>
> For example there is not data type of Execute. I tried with:
> permission.getGroup().add(DdPackageImpl.eINSTANCE.getDocumen tRoot_Execute());
>
> or
> DdFactory.eINSTANCE.createDocumentRoot().setExecute(constrai n);
>
> but I don't get it.
>


--------------020101090306060904070000
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">
Ismet,<br>
<br>
From what I gather from the schema:<br>
<blockquote>
Re: Creating XML with n Models created using XSD [message #393097 is a reply to message #393087] Thu, 26 May 2005 07:47 Go to previous message
Eclipse UserFriend
Originally posted by: ismet.celebi.cs.tcd.ie

Ed,

Thank you for the very useful & fast answers.

Cheers,
Ismet
Previous Topic:Free DB Design plug-in
Next Topic:Why does the emf 3.0.2 feature depend on JDT?
Goto Forum:
  


Current Time: Sun Aug 03 17:56:07 EDT 2025

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

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

Back to the top