Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » XML Schema Definition (XSD) » Binding XML to Java
Binding XML to Java [message #71458] Mon, 29 January 2007 12:44 Go to next message
Eclipse UserFriend
Originally posted by: elena.tibrea.gmail.com

I'm creating an XML as described here:
http://www.theserverside.com/tt/articles/article.tss?l=Bindi ngXMLJava.

Is it possible to add an element which represents a schema
(org.eclipse.xsd.XSDSchema) to the XML resource?

If yes, can you give some clues?

Thanks.
elena
Re: Binding XML to Java [message #71477 is a reply to message #71458] Mon, 29 January 2007 13:09 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Elena,

You could build an Ecore model for the XMLSchema.xsd and use that, or
you could use the extended metadata's demandFeature to create the
element name and namespace you want just as for any other XML name and
namespace you might want to produce. The XSD model itself requires the
specialized behavior of an XSDResourceImpl to serialize, so you can't
use it directly for the purposes of embedding it in some XML data
represented as an EMF AnyType.


elena t wrote:
> I'm creating an XML as described here:
> http://www.theserverside.com/tt/articles/article.tss?l=Bindi ngXMLJava.
>
> Is it possible to add an element which represents a schema
> (org.eclipse.xsd.XSDSchema) to the XML resource?
>
> If yes, can you give some clues?
>
> Thanks.
> elena
>
Re: Binding XML to Java [message #71496 is a reply to message #71477] Mon, 29 January 2007 16:58 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: elena.tibrea.gmail.com

Hi again,

Using the EMF model generated from mySchema.xsd file, I could have smth
like:

StructuralFeature feature =
MyPackage.eINSTANCE.getDocumentRoot().getEStructuralFeature( "myFeature");
MyType featureType=MyFactory.eINSTANCE.createMyFeatureType();
rootMixed.add(feature,featureType);

which would result in <myFeature> being included in my XML Resource,
but what I want to have in the end is a XML file looking like
...
<document>
<data>
<xs:schema>
<!--everything which belongs to a schema declaration, basically
mySchema.xsd file-->
</xs:schema>
</data>
</document>
....

Help :-)

Thanks.
elena
Re: Binding XML to Java [message #71515 is a reply to message #71496] Mon, 29 January 2007 18:23 Go to previous message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

This is a multi-part message in MIME format.
--------------000705080308080905060006
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Elena,

The paper shows how to use demandFeature and how to use AnyType.

AnyType rootTreeNode = XMLTypeFactory.eINSTANCE.createAnyType();
documentRoot.eSet(rootNodeFeature, rootTreeNode);


That same technique could be used to build anything. Or, as I
suggested, you could generate a <My>Package for the schema for schemas
and use that:

http://www.w3.org/2001/XMLSchema.xsd



elena t wrote:
> Hi again,
>
> Using the EMF model generated from mySchema.xsd file, I could have
> smth like:
>
> StructuralFeature feature =
> MyPackage.eINSTANCE.getDocumentRoot().getEStructuralFeature( "myFeature");
> MyType featureType=MyFactory.eINSTANCE.createMyFeatureType();
> rootMixed.add(feature,featureType);
>
> which would result in <myFeature> being included in my XML Resource,
> but what I want to have in the end is a XML file looking like
> ...
> <document>
> <data>
> <xs:schema>
> <!--everything which belongs to a schema declaration, basically
> mySchema.xsd file-->
> </xs:schema>
> </data>
> </document>
> ....
>
> Help :-)
>
> Thanks.
> elena
>
>
>


--------------000705080308080905060006
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">
Elena,<br>
<br>
The paper shows how to use demandFeature and how to use AnyType.
Re: Binding XML to Java [message #599555 is a reply to message #71458] Mon, 29 January 2007 13:09 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 26279
Registered: July 2009
Senior Member
Elena,

You could build an Ecore model for the XMLSchema.xsd and use that, or
you could use the extended metadata's demandFeature to create the
element name and namespace you want just as for any other XML name and
namespace you might want to produce. The XSD model itself requires the
specialized behavior of an XSDResourceImpl to serialize, so you can't
use it directly for the purposes of embedding it in some XML data
represented as an EMF AnyType.


elena t wrote:
> I'm creating an XML as described here:
> http://www.theserverside.com/tt/articles/article.tss?l=Bindi ngXMLJava
>
> Is it possible to add an element which represents a schema
> (org.eclipse.xsd.XSDSchema) to the XML resource?
>
> If yes, can you give some clues?
>
> Thanks.
> elena
>
Re: Binding XML to Java [message #602063 is a reply to message #71477] Mon, 29 January 2007 16:58 Go to previous message
Eclipse UserFriend
Originally posted by: elena.tibrea.gmail.com

Hi again,

Using the EMF model generated from mySchema.xsd file, I could have smth
like:

StructuralFeature feature =
MyPackage.eINSTANCE.getDocumentRoot().getEStructuralFeature( "myFeature");
MyType featureType=MyFactory.eINSTANCE.createMyFeatureType();
rootMixed.add(feature,featureType);

which would result in <myFeature> being included in my XML Resource,
but what I want to have in the end is a XML file looking like
...
<document>
<data>
<xs:schema>
<!--everything which belongs to a schema declaration, basically
mySchema.xsd file-->
</xs:schema>
</data>
</document>
....

Help :-)

Thanks.
elena
Re: Binding XML to Java [message #602074 is a reply to message #71496] Mon, 29 January 2007 18:23 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 26279
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------000705080308080905060006
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Elena,

The paper shows how to use demandFeature and how to use AnyType.

AnyType rootTreeNode = XMLTypeFactory.eINSTANCE.createAnyType();
documentRoot.eSet(rootNodeFeature, rootTreeNode);


That same technique could be used to build anything. Or, as I
suggested, you could generate a <My>Package for the schema for schemas
and use that:

http://www.w3.org/2001/XMLSchema.xsd



elena t wrote:
> Hi again,
>
> Using the EMF model generated from mySchema.xsd file, I could have
> smth like:
>
> StructuralFeature feature =
> MyPackage.eINSTANCE.getDocumentRoot().getEStructuralFeature( "myFeature");
> MyType featureType=MyFactory.eINSTANCE.createMyFeatureType();
> rootMixed.add(feature,featureType);
>
> which would result in <myFeature> being included in my XML Resource,
> but what I want to have in the end is a XML file looking like
> ...
> <document>
> <data>
> <xs:schema>
> <!--everything which belongs to a schema declaration, basically
> mySchema.xsd file-->
> </xs:schema>
> </data>
> </document>
> ....
>
> Help :-)
>
> Thanks.
> elena
>
>
>


--------------000705080308080905060006
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">
Elena,<br>
<br>
The paper shows how to use demandFeature and how to use AnyType.
Previous Topic:Binding XML to Java
Next Topic:[Announce] EclipseCon 2007 Registration
Goto Forum:
  


Current Time: Thu Dec 18 15:24:29 GMT 2014

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

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