]> jspc29.x-matter.uni-frankfurt.de Git - daqtools.git/commitdiff
Added comments to schema, fixed its indentation, xml-db.pl checks now validity
authorAndreas Neiser <neiser@kph.uni-mainz.de>
Fri, 28 Jun 2013 12:41:13 +0000 (14:41 +0200)
committerAndreas Neiser <neiser@kph.uni-mainz.de>
Fri, 28 Jun 2013 12:41:13 +0000 (14:41 +0200)
xml-db/database/TrbNet.xsd
xml-db/database/testing.xml
xml-db/xml-db.pl

index 6c95a82c3d9676e76826a45e0e24e44266d6f408..d634573d54c91f522542d4dd398a887c9126f193 100644 (file)
 <?xml version="1.0" encoding="utf-8" ?>
 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
 
-<!--==============================
-    Type Definitions
-==============================-->
-<xs:simpleType name="nametype">
-  <xs:restriction base="xs:string">
-    <xs:pattern value="[0-9a-zA-Z_]+"/>
-  </xs:restriction>
-</xs:simpleType> 
-
-<xs:simpleType name="addresstype">
-  <xs:restriction base="xs:string">
-    <xs:pattern value="[0-9a-fA-F]{4}"/>
-  </xs:restriction>
-</xs:simpleType> 
-
-<xs:simpleType name="valuetype">
-  <xs:restriction base="xs:string">
-    <xs:pattern value="[0-9a-fA-F]+"/>
-  </xs:restriction>
-</xs:simpleType> 
-
-<xs:simpleType name="modetype">
-  <xs:restriction base="xs:string">
-    <xs:pattern value="[rwb]+"/>
-    <!-- (r)ead and /or (w)rite, plus maybe (b)lock, if a no-more-data from this registers transports some vital information-->
-  </xs:restriction>
-</xs:simpleType> 
-
-<xs:simpleType name="functiontype">
- <xs:restriction base="xs:string">
+  <!--==============================
+      Type Definitions
+      ==============================-->
+  <xs:simpleType name="nametype">
+    <xs:restriction base="xs:string">
+      <xs:pattern value="[0-9a-zA-Z_]+"/>
+    </xs:restriction>
+  </xs:simpleType> 
+
+  <xs:simpleType name="addresstype">
+    <xs:restriction base="xs:string">
+      <xs:pattern value="[0-9a-fA-F]{4}"/>
+    </xs:restriction>
+  </xs:simpleType> 
+
+  <xs:simpleType name="valuetype">
+    <xs:restriction base="xs:string">
+      <xs:pattern value="[0-9a-fA-F]+"/>
+    </xs:restriction>
+  </xs:simpleType> 
+
+  <xs:simpleType name="modetype">
+    <xs:restriction base="xs:string">
+      <xs:pattern value="r|w|rw|b"/>
+      <!-- (r)ead and /or (w)rite, plus maybe (b)lock, if a no-more-data from this registers transports some vital information-->
+    </xs:restriction>
+  </xs:simpleType> 
+
+  <xs:simpleType name="functiontype">
+    <!-- config: setup some behaviour
+         trigger: register which starts some kind of operation of the hardware
+         status: slowly changing information
+         statistics: quickly changing information
+  
+         Note: The difference between "status" and "statistics" is not sharp,
+         they both give some information about the system. Usually, statistics
+         is updated every event (e.g. number of read-out triggers received),
+         whereas status contains more "constant" stuff (e.g. temperature)   
+    -->
+    <xs:restriction base="xs:string">
       <xs:enumeration value="config"/>
       <xs:enumeration value="trigger"/>
       <xs:enumeration value="status"/>
       <xs:enumeration value="statistics"/>
     </xs:restriction>
