- From: <noah_mendelsohn@us.ibm.com>
- Date: Fri, 6 Jan 2006 17:08:59 -0500
- To: "Thomson, Martin" <Martin.Thomson@andrew.com>
- Cc: www-xml-schema-comments@w3.org
Martin Thompson writes: > To save us all from having to do something like the below, it might be useful to have an IP address base type. I'm not speaking officially for the workgroup, but in general there are a huge number of potentially useful datatypes that we could have standardized. Every community wants their own. The physicists want measurements (ranging from angstroms to light years, grams to tons, etc.), the printer folks want measurements (in pixels or twips [1]), calendar folks want dates that know about timezones, librarians want ISBN numbers, mathemeticians want a type for prime numbers, etc. So, we tried to draw the line at a modest number of types that were particularly useful and widely useful in XML, and especially those that could be used by others to create standard types. Note that you can write your own schema for an IP address type, either as a subtype of string, or perhaps as a list of integers if you prefer. Put it in a namespace of your choosing and promote its use as a standard. Get some appropriate standards body to do it and maintain it. Yes, there are compromises: "::1" and "0:0:0:0:0:0:1" will not be equal. Then again, there are only a few places in Schema itself where equality matters (enumerations, fixed value constraints, and key/keyref come to mind.) XML Query makes more use of our types, but that's in some respects a reason for not defining too many. Every time we define a type, they have to consider all the possible functions and type coercions that may be necessary (e.g. can you cast an IP address to a string?) There's a real cost to such feature-richness. Specs get larger, testing time goes up, and code winds up in systems that may never use it. So, it's a tradeoff. In general, our model was not to define all the important types in the world, but to provide the mechanisms that would let others derive a reasonable subsetset of the necessary types, albeit with compromises. I should note that your input to the workgroup has been logged in our comments system, and will come up for formal consideration in due course (thought it may take awhile, since we're pretty busy with XML Schema 1.1). Thank you for taking the trouble to comment. Noah [1] http://www.applecore99.com/api/api012.asp -------------------------------------- Noah Mendelsohn IBM Corporation One Rogers Street Cambridge, MA 02142 1-617-693-4036 -------------------------------------- "Thomson, Martin" <Martin.Thomson@andrew.com> Sent by: www-xml-schema-comments-request@w3.org 12/05/2005 05:59 PM To: <www-xml-schema-comments@w3.org> cc: (bcc: Noah Mendelsohn/Cambridge/IBM) Subject: 1.1 Datatypes - suggest base types for IP addresses To save us all from having to do something like the below, it might be useful to have an IP address base type. Constraining facets might be: length, minLength, maxLength, pattern and enumeration. Care should be taken to ensure that "::1" and "0:0:0:0:0:0:1" are equal. Values are totally ordered. Values are bounded (to 32 and 128 bits). Cheers, Martin p.s. maybe someone has a better regex set for IPv6 addresses, I've kept it in different patterns here, but a (...|..|.) set would work equally well. ----------- <xsd:simpleType name="ipv4"> <xsd:annotation> <xsd:documentation> An IP version 4 address. </xsd:documentation> </xsd:annotation> <xsd:restriction base="xsd:token"> <xsd:pattern value="(25[0-5]|2[0-4][0-9]|[0-1]?[0-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|[0-1]?[0-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|[0-1]?[0-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|[0-1]?[0-9]?[0-9])"/> <xsd:pattern value="[0-9A-Fa-f]{8}"/> </xsd:restriction> </xsd:simpleType> <xsd:simpleType name="ipv6"> <xsd:annotation> <xsd:documentation> An IP version 6 address, based on RFC 1884. </xsd:documentation> </xsd:annotation> <xsd:restriction base="xsd:token"> <!-- Fully specified address --> <xsd:pattern value="[0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){7}"/> <!-- Double colon start --> <xsd:pattern value=":(:[0-9A-Fa-f]{1,4}){1,7}"/> <!-- Double colon middle --> <xsd:pattern value="([0-9A-Fa-f]{1,4}:){1,6}(:[0-9A-Fa-f]{1,4}){1}"/> <xsd:pattern value="([0-9A-Fa-f]{1,4}:){1,5}(:[0-9A-Fa-f]{1,4}){1,2}"/> <xsd:pattern value="([0-9A-Fa-f]{1,4}:){1,4}(:[0-9A-Fa-f]{1,4}){1,3}"/> <xsd:pattern value="([0-9A-Fa-f]{1,4}:){1,3}(:[0-9A-Fa-f]{1,4}){1,4}"/> <xsd:pattern value="([0-9A-Fa-f]{1,4}:){1,2}(:[0-9A-Fa-f]{1,4}){1,5}"/> <xsd:pattern value="([0-9A-Fa-f]{1,4}:){1}(:[0-9A-Fa-f]{1,4}){1,6}"/> <!-- Double colon end --> <xsd:pattern value="([0-9A-Fa-f]{1,4}:){1,7}:"/> <!-- Embedded IPv4 addresses --> <xsd:pattern value="((:(:0{1,4}){0,3}(:(0{1,4}|[fF]{4}))?)|(0{1,4}:(:0{1,4}){0,2}(:(0{1,4}|[fF]{4}))?)|((0{1,4}:){2}(:0{1,4})?(:(0{1,4}|[fF]{4}))?)|((0{1,4}:){3}(:(0{1,4}|[fF]{4}))?)|((0{1,4}:){4}(0{1,4}|[fF]{4})?)):(25[0-5]|2[0-4][0-9]|[0-1]?[0-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|[0-1]?[0-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|[0-1]?[0-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|[0-1]?[0-9]?[0-9])"/> <!-- The unspecified address --> <xsd:pattern value="::"/> </xsd:restriction> </xsd:simpleType> ------------------------------------------------------------------------------------------------ This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information. If you have received it in error, please notify the sender immediately and delete the original. Any unauthorized use of this email is prohibited. ------------------------------------------------------------------------------------------------ [mf2]
Received on Friday, 6 January 2006 22:09:17 UTC