[erlang-questions] ct_netconfc.erl: is this the expected behavior or is it a bug?

Martin Bjorklund mbj@REDACTED
Wed Mar 12 10:14:21 CET 2014


Alexander Poulikakos <alexander.poulikakos@REDACTED> wrote:
> Hi
> 
> Yes, this works for me (it also works without the 'xs' prefix), thanks
> for that :)
> 
> <?xml version=\"1.0\" encoding=\"UTF-8\"?> 
> <rpc message-id="1" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
>      <edit-config>
>          <target>
>              <running/>
>          </target>
>          <config>
>              <ElementA  xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0">
>                  <elementAId>1</elementAId>
>                  <elementB>
>                      <elementB>1</elementB>
>                      <  xc:operation="delete">
>                          <elementCId>6</elementCId>
>                      </elementC>
>                  </elementB>
>              </ElementA>
>          </config>
>      </edit-config>
>  </rpc>
> 
> 
> But what is the difference between putting the namespace attribute on
> ElementA, instead of config? Which is the correct NETCONF way? Or
> maybe it does not matter?

This is a generic XML issue, rather than NETCONF specific.

The XML attribute 'xmlns:xc="..."' is really like a variable
assignment:

  xc := "..."

After this, 'xc' can be used in the subtree as a prefix,
e.g. "xc:operation".

So in this example, it doesn't matter where you define your "xc"
prefix; you can put in on any element above the element where it is
used, e.g., any of <elementC>, <elementB>, <ElementA>, <config>,
<edit-config>, or <rpc>.
  
>              <ElementA  xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0">
>              <config xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0">
> Seems to work to add the namespace attribute on the "elementC" as well
> (at least for my SUT).
> 
> Is the example in RFC6241 [ http://tools.ietf.org/html/rfc6241 June
> 2011 page 41], where they use the "config" element, wrong? See below:

No, it is correct.


/martin

> 
> <rpc message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
>        <edit-config>
>          <target>
>            <running/>
>          </target>
>          <default-operation>none</default-operation>
>          <config xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0">
>            <top xmlns="http://example.com/schema/1.2/config">
>              <interface xc:operation="delete">
>                <name>Ethernet0/0</name>
>              </interface>
>            </top>
>          </config>
>        </edit-config>
>      </rpc>
> 
> 
> ///Alex
> 
> -----Original Message-----
> From: Martin Bjorklund [mailto:mbj@REDACTED] 
> Sent: den 11 mars 2014 14:50
> To: erlangsiri@REDACTED
> Cc: Alexander Poulikakos; erlang-questions@REDACTED
> Subject: Re: [erlang-questions] ct_netconfc.erl: is this the expected
> behavior or is it a bug?
> 
> Hi,
> 
> Siri Hansen <erlangsiri@REDACTED> wrote:
> > Would this also work ?
> > 
> > <?xml version=\"1.0\" encoding=\"UTF-8\"?> <rpc message-id=\"1\" 
> > xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">
> >     <edit-config>
> >         <target>
> >             <running/>
> >         </target>
> >         <config>
> >             <ElementA>
> >                 <elementAId>1</elementAId>
> >                 <elementB>
> >                     <elementB>1</elementB>
> >                     <elementC operation=\"delete\">
> >                         <elementCId>6</elementCId>
> >                     </elementC>
> >                 </elementB>
> >             </ElementA>
> >         </config>
> >     </edit-config>
> > </rpc>
> > 
> > 
> >  i.e. without the 'xc' prefix (the netconf base namespace is the 
> > default anyway).
> 
> This is actually not how default namespaces work.  The default
> namespace does not apply to XML attributes.
> 
> > It's probably up to your netconf server if it can handle that or not.
> 
> Some NETCONF servers are lax and will accept an unqualified
> "operation" attribute.
> 
> > Ideally it should be something like:
> > 
> > <?xml version=\"1.0\" encoding=\"UTF-8\"?> <rpc message-id=\"1\" 
> > xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">
> >     <edit-config>
> >         <target>
> >             <running/>
> >         </target>
> >         <config>
> >             <ElementA xmlns=\"mynamespace\"
> > xmlns:xc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">
> >                 <elementAId>1</elementAId>
> >                 <elementB>
> >                     <elementB>1</elementB>
> >                     <elementC xc:operation=\"delete\">
> >                         <elementCId>6</elementCId>
> >                     </elementC>
> >                 </elementB>
> >             </ElementA>
> >         </config>
> >     </edit-config>
> > </rpc>
> > 
> > where "mynamespace" defines your own config data.
> 
> This is the only example so far that is correct.  It is important that
> the "ElementA" has a namespace declaration; otherwise it refers to
> "ElementA" in the namespace "urn:ietf:params:xml:ns:netconf:base:1.0",
> which clearly is wrong.
> 
> 
> /martin
> 



More information about the erlang-questions mailing list