[xsd-users] start/end tags versus empty tag
Barrie Kovish
barrie.kovish at singularsoftware.com
Tue May 18 07:43:48 EDT 2010
Boris,
Thanks for the quick response. Unfortunately virtually everything in our xsd is a mixed complex type so presumably your suggestion won't work. I'm thinking I will need to write some custom XML parsing code to deal with this issue.
Barrie
On 2010-05-18, at 4:03 AM, Boris Kolpackov wrote:
> Hi Barrie,
>
> Barrie Kovish <barrie.kovish at singularsoftware.com> writes:
>
>> I'm using XSD tree mapping. I would like to be able to force empty
>> elements to be written out as start end tags instead of an empty tag,
>> i.e. start/end tags:
>>
>> <car></car>
>>
>> instead of empty tag:
>>
>> <car/>
>
> There is no easy way to get this behavior. One thing that you can
> do is to add a whitespace as the value of the element:
>
> <car> </car>
>
> This will work for elements that have complex content and for which
> mixed is not set to true. For such elements whitespaces are ignored,
> provided, of course, the other end will ignore them as well.
>
> If this approach works for you, the best way to implement it would
> probably be to serialize the object model to a DOM document, then
> recursively traverse this document and add a space to every empty
> element. Once this is done, you can serialize the document to XML.
>
> Boris
More information about the xsd-users
mailing list