In an xsd file I have this element base type :
<xs:complexType name="event" abstract="true" >
<xs:attribute name="move" type="aos:move_ref" use="required" />
<xs:attribute name="type" type="aos:event_type" use="required" />
</xs:complexType>
And I want to define the value of the type attribute in the children types, so I tried this :
<xs:complexType name="signal" >
<xs:complexContent>
<xs:extension base="aos:event">
<xs:attribute name="type" type="aos:event_type" fixed="signal" />
<xs:attribute name="source" type="aos:signal_source" use="required" />
</xs:extension>
</xs:complexContent>
</xs:complexType>
Visual Studio don't seem to bother but CodeSynthesis C++ code generator don't seem to agree :
error: attribute 'type' is already defined in base
How should I write this? I just want the value of the type attribute to be specific to each different child type.
edit ----
To make the question more clear, I'll write the same thing I want to do but in C++.
Here is the base class :
class Event
{
public:
std::string name() const { return m_name; }
protected:
// we need the child class to set the name
Event( const std::string& name ) : m_name( name ) {}
// it's a base class
virtual ~Event(){}
private:
std::string m_name;
};
Now, one of the children could be implemented like this :
class Signal : public Event
{
public:
Signal() : Event( "signal" ){}
};
As you can see, the child class define the values of attributes that are defined by the base class. Is it even possible to express in xsd?
I just want the value of the type attribute to be specific to each different child type, if you want to define an attribute differently under same child/entity then its not possible, where as if you want to define same attribute differently for different entity/children then quite possible.