English 中文(简体)
XSD: specifying element with 12 characters and area code is digit
原标题:
  • 时间:2009-11-13 05:12:37
  •  标签:
  • syntax
  • xsd

What is the XSD syntax, given

<xs:element name="PhoneNumber" type="xs:string" ...? >

, to specify the following format for a phone number:

12 characters and area code is digits.

example of values:

<PhoneNumber>213-555-5845</PhoneNumber>
<PhoneNumber>213-695-CARE</PhoneNumber>
<PhoneNumber>213-4URGENT</PhoneNumber>
最佳回答

You need to define a simple type deriving from xs:string with a pattern restriction:

  <xs:simpleType name="PhoneNumberType">
    <xs:restriction base="xs:string">
      <xs:pattern value="d{3}-.{8}"/>
    </xs:restriction>
  </xs:simpleType>

(here the regex requires 3 digits first, then a dash "-", then exactly 8 other characters, for a total of 12 characters.

Then use that type in your phone number element:

<xs:element name="PhoneNumber" type="PhoneNumberType" ...? >

Marc

问题回答

暂无回答




相关问题
How to change out-of-focus text selection color in Xcode?

Okay, I ll bite. I ve got really pleasant code/window colors set up in Xcode. Ordinarily, my selection color is very visible. When I am doing a project search and iterating through the results, ...

pdo database abstraction

Can someone help me to see what is going wrong with this setup I build the @sql query in the function below like this. The extra quotes are setup in the conditions array. $sql .= " WHERE $...

I wish I could correlate an "inline view"

I have a Patient table: PatientId Admitted --------- --------------- 1 d/m/yy hh:mm:ss 2 d/m/yy hh:mm:ss 3 d/m/yy hh:mm:ss I have a PatientMeasurement table (0 to ...

Syntax help! Php and MYSQL

Original: $sql = "SELECT DATE(TimeAdded) AS Date, $column_name FROM Codes ORDER BY TimeAdded ASC"; Altered: $sql = "SELECT DATE("m", TimeAdded ) AS Date, ColumnName FROM TableName ORDER BY ...

Is this code Equivalent

I am not a fan of the following construction if (self = [super init]) { //do something with self assuming it has been created } Is the following equivalent? self = [super init]; if (self != ...

热门标签