[xsd-users] Different C++ namespace for included schema

Matt Burnham mburnham at gblsys.com
Thu Sep 18 14:29:10 EDT 2008


I've looked through the archives and can't find an answer for what I'm 
trying to do.

I have 2 schemas (attached with command lines) and I want to specify 
different C++ namespaces (foo & bar) using the --namespace-map option.  
The second schema includes the first one and uses an element (type1) 
from the first one.  When I compile the resulting C++ code I get the 
error that 'type1' is not a member of 'bar' since type1 is in the 
namespace 'foo'.

Is there anyway to do this other than using the same namespace for both 
schemas (which I'd really rather not do)?

Thanks,
Matt

Schema 1: (compiled using xsd.exe cxx-tree --root-element type1 
--namespace-map =foo test1.xsd)

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <xsd:complexType name="type1">
        <xsd:attribute name="value1" type="xsd:int" use="required"/>
    </xsd:complexType>
</xsd:schema>

Schema 2: (compiled using xsd.exe cxx-tree --root-element type2 
--namespace-map =bar test2.xsd)

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <xsd:include schemaLocation="test1.xsd"/>
    <xsd:element name="type2" type="type2"/>
    <xsd:complexType name="type2">
        <xsd:all>
            <xsd:element name="type1" type="type1"/>
        </xsd:all>
    </xsd:complexType>
</xsd:schema>




More information about the xsd-users mailing list