@@ -18,7 +18,7 @@ use svd::peripheral::Peripheral;
18
18
#[ derive( Clone , Debug ) ]
19
19
pub struct Device {
20
20
pub name : String ,
21
- schema_version : String ,
21
+ schema_version : Option < String > ,
22
22
pub version : Option < String > ,
23
23
pub description : Option < String > ,
24
24
pub address_unit_bits : Option < u32 > ,
@@ -40,8 +40,7 @@ impl Parse for Device {
40
40
name : tree. get_child_text ( "name" ) ?,
41
41
schema_version : tree. attributes
42
42
. get ( "schemaVersion" )
43
- . unwrap ( )
44
- . clone ( ) ,
43
+ . map ( |s| s. clone ( ) ) ,
45
44
cpu : parse:: optional :: < Cpu > ( "cpu" , tree) ?,
46
45
version : tree. get_child_text_opt ( "version" ) ?,
47
46
description : tree. get_child_text_opt ( "description" ) ?,
@@ -77,14 +76,23 @@ impl Encode for Device {
77
76
String :: from ( "xmlns:xs" ) ,
78
77
String :: from ( "http://www.w3.org/2001/XMLSchema-instance" ) ,
79
78
) ;
80
- elem. attributes . insert (
81
- String :: from ( "schemaVersion" ) ,
82
- format ! ( "{}" , self . schema_version) ,
83
- ) ;
84
- elem. attributes . insert (
85
- String :: from ( "xs:noNamespaceSchemaLocation" ) ,
86
- format ! ( "CMSIS-SVD_Schema_{}.xsd" , self . schema_version) ,
87
- ) ;
79
+ match self . schema_version {
80
+ Some ( ref schema_version) => {
81
+ elem. attributes . insert (
82
+ String :: from ( "schemaVersion" ) ,
83
+ format ! ( "{}" , schema_version) ) ;
84
+ } ,
85
+ None => ( ) ,
86
+ }
87
+ match self . schema_version {
88
+ Some ( ref schema_version) => {
89
+ elem. attributes . insert (
90
+ String :: from ( "xs:noNamespaceSchemaLocation" ) ,
91
+ format ! ( "CMSIS-SVD_Schema_{}.xsd" , schema_version) ) ;
92
+ } ,
93
+ None => ( ) ,
94
+ }
95
+
88
96
89
97
match self . version {
90
98
Some ( ref v) => elem. children
0 commit comments