-</xs:simpleType> 
-
-<xs:simpleType name="bittype">
-  <xs:restriction base="xs:integer">
-    <xs:minInclusive value="0"/>
-    <xs:maxInclusive value="31"/>
-  </xs:restriction>
-</xs:simpleType> 
-
-<xs:simpleType name="formattype">
- <xs:restriction base="xs:string">
-    <xs:enumeration value="raw"/>
-    <xs:enumeration value="integer"/>
-    <xs:enumeration value="signed"/>
-    <xs:enumeration value="unsigned"/>
-    <xs:enumeration value="hex"/>
-    <xs:enumeration value="bitmask"/>
-    <xs:enumeration value="boolean"/>
-    <xs:enumeration value="time"/>
-    <xs:enumeration value="string"/>
-  </xs:restriction>
-</xs:simpleType> 
-
-
-<!--==============================
-    Attribute Definition
-==============================-->
-<xs:attribute name="name"         type="nametype" />
-<xs:attribute name="address"      type="addresstype" />
-<xs:attribute name="offset"       type="addresstype" />
-<xs:attribute name="mode"         type="modetype"  />
-<xs:attribute name="type"         type="functiontype" />
-<xs:attribute name="function"     type="functiontype" />
-<xs:attribute name="start"        type="bittype" />
-<xs:attribute name="size"         type="xs:positiveInteger" />
-<xs:attribute name="defaultValue" type="valuetype" />
-<xs:attribute name="value"        type="valuetype" />
-<xs:attribute name="format"       type="formattype" />
-<xs:attribute name="continuous"   type="xs:boolean" />
-<xs:attribute name="repeat"       type="xs:positiveInteger" default="1" />
-
-
-<!--==============================
-    Simple Elements
-==============================-->
-<xs:element name="description" type="xs:string" />
-
-<!--==============================
-    Complex Elements
-==============================-->
-<xs:element name="TrbNet">
-  <xs:complexType>
-    <xs:choice maxOccurs="unbounded">
-      <xs:element   ref="description" minOccurs="1" maxOccurs="1" />
-      <xs:element   ref="group"       maxOccurs="unbounded" />
-      <xs:element   ref="register"    maxOccurs="unbounded" />
-      <xs:element   ref="memory"      maxOccurs="unbounded" />
-      <xs:element   ref="fifo"        maxOccurs="unbounded" />
-    </xs:choice>
-    <xs:attribute ref="name" />
-    <xs:attribute ref="address" />
-  </xs:complexType>
-</xs:element>
-
-<xs:element name="group">
-  <xs:complexType>
-    <xs:choice maxOccurs="unbounded">
-      <xs:element   ref="group"       maxOccurs="unbounded" />
-      <xs:element   ref="description" minOccurs="1" maxOccurs="1" />
-      <xs:element   ref="register"    maxOccurs="unbounded" />
-      <xs:element   ref="memory"      maxOccurs="unbounded" />
-      <xs:element   ref="fifo"        maxOccurs="unbounded" />
-    </xs:choice>
-    <xs:attribute ref="name" use="required" />
-    <xs:attribute ref="address" />
-    <xs:attribute ref="size" />
-    <xs:attribute ref="function" />
-    <xs:attribute ref="continuous" />
-    <xs:attribute ref="mode" />
-    <xs:attribute ref="format" />
-    <xs:attribute ref="repeat" />
-  </xs:complexType>
-</xs:element> 
-
-
-<xs:element name="field">
-  <xs:complexType>
-    <xs:all>
-      <xs:element   ref="description" minOccurs="1" maxOccurs="1" />
-    </xs:all>
-    <xs:attribute ref="name" />
-    <xs:attribute ref="start" />
-    <xs:attribute ref="size" />
-    <xs:attribute ref="type" />
-    <xs:attribute ref="mode" />
-    <xs:attribute ref="defaultValue" />
-    <xs:attribute ref="format" />
-    <xs:attribute ref="repeat" />
-  </xs:complexType>
-</xs:element> 
-
-
-<xs:element name="register">
-  <xs:complexType>
-    <xs:choice maxOccurs="unbounded">
-      <xs:element   ref="field" />
-      <xs:element   ref="description" minOccurs="1" maxOccurs="1" />
-    </xs:choice>
-    <xs:attribute ref="name" />
-    <xs:attribute ref="address" />
-    <xs:attribute ref="mode" />
-    <xs:attribute ref="function" />
-    <xs:attribute ref="repeat" />
-  </xs:complexType>
-</xs:element> 
-
-<xs:element name="memory">
-  <xs:complexType>
-    <xs:choice maxOccurs="unbounded">
-      <xs:element   ref="field" />
-      <xs:element   ref="description" minOccurs="1" maxOccurs="1" />
-    </xs:choice>
-    <xs:attribute ref="name" />
-    <xs:attribute ref="address" />
-    <xs:attribute ref="size" />
-    <xs:attribute ref="mode" />
-    <xs:attribute ref="function" />
-  </xs:complexType>
-</xs:element> 
-
-<xs:element name="fifo">
-  <xs:complexType>
-    <xs:choice maxOccurs="unbounded">
-      <xs:element   ref="field" />
-      <xs:element   ref="description" minOccurs="1" maxOccurs="1" />
-    </xs:choice>
-    <xs:attribute ref="name" />
-    <xs:attribute ref="address" />
-    <xs:attribute ref="mode" />
-    <xs:attribute ref="function" />
-  </xs:complexType>
-</xs:element> 
+  </xs:simpleType> 
+
+  <xs:simpleType name="bittype">
+    <xs:restriction base="xs:integer">
+      <xs:minInclusive value="0"/>
+      <xs:maxInclusive value="31"/>
+    </xs:restriction>
+  </xs:simpleType> 
+
+  <xs:simpleType name="formattype">
   <xs:restriction base="xs:string">
