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

From: Balázs Lengyel <[email-masked]>
Date: Tue, 9 Oct 2018 08:59:56 +0000

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. 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>

It is problematic that this is not clarified. IMHO this should be
clarified in an errata to rfc7950. Chose one:

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.

It is not allowed to add preceding or following whitespace
after the value of a leaf/leaf-list.

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: [email-masked]

---

From: Qin Wu <[email-masked]>
Date: Tue, 9 Oct 2018 09:23:52 +0000

This issue has been touched by earlier version of draft-kwatsen-netmod-artwork-folding-07.
RFC7950 has provide XML encoding rule as follows:
"
Any whitespace between the subelements to the list entry is
   insignificant, i.e., an implementation MAY insert whitespace
   characters between subelements.
"
Similar rule is applied to leaf-list.

-Qin
发件人: netmod [mailto:[email-masked]] 代表 Balázs Lengyel
发送时间: 2018年10月9日 17:00
收件人: [email-masked]
主题: [netmod] Whitespace in XML encoding - allowed ?

Hello,

Recently we came up against a problem where a certain implementation did not accept the following:

    report-all

</with-defaults>

while it did accept

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. I have found the following examples that seem to allow preceding/following whitespace:

       <status xmlns="http://example.com/system"<http://example.com/system>>

       </status>

         <reporting-entity>

         </reporting-entity>

        <with-defaults

          report-all

        </with-defaults>

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

--

Senior Specialist

Mobile: +36-70-330-7909              email: [email-masked]<mailto:[email-masked]>

---

From: Balázs Lengyel <[email-masked]>
Date: Tue, 9 Oct 2018 10:02:47 +0000

Hello,

That does not answer my question about whitespace around
individual leaf/leaf-list values. The question about all these
examples is also open.

regards Balazs

On 2018. 10. 09. 11:23, Qin Wu wrote:

This issue has been touched by earlier version
of draft-kwatsen-netmod-artwork-folding-07.

RFC7950 has provide XML encoding rule as
follows:

"

Any whitespace between the subelements to the
list entry is

insignificant, i.e., an implementation MAY
insert whitespace

"

-Qin

发件人:
netmod [mailto:[email-masked]]
代表
Balázs Lengyel

发送时间: 2018年10月9日 17:00

收件人: [email-masked]

主题: [netmod] Whitespace in XML encoding -
allowed ?

Hello,

Recently we came up against a problem
where a certain implementation did not accept the following:

report-all

</with-defaults>

while it did accept

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. I have found the
following examples that seem to allow preceding/following
whitespace:

</status>

<reporting-entity>

</reporting-entity>

<with-defaults

report-all

</with-defaults>

It is problematic that this is not
clarified. IMHO this should be clarified in an errata to
rfc7950. Chose one:

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.

It is not allowed to add preceding or
following whitespace after the value of a leaf/leaf-list.

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

--

Senior Specialist

---

From: Martin Bjorklund <[email-masked]>
Date: Tue, 09 Oct 2018 12:07:05 +0200 (CEST)

Balázs Lengyel <[email-masked]> wrote:
> 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:
> 

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

> 1 It is not allowed to add preceding or following whitespace after the
>   value of a leaf/leaf-list.
> 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

---

From: "Adrian Farrel" <[email-masked]>
Date: Tue, 9 Oct 2018 11:17:45 +0100

Hence why we go through so many hoops in the line-wrapping draft.

Adrian

> -----Original Message-----
> From: netmod [mailto:[email-masked]] On Behalf Of Martin Bjorklund
> Sent: 09 October 2018 11:07
> To: [email-masked]
> Cc: [email-masked]
> Subject: Re: [netmod] Whitespace in XML encoding - allowed ?
> 
> _______________________________________________
> netmod mailing list
> [email-masked]
> https://www.ietf.org/mailman/listinfo/netmod

---

From: Ladislav Lhotka <[email-masked]>
Date: Tue, 09 Oct 2018 12:37:37 +0200

> <with-defaults xmlns="...">report-all</with-defaults>

The "with-defaults" leaf is modelled as an enumeration in RFC 6243
(sec. 5), so the lexical representation is the assigned name,
i.e. "report-all". So the behaviour above is correct according to the
spec.

On the other hand, this looks like a good place for applying the Postel
principle because enum names must not have any leading or trailing
whitespace, so no confusion can ever arise if this whitespace is
stripped.

Lada

>
> 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. I have found the following examples that seem to allow
> 1 It is not allowed to add preceding or following whitespace after the value of a leaf/leaf-list. 
> 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

-- 
Ladislav Lhotka
Head, CZ.NIC Labs
PGP Key ID: 0xB8F92B08A9F76C67

---

From: Kent Watsen <[email-masked]>
Date: Tue, 9 Oct 2018 17:24:15 +0000

As Martin points out, this is how XML works.

As a result, XML instance documents are poster-child examples for why long lines occur sometimes, and where the artwork-folding draft shines when placing said examples into drafts.

Lada, good point, but would there be a layer violation?

Kent // contributor

---

From: Ladislav Lhotka <[email-masked]>
Date: Wed, 10 Oct 2018 08:53:50 +0200

On Tue, 2018-10-09 at 17:24 +0000, Kent Watsen wrote:
> As a result, XML instance documents are poster-child examples for why long
> lines occur sometimes, and where the artwork-folding draft shines when placing
> said examples into drafts.
> 

Which layers do you mean? XML and YANG parser on top of it? An XML processor is
expected to pass the whitespace unchanged to the application (except for EOL
normalization), and it is up to the YANG parser how the data is interpreted.

Lada

---

From: Balázs Lengyel <[email-masked]>
Date: Fri, 12 Oct 2018 14:13:47 +0000

Hello,

Thanks for all the replies. So preceding and following whitespace
is not allowed.

However as I got similar questions often, and some RFC examples
seem to indicate that it is allowed, I feel that an explanatory
statement like the following would help YANG users.:

"It is not allowed to add preceding or following whitespace after
the value of a leaf/leaf-list.

Netconf encoding."

regards Balazs

On 2018. 10. 09. 10:59, Balázs Lengyel
wrote:

Hello,

while it did accept

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. I have found the following examples that seem to allow
preceding/following whitespace:

<reporting-entity>

<with-defaults

It is problematic that this is not clarified. IMHO this should
be clarified in an errata to rfc7950. Chose one:

What do you think?

regards Balazs