Closed mrehder closed 9 years ago
+1 i have the same problem...
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.
ok, so then what tool in Windows could I use to validate an XML instance of a YANG module?
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.
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
No, "when" is supported. Can you send me an example where it doesn't work?
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
<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>
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.
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.
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
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>
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">
/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
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?