+      <xs:enumeration value="raw"/>
+      <xs:enumeration value="integer"/>
+      <xs:enumeration value="signed"/>
+      <xs:enumeration value="unsigned"/>
+      <xs:enumeration value="hex"/>
+      <xs:enumeration value="bitmask"/>
+      <xs:enumeration value="boolean"/>
+      <xs:enumeration value="time"/>
+      <xs:enumeration value="string"/>
+    </xs:restriction>
+  </xs:simpleType> 
+
+
+  <!--==============================
+      Attribute Definition
+      ==============================-->
+  <xs:attribute name="name"         type="nametype" />
+  <xs:attribute name="address"      type="addresstype" />
+  <xs:attribute name="offset"       type="addresstype" />
+  <xs:attribute name="mode"         type="modetype"  />
+  <xs:attribute name="type"         type="functiontype" />
+  <xs:attribute name="function"     type="functiontype" />
+  <xs:attribute name="start"        type="bittype" />
+  <xs:attribute name="size"         type="xs:positiveInteger" />
+  <xs:attribute name="defaultValue" type="valuetype" />
+  <xs:attribute name="value"        type="valuetype" />
+  <xs:attribute name="format"       type="formattype" />
+  <xs:attribute name="continuous"   type="xs:boolean" />
+  <xs:attribute name="repeat"       type="xs:positiveInteger" default="1" />
+
+
+  <!--==============================
+      Simple Elements
+      ==============================-->
+  <xs:element name="description" type="xs:string" />
+
+  <!--==============================
+      Complex Elements
+      ==============================-->
+  <xs:element name="TrbNet">
+    <xs:complexType>
+      <xs:choice maxOccurs="unbounded">
+        <xs:element   ref="description" minOccurs="1" maxOccurs="1" />
+        <xs:element   ref="group"       maxOccurs="unbounded" />
+        <xs:element   ref="register"    maxOccurs="unbounded" />
+        <xs:element   ref="memory"      maxOccurs="unbounded" />
+        <xs:element   ref="fifo"        maxOccurs="unbounded" />
+      </xs:choice>
+      <xs:attribute ref="name" />
+      <xs:attribute ref="address" />
+    </xs:complexType>
+  </xs:element>
+
+  <xs:element name="group">
+    <xs:complexType>
+      <xs:choice maxOccurs="unbounded">
+        <xs:element   ref="group"       maxOccurs="unbounded" />
+        <xs:element   ref="description" minOccurs="1" maxOccurs="1" />
+        <xs:element   ref="register"    maxOccurs="unbounded" />
+        <xs:element   ref="memory"      maxOccurs="unbounded" />
+        <xs:element   ref="fifo"        maxOccurs="unbounded" />
+      </xs:choice>
+      <xs:attribute ref="name" use="required" />
+      <xs:attribute ref="address" />
+      <xs:attribute ref="size" />
+      <xs:attribute ref="function" />
+      <xs:attribute ref="continuous" />
+      <xs:attribute ref="mode" />
+      <xs:attribute ref="format" />
+      <xs:attribute ref="repeat" />
+    </xs:complexType>
+  </xs:element> 
+
+
+  <xs:element name="field">
+    <xs:complexType>
+      <xs:all>
+        <xs:element   ref="description" minOccurs="1" maxOccurs="1" />
+      </xs:all>
+      <xs:attribute ref="name" />
+      <xs:attribute ref="start" />
+      <xs:attribute ref="size" />
+      <xs:attribute ref="type" />
+      <xs:attribute ref="mode" />
+      <xs:attribute ref="defaultValue" />
+      <xs:attribute ref="format" />
+      <xs:attribute ref="repeat" />
+    </xs:complexType>
+  </xs:element> 
+
+
+  <xs:element name="register">
+    <xs:complexType>
+      <xs:choice maxOccurs="unbounded">
+        <xs:element   ref="field" />
+        <xs:element   ref="description" minOccurs="1" maxOccurs="1" />
+      </xs:choice>
+      <xs:attribute ref="name" />
+      <xs:attribute ref="address" />
+      <xs:attribute ref="mode" />
+      <xs:attribute ref="function" />
+      <xs:attribute ref="repeat" />
+    </xs:complexType>
+  </xs:element> 
+
+  <xs:element name="memory">
+    <xs:complexType>
+      <xs:choice maxOccurs="unbounded">
+        <xs:element   ref="field" />
+        <xs:element   ref="description" minOccurs="1" maxOccurs="1" />
+      </xs:choice>
+      <xs:attribute ref="name" />
+      <xs:attribute ref="address" />
+      <xs:attribute ref="size" />
+      <xs:attribute ref="mode" />
+      <xs:attribute ref="function" />
+    </xs:complexType>
+  </xs:element> 
+
+  <xs:element name="fifo">
+    <xs:complexType>
+      <xs:choice maxOccurs="unbounded">
+        <xs:element   ref="field" />
+        <xs:element   ref="description" minOccurs="1" maxOccurs="1" />
+      </xs:choice>
+      <xs:attribute ref="name" />
+      <xs:attribute ref="address" />
+      <xs:attribute ref="mode" />
+      <xs:attribute ref="function" />
+    </xs:complexType>
+  </xs:element> 
 
 
 </xs:schema> 
