Re: [netmod] Whitespace in XML encoding - allowed ?

Martin Bjorklund <mbj@tail-f.com> Tue, 09 October 2018 10:07 UTC

Return-Path: <mbj@tail-f.com>
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 24EEC13123D for <netmod@ietfa.amsl.com>; Tue, 9 Oct 2018 03:07:10 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.9
X-Spam-Level:
X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
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 O_7mBYOc0KjB for <netmod@ietfa.amsl.com>; Tue, 9 Oct 2018 03:07:07 -0700 (PDT)
Received: from mail.tail-f.com (mail.tail-f.com [46.21.102.45]) by ietfa.amsl.com (Postfix) with ESMTP id 78BE51311AD for <netmod@ietf.org>; Tue, 9 Oct 2018 03:07:07 -0700 (PDT)
Received: from localhost (unknown [173.38.220.61]) by mail.tail-f.com (Postfix) with ESMTPSA id CEA391AE0187; Tue, 9 Oct 2018 12:07:05 +0200 (CEST)
Date: Tue, 09 Oct 2018 12:07:05 +0200
Message-Id: <20181009.120705.20836607492685594.mbj@tail-f.com>
To: balazs.lengyel@ericsson.com
Cc: netmod@ietf.org
From: Martin Bjorklund <mbj@tail-f.com>
In-Reply-To: <14e78aaa-4508-970a-d1a0-e091ffaf5c8e@ericsson.com>
References: <14e78aaa-4508-970a-d1a0-e091ffaf5c8e@ericsson.com>
X-Mailer: Mew version 6.7 on Emacs 24.5 / Mule 6.0 (HANACHIRUSATO)
Mime-Version: 1.0
Content-Type: Text/Plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/ysnD4oSVkFBB8dvE91Gw-s8DR74>
Subject: Re: [netmod] Whitespace in XML encoding - allowed ?
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, 09 Oct 2018 10:07:10 -0000

Balázs Lengyel <balazs.lengyel@ericsson.com> wrote:
> Hello,
> 
> Recently we came up against a problem where a certain implementation
> did not accept the following:
> 
> <with-defaults xmlns="...">
>     report-all
> </with-defaults>
> 
> while it did accept
> 
> <with-defaults xmlns="...">report-all</with-defaults>
> 
> I am unsure whether YANG's XML encoding allows whitespace before and
> after a leaf's value? In RFC7950 it does not say yes or no.

For example, RFC 7950 says about integers in 9.2.1:

   An integer value is lexically represented as an optional sign ("+" or
   "-"), followed by a sequence of decimal digits.  If no sign is
   specified, "+" is assumed.

So, space characters (and other characters) are not allowed.  In XML,
whitespace has meaning, so:

   <foo>42</foo>

is not the same as

   <foo> 42 </foo>

Since the string " 42 " is not a legal integer lexical representation
according to 9.2.1, <foo> 42 </foo> is not a valid XML representation
for the integer foo.

> I have
> found the following examples that seem to allow preceding/following
> whitespace:
> 
> https://tools.ietf.org/html/rfc7950#section-4.2.9
> 
>        <status xmlns="http://example.com/system">
>          The image example-fw-2.3 is being installed.
>        </status>
>
> https://tools.ietf.org/html/rfc7950#section-7.16.3
> 
>          <reporting-entity>
>            /ex:interface[ex:name='Ethernet0']
>          </reporting-entity>
> 
> https://tools.ietf.org/html/rfc6243#appendix-A.3.1
> 
>         <with-defaults
>          xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults">
>           report-all
>         </with-defaults>

Yes, to be strict, these examples should have had some text that
explained that whitespace was added for readability.  New documents
will hopefully use the new artwork draft's rules instead.



/martin


> It is problematic that this is not clarified. IMHO this should be
> clarified in an errata to rfc7950. Chose one:
> 
> 1 It is not allowed to add preceding or following whitespace after the
>   value of a leaf/leaf-list.
>   Note that some text documents may add whitespace to Netconf examples
>   to avoid long lines,
>   however this extra whitespace MUST NOT be present in the actual
>   Netconf encoding.
> 
> 2 It is not allowed to add preceding or following whitespace after the
>   value of a leaf/leaf-list.
> 3 It is allowed to add preceding or following whitespace after the
>   value of a leaf/leaf-list except
>   for string based types, where the whitespace could be part of the
>   leaf's value itself..
> 
> What do you think?
> 
> regards Balazs
> 
> --
> Balazs Lengyel                       Ericsson Hungary Ltd.
> Senior Specialist
> Mobile: +36-70-330-7909              email: Balazs.Lengyel@ericsson.com