xml-xmlbeans-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Murphy, Eric" <erimu...@pfc.cfs.nrcan.gc.ca>
Subject XmlObject set
Date Thu, 11 Mar 2004 18:12:04 GMT

XmlBeans -

I have created a Document with XmlOptions.setValidateOnSet() as an argument.
When a setter is called with an invalid value an Exception is thrown which
is what I expect.  I was surprised to see when I call the associated getter
after calling the setter I also get an Exception.

I would expect just a null value to be returned.  When the setter was called
and failed, I would think nothing would be set and we would return to the
condition on line 7.

1   XmlOptions options = new XmlOptions();
2   options.setValidateOnSet();
3   MetadataDocument doc = MetadataDocument.Factory.newInstance(options);
4   MetadataType metaElement = doc.addNewMetadata();
6   // This passes as I would expect this to return null
7   assertTrue(metaElement.getType() == null);
9   // Set illegal value, this does and should throw an Exception
10  try {
11   metaElement.setType(MetadataTypeEnum.Enum.forString("abc")); 
12  } catch (Exception e) { /* do nothing */ }
14  metaElement.getType();    // This throws an Exception, I would expect
15                            // it to return null.

Eric Murphy
Software Developer (NFIS)

tel/tél: 250-363-6038
fax / télécopieur 250-363-6004

Natural Resources Canada
Pacific Forestry Centre
506 West Burnside Road
Victoria BC V8Z 1M5

Ressources naturelles Canada
Centre de foresterie du Pacifique
506 rue Burnside ouest
Victoria, Colombie-Britanique V8Z 1M5

View raw message