mbj4668 / pyang

An extensible YANG validator and converter in python
ISC License
537 stars 344 forks source link

yang2dsdl not finding "mktemp" and "xsltproc" #138

Closed mrehder closed 9 years ago

mrehder commented 9 years ago

Runnning yang2dsdl on Windows 7. The program complains that it can't find mktemp and xsltproc. It seems that either the installation is broken or documentation is missing about a dependency on other packages (which need to be installed). How would I fix this issue?

shinn1982 commented 9 years ago

+1 i have the same problem...

llhotka commented 9 years ago

yang2dsdl is a Unix shell script that was never intended to be run on Windows. Dependency on xsltproc and xmllint/jing is mentioned in the manpage.

I don't use Windows but if somebody writes a corresponding Windows script, we'll be happy to include it in pyang distribution.

mrehder commented 9 years ago

ok, so then what tool in Windows could I use to validate an XML instance of a YANG module?

llhotka commented 9 years ago

You need a RELAX NG validator and XSLT 1.0 processor, I am sure there are several choices available for Windows. Then it should be easy to perform the same steps as in the yang2dsdl script. Details are described in DsdlDetails.

mrehder commented 9 years ago

Got everything working following the wiki. It seems that “when” xpath statements are not validated. Is that intentional? Future feature?

From: Ladislav Lhotka [mailto:notifications@github.com] Sent: Friday, May 15, 2015 9:04 AM To: mbj4668/pyang Cc: Michael Rehder Subject: [MARKETING] Re: [pyang] yang2dsdl not finding "mktemp" and "xsltproc" (#138)

You need a RELAX NG validator and XSLT 1.0 processor, I am sure there are several choices available for Windows. Then it should be easy to perform the same steps as in the yang2dsdl script. Details are described in DsdlDetailshttps://github.com/mbj4668/pyang/wiki/DsdlDetails.

— Reply to this email directly or view it on GitHubhttps://github.com/mbj4668/pyang/issues/138#issuecomment-102392232.

Ce message et les renseignements qu'il contient sont exclusifs et confidentiels et sont assujettis a la politique d'Amdocs que vous pouvez consulter au http://www.amdocs.com/About/Pages/Email-Disclaimer-Fr.aspx

This message and the information contained herein is proprietary and confidential and subject to the Amdocs policy statement, you may review at http://www.amdocs.com/email_disclaimer.asp

llhotka commented 9 years ago

No, "when" is supported. Can you send me an example where it doesn't work?

mrehder commented 9 years ago

I did get an error eventually reported but I can’t figure out how to fix it.

YANG leaf physical-object { type boolean; mandatory true; description "Indicates if the component is a physical object or not."; } container physical-properties { uses physical-attributes; when "../physical-object=true"; description "Physical properties of the component."; }

XML

true
  <physical-properties>
    <height>933</height>
    <width>431</width>
    <depth>533</depth>
    <rack-units>21</rack-units>
    <power-consumed>155</power-consumed>
    <cooling-required>530</cooling-required>
  </physical-properties>
svrl:textNode "physical-properties" is only valid when "../deviceDefinition:physical-object=deviceDefinition:true"/svrl:text /svrl:failed-assert There are other when statements that are not reported as failing when they are clearly violating the expression. For example, YANG grouping physical-attributes { description "The physical properties of a component."; ``` leaf height { when "../../component-class=Chassis"; type uint32; units "millimeters"; description "Height and rack units need to be proportional (at 44.45mm per RU)"; } ``` XML Module Carrier true true 44 390 406 1 170 0 It seems that the xpath statement is ignored if it is incorrectly formatted or not accurate. Mike From: Ladislav Lhotka [mailto:notifications@github.com] Sent: Friday, May 22, 2015 3:55 AM To: mbj4668/pyang Cc: Michael Rehder Subject: [MARKETING] Re: [pyang] yang2dsdl not finding "mktemp" and "xsltproc" (#138) No, "when" is supported. Can you send me an example where it doesn't work? — Reply to this email directly or view it on GitHubhttps://github.com/mbj4668/pyang/issues/138#issuecomment-104556430. Ce message et les renseignements qu'il contient sont exclusifs et confidentiels et sont assujettis a la politique d'Amdocs que vous pouvez consulter au http://www.amdocs.com/About/Pages/Email-Disclaimer-Fr.aspx This message and the information contained herein is proprietary and confidential and subject to the Amdocs policy statement, you may review at http://www.amdocs.com/email_disclaimer.asp
llhotka commented 9 years ago

The "when" statement is wrong, it should be

 when "../physical-object='true'";

All string literal values have to be quoted because otherwise in this example the XPath processor tries to compare the values of two nodes (XML elements) namely ../physical-object and true. Since the latter doesn't exist, the expression is always false.

llhotka commented 9 years ago

By the way, you can use the the svrl2text.xsl stylesheet that's also included in pyang distribution for translating the SVRL reports into something readable.

mrehder commented 9 years ago

Ok, that explains the first case. What about the second? Even if the path is wrongly formatted, the expression should return false and thus declare that the presence of “height” is not allowed.

Mike

From: Ladislav Lhotka [mailto:notifications@github.com] Sent: Friday, May 22, 2015 10:45 AM To: mbj4668/pyang Cc: Michael Rehder Subject: [MARKETING] Re: [pyang] yang2dsdl not finding "mktemp" and "xsltproc" (#138)

The "when" statement is wrong, it should be

when "../physical-object='true'";

All string literal values have to be quoted because otherwise in this example the XPath processor tries to compare the values of two nodes (XML elements) namely ../physical-object and true. Since the latter doesn't exist, the expression is always false.

— Reply to this email directly or view it on GitHubhttps://github.com/mbj4668/pyang/issues/138#issuecomment-104678367.

Ce message et les renseignements qu'il contient sont exclusifs et confidentiels et sont assujettis a la politique d'Amdocs que vous pouvez consulter au http://www.amdocs.com/About/Pages/Email-Disclaimer-Fr.aspx

This message and the information contained herein is proprietary and confidential and subject to the Amdocs policy statement, you may review at http://www.amdocs.com/email_disclaimer.asp

llhotka commented 9 years ago

I do get a validation error:

$ yang2dsdl physical.yin 
== Generating RELAX NG schema './physical-data.rng'
Done.

== Generating Schematron schema './physical-data.sch'
Done.

== Generating DSRL schema './physical-data.dsrl'
Done.

$ yang2dsdl -s -j -b physical -v physical-data.xml 
== Using pre-generated schemas

== Validating grammar and datatypes ...
physical-data.xml validates.

== Adding default values... done.

== Validating semantic constraints ...
--- Failed assert at "/nc:data/ph:physical-properties/ph:height":
    Node "height" is only valid when "../../ph:component-class='Chassis'"

Here is the complete module and instance document with which I got the above result.

module physical {
  namespace "http://example.com/physical";
  prefix ph;

  grouping physical-attributes {
    leaf height {
      when "../../component-class='Chassis'";
      type uint16;
    }
    leaf width {
      type uint16;
    }
  }

  leaf physical-object {
    type boolean;
    default "false";
  }
  leaf component-class {
    type enumeration {
      enum "Chassis";
      enum "Module";
    }
    default "Module";
  }
  container physical-properties {
    uses physical-attributes;
    when "../physical-object = 'true'";
  }
}
<?xml version="1.0" encoding="UTF-8"?>
<nc:data xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"
      xmlns="http://example.com/physical">
  <physical-object>true</physical-object>
  <component-class>Module</component-class>
  <physical-properties>
    <height>933</height>
    <width>431</width>
  </physical-properties>
</nc:data>
mrehder commented 9 years ago

I’m in Windows and so not using yang2dsdl. I’m using the tools directly on an xml instance file, following your wiki page.

From: Ladislav Lhotka [mailto:notifications@github.com] Sent: Friday, May 22, 2015 11:13 AM To: mbj4668/pyang Cc: Michael Rehder Subject: [MARKETING] Re: [pyang] yang2dsdl not finding "mktemp" and "xsltproc" (#138)

I do get a validation error:

$ yang2dsdl physical.yin

== Generating RELAX NG schema './physical-data.rng'

Done.

== Generating Schematron schema './physical-data.sch'

Done.

== Generating DSRL schema './physical-data.dsrl'

Done.

$ yang2dsdl -s -j -b physical -v physical-data.xml

== Using pre-generated schemas

== Validating grammar and datatypes ...

physical-data.xml validates.

== Adding default values... done.

== Validating semantic constraints ...

--- Failed assert at "/nc:data/ph:physical-properties/ph:height":

Node "height" is only valid when "../../ph:component-class='Chassis'"

Here is the complete module and instance document with which I got the above result.

module physical {

namespace "http://example.com/physical";

prefix ph;

grouping physical-attributes {

leaf height {

  when "../../component-class='Chassis'";

  type uint16;

}

leaf width {

  type uint16;

}

}

leaf physical-object {

type boolean;

default "false";

}

leaf component-class {

type enumeration {

  enum "Chassis";

  enum "Module";

}

default "Module";

}

container physical-properties {

uses physical-attributes;

when "../physical-object = 'true'";

}

}

<?xml version="1.0" encoding="UTF-8"?>

<nc:data xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"

  xmlns="http://example.com/physical">
true Module ``` 933 431 ```

/nc:data

— Reply to this email directly or view it on GitHubhttps://github.com/mbj4668/pyang/issues/138#issuecomment-104685641.

Ce message et les renseignements qu'il contient sont exclusifs et confidentiels et sont assujettis a la politique d'Amdocs que vous pouvez consulter au http://www.amdocs.com/About/Pages/Email-Disclaimer-Fr.aspx

This message and the information contained herein is proprietary and confidential and subject to the Amdocs policy statement, you may review at http://www.amdocs.com/email_disclaimer.asp