XSD : How to set attributes values in children element type?
Posted: Tue Nov 23, 2010 9:52 pm
I posted this question on stackoverflow but I think there is no solution :/ http://stackoverflow.com/questions/4199 ... ement-type
If an XML/XSD expert is around, maybe he could help me on this one. I've been looking for an alternative for some days but without success.
Here is a copy of the question :
----
n an xsd file I have this element base type :
And I want to define the value of the type attribute in the children types, so I tried this :
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 :
Now, one of the children could be implemented like this :
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?
----
Any idea?
If an XML/XSD expert is around, maybe he could help me on this one. I've been looking for an alternative for some days but without success.
Here is a copy of the question :
----
n an xsd file I have this element base type :
Code: Select all
<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>Code: Select all
<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>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 :
Code: Select all
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;
};Code: Select all
class Signal : public Event
{
public:
Signal() : Event( "signal" ){}
};----
Any idea?