Custom attributes in xsd schema

I am trying to create a simple xml editor for some basic, but specific needs, the fact that I'm not sure how to handle it is that I want to have my own custom attributes (or something else) in the xsd scheme itself.

Something like what I had in mind:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <xsd:element name="Book">
      <xsd:complexType>
         <xsd:sequence>
            <xsd:element name="Author" type="xsd:string" listable="1" />
            <xsd:element name="Pages" type="xsd:int" />
         </xsd:sequence>
      </xsd:complexType>
   </xsd:element>
</xsd:schema>

Where do I need information about whether an element is “enumerated” or not in the scheme (note that the .xml file does not have any information or a hint as to whether this element is accessible or not, an enumerated attribute is just a way to organize the elements in the editor).

He does not need to be his own attribute. If there is any attribute or something that I can play with this, everything will be fine. The problem is that the above schema does not check (the "listable" attribute is not supported in this context.)

Is there a way to save this kind of information in a schema?

It seems like it would be possible to create a new namespace, but I don't know how this namespace should be declared so that any element can have a special attribute in xsd (I would prefer to avoid messing with the xml file for this). And it seems like a bit overkill to create a new namespace for just that?

Or did I not quite understand this?

+5
source share
1 answer

. . , xsd: documentation, , xsd: appinfo, , . , :

 <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:foo="http://www.example.org/bar">
   <xsd:element name="Book">
      <xsd:complexType>
         <xsd:sequence>
            <xsd:element name="Author" type="xsd:string" >
        <xsd:annotation>
            <xsd:appinfo>
                <foo:listable value="true"/>
            </xsd:appinfo>
        </xsd:annotation>
             </xsd:element>
            <xsd:element name="Pages" type="xsd:int" />
         </xsd:sequence>
      </xsd:complexType>
   </xsd:element>
</xsd:schema>
+5

All Articles