[xsd-users] Re: Some questions about xsd

Boris Kolpackov boris at codesynthesis.com
Tue Mar 20 11:28:43 EDT 2007


Hi Sergei,

In the future please send technical questions like this to the
xsd-users  mailing list (which I've CC'ed) rather than to me
directly. This way a) other developers who may have experienced
a similar problem can provide you with a solution and b) questions
and answers will be archived and available to others with similar
problems.

Sergei V. Firsov <sergei.firsov at mail.ru> writes:

>   At first, i want to say BIG THANKS for your product XSD.
>   It's first product which is really can parse/serialize xsd/xml
>   schemas and files and sources really works.

This is nice of you to say, thanks! I am glad you're enjoying it.

>   But i have some questions:
>   - Is it possible to include xsi:type attribute into ouptut file?
>   Something like this:
>             <pi:Label xsi:type="xs:normalizedString" />
>             <Title xsi:nil="true" xsi:type="xs:normalizedString" />
>   I have found type-serializer-map files, but how use it?

At the moment XSD includes xsi:type only when the actual type
and the declared type differ. This is a common practice and
results in XML instances which are not bloated with unnecessary
xsi:type attributes. Why would you need to include xsi:type in
places where it is not required?


>   - For example my XSD schema is:
>         <xs:complexType name="ItemContentType" abstract="true">
>                 <xs:sequence>
>                         <xs:element name="Label" type="xs:normalizedString" nillable="true" minOccurs="0"/>
>                         <xs:element name="is_a" type="RecordIdType" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
>                 </xs:sequence>
>                 <xs:attribute name="isClosed" type="xs:boolean" use="optional" default="false"/>
>                 <xs:attribute name="isWeaklySigned" type="xs:boolean" use="optional"  default="false"/>
>                 <xs:attribute name="isWeaklyEncrypted" type="xs:boolean" use="optional"  default="false"/>
>         </xs:complexType>
>
>         How i can force xsd  include "isClose", isWeaklySigned and etc
>         only if attribute value not equal default value?

We are planning to implement this in the next version. I will let you
know when there is a beta for you to try.


>
>         Now i have solved this problem by modifing "<<" output operator
> ----------
>         if (i.isWeaklySigned() != pimessage::ItemContentType::isWeaklySigned::default_value())
>         {
>             ::xsd::cxx::xml::dom::attribute< wchar_t > a (
>                 L"isWeaklySigned",
>                 e);
>             a.dom_attribute () << i.isWeaklySigned ();
>         }
> ----------
>         But i think it's not good solution, in't it?

That's pretty much what we will have in the generated code so you can
use this method for now. Its major drawback is that your changes will
be lost when you regenerate your code.


Thanks for the suggestions!

-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/20070320/756c5efb/attachment.pgp


More information about the xsd-users mailing list