Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Teneo] Use J2SE spec API for XML datatypes (work with IBM JDK)
[Teneo] Use J2SE spec API for XML datatypes (work with IBM JDK) [message #105127] Sun, 23 December 2007 16:14 Go to next message
Eclipse UserFriend
Originally posted by: akarypid.yahoo.gr

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

Hi,

Teneo uses the internal Xerces API to construct XML Gregorian calendar
objects, by calling the constructor of:

com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregoria nCalendarImpl

The standard J2SE API does not include this implementation class as part
of the platform. Therefore, using it may cause incompatibility with
other JDK implementations that implement XMLGregorianCalendar differently.

I've just come across one such case while using IBM's JDK. Although IBM
does the same thing as Sun (i.e. distribute Xerces with its JDK), it
uses the original namespace for the classes, whereas Sun has renamed it
from "org.apace.xerces..." to "com.sun.org.apache.xerces..."

This patch removes references to the internal class implementation and
uses the DatatypeFactory to construct XMLGregorianCalendar objects, as
instructed by Sun's API docs at:

http://java.sun.com/javase/6/docs/api/javax/xml/datatype/XML GregorianCalendar.html#XMLGregorianCalendar()

It will sadly be slower than calling the constructor directly, but I
don't see any other nice way around this.

--------------080908030601030202060106
Content-Type: text/x-patch;
name="std_jaxp.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="std_jaxp.patch"

### Eclipse Workspace Patch 1.0
#P org.eclipse.emf.teneo
Index: src/org/eclipse/emf/teneo/util/EcoreDataTypes.java
============================================================ =======
RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf.teneo/plug ins/org.eclipse.emf.teneo/src/org/eclipse/emf/teneo/util/Eco reDataTypes.java,v
retrieving revision 1.6
diff -u -r1.6 EcoreDataTypes.java
--- src/org/eclipse/emf/teneo/util/EcoreDataTypes.java 4 Jul 2007 19:27:26 -0000 1.6
+++ src/org/eclipse/emf/teneo/util/EcoreDataTypes.java 23 Dec 2007 15:59:35 -0000
@@ -24,6 +24,8 @@
import java.util.Date;
import java.util.List;

+import javax.xml.datatype.DatatypeConfigurationException;
+import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;

import org.eclipse.emf.ecore.EClassifier;
@@ -31,8 +33,7 @@
import org.eclipse.emf.ecore.EEnum;
import org.eclipse.emf.ecore.EcorePackage;
import org.eclipse.emf.ecore.xml.type.XMLTypePackage;
-
-import com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregoria nCalendarImpl;
+import org.eclipse.emf.teneo.TeneoException;

/**
* Utility class to classify Ecore datatypes.
@@ -46,6 +47,9 @@
private static EDataType xmlDateEDataType = xmlTypePackage.getDate();
private static EDataType xmlDateTimeEDataType = xmlTypePackage.getDateTime();

+ // XML datatype factory instance
+ private final DatatypeFactory dataTypeFactory;
+
private static final List<EDataType> PRIMITIVES_ETYPES_LIST =
Collections.unmodifiableList(Arrays.asList(new EDataType[] { EcorePackage.eINSTANCE.getEBoolean(),
EcorePackage.eINSTANCE.getEByte(), EcorePackage.eINSTANCE.getEChar(),
@@ -63,13 +67,18 @@
public static EcoreDataTypes INSTANCE = new EcoreDataTypes();

private EcoreDataTypes() {
+ try {
+ dataTypeFactory = DatatypeFactory.newInstance();
+ } catch (DatatypeConfigurationException e) {
+ throw new TeneoException("Exception ", e);
+ }
}

// TODO: Make all utility methods static.

/** Return a XMLGregorianCalendar on the basis of the date */
public XMLGregorianCalendar getXMLGregorianCalendar(Date date) {
- final XMLGregorianCalendar gregCalendar = new XMLGregorianCalendarImpl();
+ final XMLGregorianCalendar gregCalendar = dataTypeFactory.newXMLGregorianCalendar();
final Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
gregCalendar.setYear(calendar.get(Calendar.YEAR));
@@ -80,7 +89,7 @@

/** Return a XMLGregorianCalendar on datetime level (milliseconds) */
public XMLGregorianCalendar getXMLGregorianCalendarDateTime(Date date) {
- final XMLGregorianCalendar gregCalendar = new XMLGregorianCalendarImpl();
+ final XMLGregorianCalendar gregCalendar = dataTypeFactory.newXMLGregorianCalendar();
final Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
gregCalendar.setYear(calendar.get(Calendar.YEAR));
#P org.eclipse.emf.teneo.hibernate
Index: src/org/eclipse/emf/teneo/hibernate/mapping/XSDDateTime.java
============================================================ =======
RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf.teneo/plug ins/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/tene o/hibernate/mapping/XSDDateTime.java,v
retrieving revision 1.2
diff -u -r1.2 XSDDateTime.java
--- src/org/eclipse/emf/teneo/hibernate/mapping/XSDDateTime.java 4 Jul 2007 19:27:28 -0000 1.2
+++ src/org/eclipse/emf/teneo/hibernate/mapping/XSDDateTime.java 23 Dec 2007 15:59:37 -0000
@@ -31,8 +31,6 @@
import org.hibernate.HibernateException;
import org.hibernate.type.MutableType;

-import com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregoria nCalendarImpl;
-
/**
* Implements the hibernate UserType for EMF's XMLGregorianCalendar ("datetime" type in XSD).
*
@@ -71,7 +69,7 @@
*/
@Override
public Object deepCopyNotNull(Object value) {
- return new XMLGregorianCalendarImpl(((XMLGregorianCalendar) value).toGregorianCalendar());
+ return dataTypeFactory.newXMLGregorianCalendar(((XMLGregorianCalend ar) value).toGregorianCalendar());
}

/*

--------------080908030601030202060106--
Re: [Teneo] Use J2SE spec API for XML datatypes (work with IBM JDK) [message #105156 is a reply to message #105127] Sun, 23 December 2007 18:05 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Alexandros,

It's best if you open a bugzilla with this patch; that way you can track
when the changes are applied and available in a build. It's definitely a
bad idea to depend directly on com.sun.* classes from the JDK.


Alexandros Karypidis wrote:
> Hi,
>
> Teneo uses the internal Xerces API to construct XML Gregorian calendar
> objects, by calling the constructor of:
>
> com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregoria nCalendarImpl
>
> The standard J2SE API does not include this implementation class as
> part of the platform. Therefore, using it may cause incompatibility
> with other JDK implementations that implement XMLGregorianCalendar
> differently.
>
> I've just come across one such case while using IBM's JDK. Although
> IBM does the same thing as Sun (i.e. distribute Xerces with its JDK),
> it uses the original namespace for the classes, whereas Sun has
> renamed it from "org.apace.xerces..." to "com.sun.org.apache.xerces..."
>
> This patch removes references to the internal class implementation and
> uses the DatatypeFactory to construct XMLGregorianCalendar objects, as
> instructed by Sun's API docs at:
>
> http://java.sun.com/javase/6/docs/api/javax/xml/datatype/XML GregorianCalendar.html#XMLGregorianCalendar()
>
>
> It will sadly be slower than calling the constructor directly, but I
> don't see any other nice way around this.
Re: [Teneo] Use J2SE spec API for XML datatypes (work with IBM JDK) [message #105172 is a reply to message #105156] Sun, 23 December 2007 19:02 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Alexandros,
Can you attach the patch to this bugzilla:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=207799

As far as I can see your solution will also solve this one.

Thanks!

gr. Martin

Ed Merks wrote:
> Alexandros,
>
> It's best if you open a bugzilla with this patch; that way you can track
> when the changes are applied and available in a build. It's definitely a
> bad idea to depend directly on com.sun.* classes from the JDK.
>
>
> Alexandros Karypidis wrote:
>> Hi,
>>
>> Teneo uses the internal Xerces API to construct XML Gregorian calendar
>> objects, by calling the constructor of:
>>
>> com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregoria nCalendarImpl
>>
>> The standard J2SE API does not include this implementation class as
>> part of the platform. Therefore, using it may cause incompatibility
>> with other JDK implementations that implement XMLGregorianCalendar
>> differently.
>>
>> I've just come across one such case while using IBM's JDK. Although
>> IBM does the same thing as Sun (i.e. distribute Xerces with its JDK),
>> it uses the original namespace for the classes, whereas Sun has
>> renamed it from "org.apace.xerces..." to "com.sun.org.apache.xerces..."
>>
>> This patch removes references to the internal class implementation and
>> uses the DatatypeFactory to construct XMLGregorianCalendar objects, as
>> instructed by Sun's API docs at:
>>
>> http://java.sun.com/javase/6/docs/api/javax/xml/datatype/XML GregorianCalendar.html#XMLGregorianCalendar()
>>
>>
>> It will sadly be slower than calling the constructor directly, but I
>> don't see any other nice way around this.


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [Teneo] Use J2SE spec API for XML datatypes (work with IBM JDK) [message #612995 is a reply to message #105127] Sun, 23 December 2007 18:05 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 31467
Registered: July 2009
Senior Member
Alexandros,

It's best if you open a bugzilla with this patch; that way you can track
when the changes are applied and available in a build. It's definitely a
bad idea to depend directly on com.sun.* classes from the JDK.


Alexandros Karypidis wrote:
> Hi,
>
> Teneo uses the internal Xerces API to construct XML Gregorian calendar
> objects, by calling the constructor of:
>
> com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregoria nCalendarImpl
>
> The standard J2SE API does not include this implementation class as
> part of the platform. Therefore, using it may cause incompatibility
> with other JDK implementations that implement XMLGregorianCalendar
> differently.
>
> I've just come across one such case while using IBM's JDK. Although
> IBM does the same thing as Sun (i.e. distribute Xerces with its JDK),
> it uses the original namespace for the classes, whereas Sun has
> renamed it from "org.apace.xerces..." to "com.sun.org.apache.xerces..."
>
> This patch removes references to the internal class implementation and
> uses the DatatypeFactory to construct XMLGregorianCalendar objects, as
> instructed by Sun's API docs at:
>
> http://java.sun.com/javase/6/docs/api/javax/xml/datatype/XML GregorianCalendar.html#XMLGregorianCalendar()
>
>
> It will sadly be slower than calling the constructor directly, but I
> don't see any other nice way around this.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [Teneo] Use J2SE spec API for XML datatypes (work with IBM JDK) [message #612997 is a reply to message #105156] Sun, 23 December 2007 19:02 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Alexandros,
Can you attach the patch to this bugzilla:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=207799

As far as I can see your solution will also solve this one.

Thanks!

gr. Martin

Ed Merks wrote:
> Alexandros,
>
> It's best if you open a bugzilla with this patch; that way you can track
> when the changes are applied and available in a build. It's definitely a
> bad idea to depend directly on com.sun.* classes from the JDK.
>
>
> Alexandros Karypidis wrote:
>> Hi,
>>
>> Teneo uses the internal Xerces API to construct XML Gregorian calendar
>> objects, by calling the constructor of:
>>
>> com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregoria nCalendarImpl
>>
>> The standard J2SE API does not include this implementation class as
>> part of the platform. Therefore, using it may cause incompatibility
>> with other JDK implementations that implement XMLGregorianCalendar
>> differently.
>>
>> I've just come across one such case while using IBM's JDK. Although
>> IBM does the same thing as Sun (i.e. distribute Xerces with its JDK),
>> it uses the original namespace for the classes, whereas Sun has
>> renamed it from "org.apace.xerces..." to "com.sun.org.apache.xerces..."
>>
>> This patch removes references to the internal class implementation and
>> uses the DatatypeFactory to construct XMLGregorianCalendar objects, as
>> instructed by Sun's API docs at:
>>
>> http://java.sun.com/javase/6/docs/api/javax/xml/datatype/XML GregorianCalendar.html#XMLGregorianCalendar()
>>
>>
>> It will sadly be slower than calling the constructor directly, but I
>> don't see any other nice way around this.


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Previous Topic:[Teneo] Use J2SE spec API for XML datatypes (work with IBM JDK)
Next Topic:[CDO]When CDO can support GMF Editor?
Goto Forum:
  


Current Time: Sun Sep 20 04:41:01 GMT 2020

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

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

Back to the top