Re: [netmod] rfc6991-bis: "token" type?

Kent Watsen <kent+ietf@watsen.net> Mon, 22 April 2019 20:20 UTC

Return-Path: <0100016a46b54f44-ec6dd09f-f63b-48ee-914d-9718b27b0dc2-000000@amazonses.watsen.net>
X-Original-To: netmod@ietfa.amsl.com
Delivered-To: netmod@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 1DE3F120159 for <netmod@ietfa.amsl.com>; Mon, 22 Apr 2019 13:20:52 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.899
X-Spam-Level:
X-Spam-Status: No, score=-1.899 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=amazonses.com
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cyr0v5LbYgbR for <netmod@ietfa.amsl.com>; Mon, 22 Apr 2019 13:20:50 -0700 (PDT)
Received: from a8-88.smtp-out.amazonses.com (a8-88.smtp-out.amazonses.com [54.240.8.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 1DB2D12014C for <netmod@ietf.org>; Mon, 22 Apr 2019 13:20:49 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=6gbrjpgwjskckoa6a5zn6fwqkn67xbtw; d=amazonses.com; t=1555964448; h=From:Message-Id:Content-Type:Mime-Version:Subject:Date:In-Reply-To:Cc:To:References:Feedback-ID; bh=f4sNSHx5HLazgDOhOXy34NhwSlUfoLGkn06pIwzPIpc=; b=f+szsPqeH02LpoMVENgwtaj87rp0jlRRtQKpoasHj8cUT2ZplEOM/zkvu+JkexAX lE3+MQVByEGLcxTBjgpwPelwv5WTFq/bCVnPR7uHOm0wC7+lqBU+pCPk1bwvGIOlNOd R372zPRVrYRdJL56NbG7QPDGvuXGXgfYYTKG8+XE=
From: Kent Watsen <kent+ietf@watsen.net>
Message-ID: <0100016a46b54f44-ec6dd09f-f63b-48ee-914d-9718b27b0dc2-000000@email.amazonses.com>
Content-Type: multipart/alternative; boundary="Apple-Mail=_64FF39C5-D11A-4DA6-99AE-70B7006C6D1A"
Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\))
Date: Mon, 22 Apr 2019 20:20:48 +0000
In-Reply-To: <20190421144028.2pijzyloxxh77eix@anna.jacobs.jacobs-university.de>
Cc: "netmod@ietf.org" <netmod@ietf.org>
To: Juergen Schoenwaelder <j.schoenwaelder@jacobs-university.de>
References: <155535446032.10827.9204466950651701790@ietfa.amsl.com> <0100016a2ec8ed5f-14648cab-7615-4af4-9131-e85bf5826a03-000000@email.amazonses.com> <20190421144028.2pijzyloxxh77eix@anna.jacobs.jacobs-university.de>
X-Mailer: Apple Mail (2.3445.102.3)
X-SES-Outgoing: 2019.04.22-54.240.8.88
Feedback-ID: 1.us-east-1.DKmIRZFhhsBhtmFMNikgwZUWVrODEw9qVcPhqJEI2DA=:AmazonSES
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/Iop0GMcP-mjtEd8uaIDjlK_98nM>
Subject: Re: [netmod] rfc6991-bis: "token" type?
X-BeenThere: netmod@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: NETMOD WG list <netmod.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/netmod>, <mailto:netmod-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/netmod/>
List-Post: <mailto:netmod@ietf.org>
List-Help: <mailto:netmod-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/netmod>, <mailto:netmod-request@ietf.org?subject=subscribe>
X-List-Received-Date: Mon, 22 Apr 2019 20:20:52 -0000

Hi Juergen,


> can you provide examples where this particular type is useful?

Useful in many contexts.  For instance:

    list user {
      key name;
      leaf name {
        type string;
      }
      leaf password {
        type string;
      }

The following instance document is valid:

  <user>
    <name/>
    <password/>
  </user>

Adding pattern statements works, but gets old after awhile.  A built-in type would be helpful.


> Or were
> you generally looking for a type to name things and the XSD token type
> was the first one that came your mind?

Yes, from past-life experience with XSD, I found "token" and "normalizedString" useful (https://www.w3schools.com/XML/schema_dtypes_string.asp <https://www.w3schools.com/XML/schema_dtypes_string.asp>).   However, those types
do not fully express what I really want (including, e.g., non-empty), which is:

a) a type for a non-empty, stripped, printable string that MAY contain internal 'space' characters.

b) a type for a non-empty, stripped, printable string that MAY NOT contain internal 'space' characters.

/kw


> If the goal is to define a type for identifiers, then we likely should
> follow the Unicode standard annex UAX-31 and make use of <XID_Start>
> <XID_Continue>, which is what I think Python3 and Rust are using as
> the basis for their notion of language identifiers (but then the
> Unicode definitions are also criticized as buggy). A challenge is that
> the definition of <XID_Start> and <XID_Continue> seems to evolve with
> the unicode version. And once you start digging into the various
> attempts of modern programming languages to support internationalized
> identifiers, you discover that this is far from trivial to get right.
> 
> /js
> 
> On Thu, Apr 18, 2019 at 04:51:21AM +0000, Kent Watsen wrote:
>> 
>> Many times in models I want a non-empty version of what XSD calls a "token":
>> 
>>    token    A string that does not contain line feeds,
>>             carriage returns, tabs, leading or trailing
>>             spaces, or multiple spaces.
>> 
>> So how about the following?
>> 
>>  typedef token {
>>      type string;
>>      length "1.max";         // non-empty (some expr do this already)
>>      pattern "[^\n\r\t"]+"   // no LFs, CRs, or Tabs
>>      pattern "[^ ].*";       // no leading space     (min-length 1?)
>>      pattern ".*[^ ]";       // no trailing space    (min-length 1?)
>>      pattern ".*[^ ][^ ].*"  // no multiple spaces   (min-length 2?)
>>  }
>> 
>> Kent // contributor
>> 
>> 
>> _______________________________________________
>> netmod mailing list
>> netmod@ietf.org
>> https://www.ietf.org/mailman/listinfo/netmod
> 
> -- 
> Juergen Schoenwaelder           Jacobs University Bremen gGmbH
> Phone: +49 421 200 3587         Campus Ring 1 | 28759 Bremen | Germany
> Fax:   +49 421 200 3103         <https://www.jacobs-university.de/>