Stephen Canzano · Apr 13, 2016

XMLExport and Validation

I interested on how others feel on this subject.  In general terms when you have a class that extends from %XML.Adaptor and you call XMLExport no validation is automatically done as part of the XMLExport process.  As an example if you do the following


SAMPLES>S tPatient=##Class(Sample.Person).%New()
SAMPLES>Set tPatient.Name="asdfghjklqwrrrrokkfkljbvkfbjflkbjflkbjblkjblkjdblkjblkcn l nn klkjdfkbjdlkbjlkbj"

SAMPLES>w tPatient.XMLExport(,",indent")
  <Name>asdfghjklqwrrrrokkfkljbvkfbjflkbjflkbjblkjblkjdblkjblkcn l nn klkjdfkbjdlkbjlkbj</Name>


where tPatient.Name has a value which is greater than the MAXLEN for %String.  I understand I can declare MAXLEN for the Name property but my point is XMLExport will produce a representation of the Patient object even thought the same representation could not be Correlated via %XML.Reader or Saved.  The similar way of looking at this is suppose in Patient there is

Property Gender As %String(VALUELIST=',M,F');

if a Patient object is created and then the Gender property is set to XYZ when calling XMLExport no validation will be done.


I'm not proposing that XMLExport always force validation but I'm interested in what other feel about this somewhat inconsistency.  From a practical perspective we have run into specific issues with HealthShare Streamlets and Correlation.

0 603
Discussion (3)1
Log in or sign up to continue

Data type validation occurs when you run the % Save () method to persist the object in the database 

Perhaps you could run %Save() and only run the XXL Export if the %Save was successful

The problem with this is I believe they do not want the object saved into the database at all. It seams like a worthwhile enhancement that export to XML could optionally call %ValidateObject on the objects as it walks the tree.

You can run tPatient.%ValidateObject() and check returned status before doing XMLExport