M
MichaelD
Hi!
How do I combine an element pattern with attributes?
I can validate
<phone>111-111-1111</phone> using
pattern
I can validate presence of attributes
<phone name="xyx" value="123">111-111-1111</phone>
but now I want to validate the content of phone (111-111-1111) using
pattern
and the presence of the attributes name and value.
I am seem to be unable to find the right notation to combine the two
This is one description I think should work but doesn't (tried many
alternatives but haven't found the right one yet...)
<xsd:complexType name="Phone">
<xsd:simpleContent>
<xsd:restriction base="xsd:string">
<xsdattern value="[0-9]{3}-[0-9]{3}-[0-9]{4}"/>
</xsd:restriction>
</xsd:simpleContent>
<xsd:attribute name="name" type="xsd:string" use="required"/>
<xsd:attribute name="value" type="xsd:string" use="optional"/>
</xsd:complexType>
the content of name and value need not be validated, just the presence
as described in the 'use'
This should be simple i guess, but I it click yet in my mind...
any help appreciated!!!
Michael
How do I combine an element pattern with attributes?
I can validate
<phone>111-111-1111</phone> using
pattern
I can validate presence of attributes
<phone name="xyx" value="123">111-111-1111</phone>
but now I want to validate the content of phone (111-111-1111) using
pattern
and the presence of the attributes name and value.
I am seem to be unable to find the right notation to combine the two
This is one description I think should work but doesn't (tried many
alternatives but haven't found the right one yet...)
<xsd:complexType name="Phone">
<xsd:simpleContent>
<xsd:restriction base="xsd:string">
<xsdattern value="[0-9]{3}-[0-9]{3}-[0-9]{4}"/>
</xsd:restriction>
</xsd:simpleContent>
<xsd:attribute name="name" type="xsd:string" use="required"/>
<xsd:attribute name="value" type="xsd:string" use="optional"/>
</xsd:complexType>
the content of name and value need not be validated, just the presence
as described in the 'use'
This should be simple i guess, but I it click yet in my mind...
any help appreciated!!!
Michael