• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

XMLBeans: validating derived types in instance documents

 
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm having trouble with something that should work like a dream. I'm using Apache's XMLBeans (2.0.0 and then 2.1.0) to manipulate XML documents: to generate them and to read, validate, extract info from them.

One standard technique in XML Schemas is to define derived types: say B is derived from A by extension. Then, unless you've blocked it, you should be able to use a B element where an A element is expected. So if the xsd defines:
Then you can do the following in a document:
But when I parse and validate, it keeps failing with exception "Invalid xsi:type qname: 'myns:B' in element d@schema-url"! Does anyone know what's going wrong? I've also tried to generate a document in memory, where I call "d.setA(bObject)" to create what I described above, but when I output the XML, there is no xsi:type attribute. I've Googled and found articles like (this: check out section on Extension and Restriction) which make it sound like what I'm doing should work. Help!
[ January 13, 2006: Message edited by: Jeff Albrechtsen ]
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I should mention that the xml document that XMLBeans can't validate is being validated by the XML validator in my IDE (Eclipse), so I don't think I've made a mistake in the document, and the jar file scomp compiled from the XML schema is up-to-date.
reply
    Bookmark Topic Watch Topic
  • New Topic