[xsd-users] serialize empty element

Boris Kolpackov boris at codesynthesis.com
Mon Jan 29 02:44:08 EST 2007


Hi Bradley,

Bradley Beddoes <beddoes at intient.com> writes:

> I was wondering if there might be any suggestions as to how to serialize
>  to an empty element.
>
> I have attempted to enable default ctors and serialize an object and
> this seg faults for obvious reasons.
>
> Essentially I would like to be able to create an object representing an
> element and have it written to the DOMDocument as an empty element so
> that other code can come along and replace this empty element with on
> the fly generated content.

I am not quite sure what you mean here by the empty element. If the
schema allows for this element to be empty (e.g., no required
attributes and all elements are minOccurs=0, etc.) then you should
be able to serialize it without problems.

But I guess (from the segfault you've mentioned) that what you are
trying to do is serialize an element without some required attributes
or elements so that you can get the nested elements/attributes
created (though without any legal values). This is not going to work
since the generated serialization code expects the tree to be valid
and to contain all required attributes and elements. I guess you will
have to create those DOM nodes manually.

hth,
-boris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 652 bytes
Desc: Digital signature
Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20070129/5ed58410/attachment.pgp


More information about the xsd-users mailing list