-  
+
index 2619fb87ce1b344b72a7ad8f08f311ef62079805..183bf3437d59ef4d852e493e3f6b51a0fcf7afcd 100644 (file)
@@ -2,7 +2,7 @@
 <TrbNet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="TrbNet.xsd"
         name="JtagController"
-        offset="1000"
+        address="1000"
         >
   <group
       name="JtagCommonControl"
@@ -15,7 +15,7 @@
     <register
         name="WaitBeforeStart"
         address="0007"
-        mode="rw"
+        mode="rww"
         function ="config"
         >
       <description>Wait time between write sequence and start signal.</description>
index abc6cb3ebb43c08b0109125c1e8a05ba82462d7a..eb10576baf156d491b63e5756b589b464df90e7e 100755 (executable)
@@ -27,10 +27,14 @@ pod2usage(-exitval => 0, -verbose => 2) if $man;
 print "Database: $db_dir\n" if $verbose;
 
 my $doc = XML::LibXML->new->parse_file("$db_dir/testing.xml");
-my $xmlschema = XML::LibXML::Schema->new( location => "$db_dir/TrbNet.xsd" );
+my $xmlschema = XML::LibXML::Schema->new('location' => "$db_dir/".
+                                         $doc->getDocumentElement->getAttribute('xsi:noNamespaceSchemaLocation'));
 
 $xmlschema->validate($doc);
 
+#print $xsd;
+
+
 __END__
 
 =head1 NAME