Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Loading an XML file with SDO([XML SDO ECLIPSELINK])
Loading an XML file with SDO [message #1053131] Thu, 02 May 2013 15:25 Go to next message
Ayoub El Barji is currently offline Ayoub El BarjiFriend
Messages: 15
Registered: April 2013
Junior Member
Hello,

I am trying to load an xml file as data Object thanks to SDO.
I want to parse it for gather all the data contained.
But i am facing a problem, there is datas missing.
How can i load my xml file with the best way for having access to all my variables and their values.

i am using this code below:

FileInputStream inputStream = new FileInputStream("model/can_db.xsd");
xsdHelper.define(inputStream, null);
inputStream.close();

XMLHelper xmlHelper = helperContext.getXMLHelper();
File file = new File("model/tiny.xml");
FileInputStream xml = new FileInputStream(file);
XMLDocument xmldoc = xmlHelper.load(xml,null,null);
DataObject modelSDO = xmldoc.getRootObject();

Thank you for your Help
Ayoub
Re: Loading an XML file with SDO [message #1053160 is a reply to message #1053131] Thu, 02 May 2013 18:49 Go to previous messageGo to next message
Matt MacIvor is currently offline Matt MacIvorFriend
Messages: 14
Registered: July 2009
Junior Member
Hi Ayoub,

The code that you're using to define the types and load the xml document all looks correct.

Which parts of the data specifically are missing from the loaded DataObject? If you can provide the schema and the .xml file, I can take a look and see what's going wrong.

-Matt
Re: Loading an XML file with SDO [message #1053211 is a reply to message #1053160] Fri, 03 May 2013 07:29 Go to previous messageGo to next message
Ayoub El Barji is currently offline Ayoub El BarjiFriend
Messages: 15
Registered: April 2013
Junior Member
Hi Matt

First thanks for your fast answer.
In fact my initial aim it's to parse both the xsd schema and his corresponding instance(xml file). I want to make a binding between them et and have free access to my model data (in the xsd) and my instance data (in the xml). First i used EMF and Ecore to make this but i encountered a problem when i want to make the binding; with EMF i have my model data registered in a part and my instance data in another place; there is no binding between them.
So i am trying to use the SDO technology for having free access to all my data (xsd and xml).

The problem is when i load my xml file i have juste the top layer of my data correctly loaded but the bottom layers attributes data are missing (null, null, null, ...).

my xml file(tiny.xml) just below:

<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSPY v2004 rel. 3 U (http://www.xmlspy.com) by Philippe Favrais (Siemens VDO S.A.S.) -->
<!--Sample XML file generated by XMLSPY v2004 rel. 3 U (http://www.xmlspy.com)-->
<CAN_DB xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.conti.com C:\Users\uidw3743\Documents\STAGE\org.eclipse.emf.example.dom\data\can_db.xsd" Name="String" CANdb_version="2.5.21" SVDO_version="1.0">
	<PDUS>
		<PDU [color=red]Name="String" Identifier="A9FD64E12C" Length="8" FrameType="Data" IDFormat="Standard" Comment="String" Node="String" is_IL_TX_PDU="no" isCyclic="no" TxCycle="0" isEvent="no" isAutostart="no" TxStartupOffset="0" fastTxNotification="no" hasTxTimeout="no" TxTimeout="0" confirmationFunction="NULL" TxTimeoutFunction="NULL" Tx_ExclusionTime="0" is_IL_RX_PDU="no" hasRxTimeout="no" RxTimeout="0" fastRxIndication="no" indicationFunction="NULL" RxTimeoutFunction="NULL" is_GW_PDU="no" NetSource="String" NetDestination="String" Type="OTHER" TransmitPeriod="0" Monitored_by_OSEK_INM="no">[/color]
			<MESSAGE Name="String" BitSize="64" BitPosition="3.1415926535897932384626433832795" ByteOrder="Motorola" Valuetype="String" Factor="1" Offset="0" Unit="String" hasInitValue="no" InitValue="0" hasStartupValue="no" StartupValue="0" hasRxTimeoutValue="no" RxTimeoutValue="0" isTxEventTrigger="no"/>

		</PDU>
	</PDUS>
	<TRASH/>
</CAN_DB>


Missing data are attributes after PDU and MESSAGE.
You will find the xsd file in Attachment.

Thank you

Ayoub

  • Attachment: can_db.xsd
    (Size: 26.92KB, Downloaded 395 times)
Re: Loading an XML file with SDO [message #1053284 is a reply to message #1053211] Fri, 03 May 2013 14:43 Go to previous messageGo to next message
Matt MacIvor is currently offline Matt MacIvorFriend
Messages: 14
Registered: July 2009
Junior Member
Hi Ayoub,

I've debugged through your test case and found the issue. There's a bug in the EclipseLink SDO implementation when referencing global attribute groups in a schema with no target namespace. I've opened a bug to track this here:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=407176

A couple of options:

You could add a target namespace to your schema. The bug in eclipselink only applies to schemas with no target namespace, so by adding a namespace, everything should work.

You could also look into EclipseLink's Dynamic JAXB support. This allows you to bootstrap a JAXB Context directly from your schema and interact with Dynamic Entities. It's similar to SDO, and doesn't have the bug with attribute groups.

And example of using Dynamic JAXB to load your instance doc:
DynamicJAXBContext ctx =  DynamicJAXBContextFactory.createContextFromXSD(schemaStream, null, Tester.class.getClassLoader(), null);
Unmarshaller u = ctx.createUnmarshaller();
File xml = new File("/temp/tiny.xml");
Object obj = u.unmarshal(xml);


More documentation on Dynamic JAXB can be found here:
http://www.eclipse.org/eclipselink/documentation/2.4/moxy/dynamic_jaxb.htm

And some examples can be found here:
http://wiki.eclipse.org/EclipseLink/Examples/MOXy/Dynamic

Hope this is helpful,

-Matt
Re: Loading an XML file with SDO [message #1053287 is a reply to message #1053284] Fri, 03 May 2013 14:58 Go to previous message
Ayoub El Barji is currently offline Ayoub El BarjiFriend
Messages: 15
Registered: April 2013
Junior Member
Hi Matt

Thanks you for your precious time and your help.
I lost a lot of time in debugging the code.
I will try your solution and also explore the Dynamic JAXB solution.

Ayoub
Previous Topic:How to refresh the entities with out re starting the server
Next Topic:When will Eclipselink 2.4.2 be released?
Goto Forum:
  


Current Time: Fri Mar 29 09:55:40 GMT 2024

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

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

Back to the top