Subject: | XML::Pastor::Type to_xml_dom short-circuits values which are defined but Boolean false |
Date: | Tue, 31 Jan 2017 22:10:34 +0000 |
To: | "bug-XML-Pastor [...] rt.cpan.org" <bug-XML-Pastor [...] rt.cpan.org> |
From: | Mark Solinski <mark.solinski [...] gpsinsight.com> |
When determining what value to write out as XML, if we have a field in the DOM called Count of type xs:int which has a value of '0' (in the DOM). We would expect that it would be written out as "<Count>0</Count>". Instead it is written out as "<Count/>".
This is because when check what value should be written out, the following logic appears in the to_xml_dom subroutine of XML::Pastor::Type in the block with the condition "if (UNIVERSAL::can($self, '__value'))":
if($self->__value()) && ...
Since this will return false if the value is '0', we must change the logic to...
If(defined($self->__value()) && ...
After making this change, writing this element to XML will produce "<Count>0</Count>".