XML/RDF to Java Objects with XSD

Posted by bmucklow on Stack Overflow See other posts from Stack Overflow or by bmucklow
Published on 2010-05-05T17:17:00Z Indexed on 2010/05/11 8:14 UTC
Read the original article Hit count: 263

Filed under:
|
|
|
|

So here's the scenario...I have an XSD file describing all the objects that I need. I can create the objects in Java using JAXB no problem. I have an XML/RDF file that I need to parse into those objects.

What is the EASIEST way to do this?

I have been looking into Jena and have played around with it, but can't see how to easily map the XML/RDF file to the XSD objects that were generated. Here is a snippet of the XSD file as well as the XML/RDF file:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
    xmlns:a="http://langdale.com.au/2005/Message#" 
    xmlns:sawsdl="http://www.w3.org/ns/sawsdl" 
    targetNamespace="http://iec.ch/TC57/2007/profile#" 
    elementFormDefault="qualified" 
    attributeFormDefault="unqualified" 
    xmlns="http://langdale.com.au/2005/Message#" 
    xmlns:m="http://iec.ch/TC57/2007/profile#">
<xs:annotation/>
<xs:element name="Profile" type="m:Profile"/>
<xs:complexType name="Profile">
<xs:sequence>
<xs:element name="Breaker" type="m:Breaker" minOccurs="0" maxOccurs="unbounded"/>

And the XML/RDF:

<!-- CIM XML Output For switch783:(295854688) -->
<cim:Switch rdf:ID="Switch_295854688">
    <cim:IdentifiedObject.mRID>Switch_295854688</cim:IdentifiedObject.mRID>
    <cim:IdentifiedObject.aliasName>Switch_295854688</cim:IdentifiedObject.aliasName>
    <cim:ConductingEquipment.phases 
        rdf:resource="http://iec.ch/TC57/2009/CIM-schema-cim14#PhaseCode.ABC" />
    <cim:Switch.circuit2>0001406</cim:Switch.circuit2>
    <cim:Equipment.Line rdf:resource="#Line_0001406" />

© Stack Overflow or respective owner

Related posts about Xml

Related posts about rdf