[XML Schema] Element with restriction and attribute

webmasterbeta

New Member
I am trying to write a XML Schema and I want it to validate an example XML element. But there's one thing that I can't really get to work: I'm trying to write something that will validate the following:
<email public="yes">[email protected]</email>

I want to place restrictions on both the attribute and the value of the field, but I can't seem to get it to work. The attribute should only be able to take the values "yes" and "no" and the email adress should be verified through a regular expression. I know how to make an element that contains just text and an attribute: (the attribute restriction is taken care of by the publicType)

<xs:element name="email">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="public" type="publicType" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</element>

I'd like to add something like this to that:
<xs:restriction base="xs:string">
<xs:pattern value=http://www.webdeveloper.com/forum/archive/index.php/"^[0-9a-z]([-_.~]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,4}$"/>
</xs:restriction>

The problem is that I need a restriction for the email field. But I need an extension to attach the attribute. And I can't have both, because that's appearantly illegal in XML Schema.
Can anyone help me with this please?
 
Back
Top