[xsd-users] Elements with CDATA content
Boris Kolpackov
boris at codesynthesis.com
Wed Mar 7 05:50:07 EST 2012
Hi James,
James & Veri Martin <verimart at hotmail.com> writes:
>
> I have string-based elements in my schema for which I'd like to use CDATA
> content. I found this posting regarding the treatment of elements with
> CDATA content:
>
> http://www.codesynthesis.com/pipermail/xsd-users/2008-March/001590.html
>
> ...but it dates from 2008. I am wondering if the techniques referenced
> there are currently the only mechanisms for including CDATA content in
> an xs:string-based element?
Yes, these are the options.
> Is there not an attribute I can set on an instance of a generated class
> for such elements that instructs serialization to enclose the content in
> a CDATA section?
No, there is no such attribute. But you can always provide a custom
mapping for the xs:string type which will allow you to set a flag and
then serialize the data as either normal text or CDATA, depending on
this flag.
Boris
More information about the xsd-users
mailing list