Subject: [netmod] YANG strings vs XPath strings

From: Andy Bierman <[email-masked]>
Date: Wed, 10 Sep 2008 08:30:42 -0700

Hi,

The draft should highlight the differences between XPath strings
and YANG strings, and which applies.

All strings in a YANG file are YANG strings.
The compiler will follow the rules for YANG quoting and
string concatenation, not XPath rules.

(BTW, you should always use single-quotes for pattern strings
  unless you really know what you are doing.)

So how does the user include a double quote within a must-expr?
Is it the character entity &quot;?
Is it the YANG escaped quote \"?
In order to use the escaped quote, the entire string must be
double-quoted, which means all the whitespace trimming will
be done as well.  This may or may not matter to the XPath expression.

What about other character entities, like &lt; and &gt;?

IMO, YANG should define specific processing steps,
so that all YANG modules will be interpreted exactly
the same way by a compliant compiler.

Andy

_______________________________________________
netmod mailing list
[email-masked]
https://www.ietf.org/mailman/listinfo/netmod

---

From: Phil Shafer <[email-masked]>
Date: Wed, 10 Sep 2008 12:42:27 -0400

>  unless you really know what you are doing.)

Why do you say that?

>So how does the user include a double quote within a must-expr?

Use single quotes or escape the double quote.

>Is it the character entity &quot;?

&quot; is a UTF-8 character entity, so your parser should parse
this into '"'.  Since the entire file is UTF-8, you can say voodoo
like:

    leaf &quot;test&quot; {
        description '&quot;' + &quot;\&quot;&quot; + "
                     <-- look! two quotes";
    }

and the right thing should happen.

>Is it the YANG escaped quote \"?

This should work.

>be done as well.  This may or may not matter to the XPath expression.

And you can mix single and double quotes using "+".

>What about other character entities, like &lt; and &gt;?

These keep their normal UTF-8 magic, but get no other magic,
so "<foo>" and "&lt;foo&gt;" are identical.

>the same way by a compliant compiler.

Does this need to be detailed in the spec, in the FAQ, or in "The
YANG Book"?

Thanks,
 Phil

---

From: "Lahdensivu, Mikko (NSN - FI/Tampere)" <[email-masked]>
Date: Wed, 10 Sep 2008 20:24:45 +0300

Hi,

>-----Original Message-----
>From: [email-masked] [mailto:[email-masked]] 
>On Behalf Of ext Phil Shafer
>Sent: 10.09.2008 19:42
>To: Andy Bierman
>Cc: NETMOD Working Group
>Subject: Re: [netmod] YANG strings vs XPath strings
>
>Andy Bierman writes:

>&quot; is a UTF-8 character entity, so your parser should 
>parse this into '"'.  Since the entire file is UTF-8, you can 
>say voodoo
>like:
>
>    leaf &quot;test&quot; {

>so "<foo>" and "&lt;foo&gt;" are identical.

&quot; or other such entity references (which not same as character
references i.e. &#32;) are not part of UTF-8 encoding, but are just part
of XML. Some other UTF-8 reader would not necessarily interpret them as
entity references like an XML parser would.

If the idea is that entity references (or even character references)
from XML can be used in Yang, then it must be explictly specified in
Yang. Yin gets these of course from XML.

Regards,

Mikko

---

From: Andy Bierman <[email-masked]>
Date: Wed, 10 Sep 2008 10:34:47 -0700

>>  unless you really know what you are doing.)

Double quoted strings get processed,
like replacing escape-chars and trimming whitespace.
Single-quoted strings do not get touched.

Andy

---

From: Martin Bjorklund <[email-masked]>
Date: Wed, 10 Sep 2008 22:33:58 +0200 (CEST)

> and YANG strings, and which applies.

I think it might be confusing to do so, but maybe you can propose some
text that we can discuss?

> string concatenation, not XPath rules.

What XPath rules?  (Should we really list all rules we don't follow??)

> Is it the character entity &quot;?

No we never say that in the draft.  That's an XML thing.  If you write
YIN models, you can use this.

> Is it the YANG escaped quote \"?

If you're in a double quoted string, yes.

> be done as well.  This may or may not matter to the XPath expression.

Sure.

> What about other character entities, like &lt; and &gt;?

Useful in YIN only since it's XML.

> the same way by a compliant compiler.

Are you saying that we need something more than the rules in 6.1.3?

/martin

---

From: Andy Bierman <[email-masked]>
Date: Wed, 10 Sep 2008 15:25:52 -0700

> Are you saying that we need something more than the rules in 6.1.3?

It is now clear to me that character entities are NOT converted
when they are inside a quoted string.  These do not follow
the same rules as a select attribute, encoded inside a
NETCONF PDU (XML document).

Instead, they will be treated as errors and not converted,
since the must-stmt strings are in YANG documents,
not XML documents.  YANG does not recognize any character
entities inside quotes strings.  C-style escape char sequences
are used in YANG instead.

As for character entities peppered throughout the YANG document:
I was not aware that was a requirement for YANG compilers.
It should be made more clear in the draft.

Andy

---

From: Ladislav Lhotka <[email-masked]>
Date: Thu, 11 Sep 2008 09:16:27 +0200

Hi,

I don't really understand this discussion. A string in the value space
must have the same meaning everywhere, it is only its representation in
the lexical spaces where YANG differs from XML.

If we agree that YANG mapping from the lexical to value space is
well-defined, there should be no doubt about any value space value and
this is what is used in XPath evaluation or whatever.

If a value space string is converted to serialized XML (e.g., YIN), it
must follow the XML encoding rules. So

      '&quot;'       -->  <string of length 6>  -->      &amp;quot;
 YANG lexical space           value space            XML lexical space

Lada

-- 
Ladislav Lhotka, CESNET
PGP Key ID: E74E8C0C

---

From: Juergen Schoenwaelder <[email-masked]>
Date: Thu, 11 Sep 2008 09:27:22 +0200

>  YANG lexical space           value space            XML lexical space

I agree.

/js

-- 
Juergen Schoenwaelder           Jacobs University Bremen gGmbH
Phone: +49 421 200 3587         Campus Ring 1, 28759 Bremen, Germany
Fax:   +49 421 200 3103         <http://www.jacobs-university.de/>
_______________________________________________
netmod mailing list
[email-masked]
https://www.ietf.org/mailman/listinfo/netmod

---

From: Phil Shafer <[email-masked]>
Date: Thu, 11 Sep 2008 10:06:02 -0400

>Single-quoted strings do not get touched.

The intent was that double quoted string would be more useful,
since are more flexible.  You only need single quotes when you
want to avoid the need to use escapes.

Thanks,
 Phil