[xsde-users] root element subset within a large schema/namespace

Eric Broadbent eric.broadbent at csr.com
Thu Dec 15 14:51:39 EST 2011


The element (and children) that I am currently attempting to parse is part of a comprehensive schema which also references about a dozen other schemas.
The element that I need to generate an object model for only refers to a couple of these other schemas, so ideally I would like not to have to generate code for all the possible elements in the rest of the namespace that I don't care about.

All of the examples that I've found deal with simple XML schemas and documents - and I can't tell whether what I would like to do is possible.
In a previous attempt, I was able to at least not invoke all the generated pskel/pimpl objects in the schema namespace by calling only the specific parser settor method for my root element.
I.e. in the generated code - instead of calling the "parsers" method to assign all parsers at once - I called just the method needed for my element of interest.
(in the "driver" code main)
- - - - - - - - - - - - - - - - - - - - -
  try
  {
    // Instantiate individual parsers.
    //
    CT_Document_pimpl CT_Document_p;
    CT_DocEl1_pimpl CT_DocEl1_p;
    CT_DocEl2_pimpl CT_DocEl2_p;
    ..
    CT_MyRootEl_pimpl CT_MyRootEl_p;
    ..
    ... many hundreds more of elements here - most not needed ...
    ...
    //
    // Connect the parsers together.
    //
    ...
#ifdef  ORIGINAL_CODE
    CT_Document_p.parsers (
                        ...
                        CT_DocEl1_p,
                        CT_DocEl2_p,
                        ...
                        CT_MyRootEl_p,
                        ... );

#else /* my customization */

    CT_DocRoot.targetelement_parser (CT_MyRootEl_p);

#endif /* ORIGINAL_CODE  or my customization */
    ...    
- - - - - - - - - - - - - - - - - - - - - - - - - 
Now that I'm using C++/Hybrid and the serializer code, the entire executable is quite large (40MB) and contains a lot of code that I don't really need, but I don't know exactly how to exclude all the unnecessary stuff.  If I provide the main schema and it's dependent schemas as required, XSD/e will generate code for all the contained elements - even if I use the "--root-element" option.

I suppose one way to deal with this is to generate my own copy of the schema which has only the target element/children that I want, and then filter the XML documents on input so that the only piece of the input stream that's given to the document_pimpl is the piece of interest.

Are there other ways of dealing with this that don't require schema-trimming?
Is there something in the examples that I just haven't looked for hard enough?

Thanks,

-Eric B.
Zoran/CSR



Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog



More information about the xsde-users mailing list