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

Kent Watsen <kent+ietf@watsen.net> Tue, 23 April 2019 02:12 UTC

Return-Path: <0100016a47f7934f-e3a8cbae-e61f-40f2-a256-997db1dd46e2-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 1B2C712012F for <netmod@ietfa.amsl.com>; Mon, 22 Apr 2019 19:12:52 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.898
X-Spam-Level:
X-Spam-Status: No, score=-1.898 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, URIBL_BLOCKED=0.001] 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 ouNozx-Z7bmN for <netmod@ietfa.amsl.com>; Mon, 22 Apr 2019 19:12: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 E74BB12012A for <netmod@ietf.org>; Mon, 22 Apr 2019 19:12:49 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=6gbrjpgwjskckoa6a5zn6fwqkn67xbtw; d=amazonses.com; t=1555985568; h=From:Message-Id:Content-Type:Mime-Version:Subject:Date:In-Reply-To:Cc:To:References:Feedback-ID; bh=YKq/lLOUfUGAzhmlHdnON4HmHf6qe5kUJb8SsHBI368=; b=iMS91m8nZvO2nHJkvgRDmE3zbmY/ANcEyhJKWfZCUH38WuFeWLmwUyer/LQyNV+y ROwW2cg2pozSdvMx8IkHkrZvhzMDQbRPPXpUp1tbUWOw0E4TdxBDF4gZ/+pFMV0CUyV cde/5EHcZuboB1oY5Yr8JiZ6r0RZTpN7udAkI5WE=
From: Kent Watsen <kent+ietf@watsen.net>
Message-ID: <0100016a47f7934f-e3a8cbae-e61f-40f2-a256-997db1dd46e2-000000@email.amazonses.com>
Content-Type: multipart/alternative; boundary="Apple-Mail=_0ACD9592-13DE-408E-B394-C32F2E0DDD59"
Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\))
Date: Tue, 23 Apr 2019 02:12:48 +0000
In-Reply-To: <CABCOCHRi4xCebGjy1Cr7mwBHjzSPsEHTTVU=ZBTYHMWj0sJfKQ@mail.gmail.com>
Cc: Juergen Schoenwaelder <j.schoenwaelder@jacobs-university.de>, "netmod@ietf.org" <netmod@ietf.org>
To: Andy Bierman <andy@yumaworks.com>
References: <155535446032.10827.9204466950651701790@ietfa.amsl.com> <0100016a2ec8ed5f-14648cab-7615-4af4-9131-e85bf5826a03-000000@email.amazonses.com> <20190421144028.2pijzyloxxh77eix@anna.jacobs.jacobs-university.de> <0100016a46b54f44-ec6dd09f-f63b-48ee-914d-9718b27b0dc2-000000@email.amazonses.com> <CABCOCHRi4xCebGjy1Cr7mwBHjzSPsEHTTVU=ZBTYHMWj0sJfKQ@mail.gmail.com>
X-Mailer: Apple Mail (2.3445.102.3)
X-SES-Outgoing: 2019.04.23-54.240.8.88
Feedback-ID: 1.us-east-1.DKmIRZFhhsBhtmFMNikgwZUWVrODEw9qVcPhqJEI2DA=:AmazonSES
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/2AsDCP4ACuGBfwFoBYRWnEyEmjQ>
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: Tue, 23 Apr 2019 02:12:52 -0000

yang-identifier is not appropriate.

Ignore the password, it's not the important (e.g., passwords can have spaces at the beginning or end).

K.





> On Apr 22, 2019, at 9:43 PM, Andy Bierman <andy@yumaworks.com>; wrote:
> 
> 
> 
> On Mon, Apr 22, 2019 at 1:21 PM Kent Watsen <kent+ietf@watsen.net <mailto:kent%2Bietf@watsen.net>> wrote:
> 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;
>       }
> 
> 
> 
> Why would type string be used?
> 
>     list user {
>       key name;
>       leaf name {
>         type yang:yang-identifier;
>       }
>       leaf password {
>         type iana:crypt-hash;
>       }
>   }
> 
> Still not clear on the use-cases for a token data type.
> 
> 
> Andy
>  
> 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 <mailto:netmod@ietf.org>
>>> https://www.ietf.org/mailman/listinfo/netmod <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/ <https://www.jacobs-university.de/>>
> 
> _______________________________________________
> netmod mailing list
> netmod@ietf.org <mailto:netmod@ietf.org>
> https://www.ietf.org/mailman/listinfo/netmod <https://www.ietf.org/mailman/listinfo/netmod>