XSD : How to set attributes values in children element type?

A place for Ogre users to discuss non-Ogre subjects with friends from the community.
Post Reply
User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
x 56
Contact:

XSD : How to set attributes values in children element type?

Post by Klaim »

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 :

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>
And I want to define the value of the type attribute in the children types, so I tried this :

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>
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 :

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;

};
Now, one of the children could be implemented like this :

Code: Select all

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?

----


Any idea?
Post Reply