Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #35250
| Newsgroups | comp.lang.java.programmer |
|---|---|
| Date | 2016-08-10 13:29 -0700 |
| References | (7 earlier) <no7m5v$f24$1@dont-email.me> <487a50aa-8e4b-460a-9824-bd23c26d4c02@googlegroups.com> <nodg3g$elh$1@dont-email.me> <de36e9b4-44de-44ba-835d-80e9dc80fa90@googlegroups.com> <nofttr$u80$1@dont-email.me> |
| Message-ID | <00fae8a8-dc01-435f-9f33-e5a5055d93df@googlegroups.com> (permalink) |
| Subject | Re: XML |
| From | Eric Douglas <e.d.programmer@gmail.com> |
On Wednesday, August 10, 2016 at 3:05:44 PM UTC-4, Stanimir Stamenkov wrote: > It seems to me you're trying to make stuff unnecessary complicated. > I'm not really sure why you need the base class, and you may find > most binding frameworks have many limitations in this regard. In > this particular instance I'm not sure why you need (possibly) > different derived types mapped to the same XML element type > "DataRecord" as in: > > <DataFile> > <DataRecord>...</DataRecord> > <DataRecord>...</DataRecord> > </DataFile> > > If the two different instances of "DataRecord" map to two different > types, then the only way to resolve this is the XML Schema > 'xsi:type' attribute – the Unmarshaller would use it to instantiate > object of the necessary type. > > As a final word, you may notice in XML an element name is generally > used to define a single element type (if you're familiar with the > XML DTD). It is the much more complex XML Schema which allows you > do other "fancy" stuff at the expense of added meta information to > the instance document like 'xsi:type' attributes. You need to > design wisely both of the XML representation and Java classes bound > to it. Good luck in this effort. Correct. Each element of DataRecord has xsi:type="specificfiletype" used to generate the specific file type class instance. I did manage to create and test a couple XSD files to marshall/unmarshall DataFiles with DataRecords in them which appear to be working fine. This adds validation to ensure each record has the correct fields in it, the fields have the correct type of value, and each DataRecord is unique according to the main key fields. sample: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:element name="DataFile"> <xs:complexType> <xs:sequence> <xs:element name="DataRecord" type="rmfid" maxOccurs="unbounded" /> </xs:sequence> </xs:complexType> <xs:unique name="Key"> <xs:selector xpath="DataRecord" /> <xs:field xpath="FILENAME" /> <xs:field xpath="SEQNUM" /> </xs:unique> </xs:element> <xs:complexType name="rmfid"> <xs:all> <xs:element name="FILENAME" type="xs:string" /> <xs:element name="SEQNUM" type="xs:string" /> </xs:all> </xs:complexType> </xs:schema> Now, I'm not sure the best API to manage records. As the only method I found for storing multiple records with JAXB is a List of the DataRecord instances, how do I pass it a key value, get one or more of these record objects, update a field (or fields), and write it back out? This RMFID.xsd maps to an RMFID Java class which gives me instances specific to this file name where I can call it's setFILENAME(), getFILENAME() methods, but I don't see an obvious way to get specific instances of the RMFID from the list aside from customizing these classes further to map out what keys I need and mapping them through the DataFile class. I'm wondering if it makes sense to keep going down this path or try something else, like JiBX which claims to do all this marshall/unmarshall stuff plus add code to the Java classes to make everything more efficient and support XPath queries to find records?
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
XML Eric Douglas <e.d.programmer@gmail.com> - 2016-07-29 13:25 -0700
Re: XML Arne Vajhøj <arne@vajhoej.dk> - 2016-07-29 19:46 -0400
Re: XML Roedy Green <inquiry@mindprod.com> - 2016-07-30 17:09 -0700
Re: XML Arne Vajhøj <arne@vajhoej.dk> - 2016-07-30 21:49 -0400
Re: XML Arne Vajhøj <arne@vajhoej.dk> - 2016-07-30 22:35 -0400
Re: XML Roedy Green <inquiry@mindprod.com> - 2016-07-31 21:39 -0700
Re: XML Eric Douglas <e.d.programmer@gmail.com> - 2016-08-01 05:19 -0700
Re: XML Arne Vajhøj <arne@vajhoej.dk> - 2016-08-01 08:51 -0400
Re: XML Eric Douglas <e.d.programmer@gmail.com> - 2016-08-05 06:07 -0700
Re: XML Eric Douglas <e.d.programmer@gmail.com> - 2016-08-05 10:17 -0700
Re: XML Stanimir Stamenkov <s7an10@netscape.net> - 2016-08-07 19:04 +0300
Re: XML Eric Douglas <e.d.programmer@gmail.com> - 2016-08-08 05:38 -0700
Re: XML Eric Douglas <e.d.programmer@gmail.com> - 2016-08-08 07:19 -0700
Re: XML Stanimir Stamenkov <s7an10@netscape.net> - 2016-08-09 23:57 +0300
Re: XML Eric Douglas <e.d.programmer@gmail.com> - 2016-08-10 05:37 -0700
Re: XML Eric Douglas <e.d.programmer@gmail.com> - 2016-08-10 10:39 -0700
Re: XML Stanimir Stamenkov <s7an10@netscape.net> - 2016-08-10 22:05 +0300
Re: XML Eric Douglas <e.d.programmer@gmail.com> - 2016-08-10 13:29 -0700
Re: XML Stanimir Stamenkov <s7an10@netscape.net> - 2016-08-11 02:18 +0300
Re: XML Eric Douglas <e.d.programmer@gmail.com> - 2016-08-11 05:15 -0700
Re: XML Eric Douglas <e.d.programmer@gmail.com> - 2016-08-11 05:50 -0700
Re: XML Eric Douglas <e.d.programmer@gmail.com> - 2016-08-11 12:24 -0700
Re: XML Arne Vajhøj <arne@vajhoej.dk> - 2016-08-13 15:38 -0400
Re: XML Eric Douglas <e.d.programmer@gmail.com> - 2016-08-16 11:49 -0700
Re: XML Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-08-16 15:57 -0400
Re: XML Eric Douglas <e.d.programmer@gmail.com> - 2016-08-16 13:20 -0700
Re: XML Arne Vajhøj <arne@vajhoej.dk> - 2016-08-16 17:04 -0400
Re: XML Arne Vajhøj <arne@vajhoej.dk> - 2016-08-16 21:37 -0400
Re: XML Eric Douglas <e.d.programmer@gmail.com> - 2016-08-17 05:22 -0700
Re: XML Eric Douglas <e.d.programmer@gmail.com> - 2016-08-17 05:21 -0700
Re: XML Arne Vajhøj <arne@vajhoej.dk> - 2016-08-16 16:13 -0400
Re: XML Eric Douglas <e.d.programmer@gmail.com> - 2016-08-16 13:22 -0700
Re: XML Arne Vajhøj <arne@vajhoej.dk> - 2016-08-16 16:53 -0400
Re: XML Eric Douglas <e.d.programmer@gmail.com> - 2016-08-16 13:32 -0700
Re: XML Arne Vajhøj <arne@vajhoej.dk> - 2016-08-16 16:47 -0400
Re: XML Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-08-16 16:59 -0400
Re: XML Arne Vajhøj <arne@vajhoej.dk> - 2016-08-01 08:46 -0400
csiph-web