xml: bug 484257: allow to define values anywhere in the file
authorGeneviève Bastien <gbastien+lttng@versatic.net>
Tue, 12 Jan 2016 15:00:54 +0000 (10:00 -0500)
committerGenevieve Bastien <gbastien+lttng@versatic.net>
Thu, 14 Jan 2016 01:23:41 +0000 (20:23 -0500)
Values and locations do not have to be defined at the beginning of the file.
They should however precede any eventHandler related to it.

Change-Id: I27ce894f03b093d180d651a00325608228308273
Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net>
Reviewed-on: https://git.eclipse.org/r/64139
Reviewed-by: Hudson CI
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/test_xml_files/test_invalid/state_provider_placement.xml [new file with mode: 0644]
tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/test_xml_files/test_valid/state_provider_placement.xml [new file with mode: 0644]
tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/tmf/analysis/xml/core/module/xmlStateProvider.xsd

diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/test_xml_files/test_invalid/state_provider_placement.xml b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/test_xml_files/test_invalid/state_provider_placement.xml
new file mode 100644 (file)
index 0000000..fdb3202
--- /dev/null
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- ***************************************************************************
+* Copyright (c) 2016 École Polytechnique de Montréal
+*
+* All rights reserved. This program and the accompanying materials are
+* made available under the terms of the Eclipse Public License v1.0 which
+* accompanies this distribution, and is available at
+* http://www.eclipse.org/legal/epl-v10.html
+*************************************************************************** -->
+<tmfxml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:noNamespaceSchemaLocation="xmlDefinition.xsd">
+       
+       <stateProvider id="test.element.placement" version="1">
+               
+               <location id="CurrentWorker">
+            <stateAttribute type="constant" value="Worker" />
+            <stateAttribute type="eventField" value="workerno" />
+        </location>
+        
+               <!-- StateValues -->
+               <definedValue name="WORKING" value="3" />
+               <eventHandler eventName="start">
+                       <stateChange>
+                               <stateAttribute type="location" value="CurrentWorker" />
+                               <stateValue type="int" value="$WORKING" />
+                       </stateChange>
+               </eventHandler>
+               
+               <definedValue name="NO_FOLLOWING_EVENT_HANDLER" value="5" />
+               <location id="NoFollowingEventHandler">
+            <stateAttribute type="constant" value="Wrong" />
+            <stateAttribute type="eventField" value="place" />
+        </location>
+       </stateProvider>
+</tmfxml>
\ No newline at end of file
diff --git a/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/test_xml_files/test_valid/state_provider_placement.xml b/tmf/org.eclipse.tracecompass.tmf.analysis.xml.core.tests/test_xml_files/test_valid/state_provider_placement.xml
new file mode 100644 (file)
index 0000000..5b628ec
--- /dev/null
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- ***************************************************************************
+* Copyright (c) 2016 École Polytechnique de Montréal
+*
+* All rights reserved. This program and the accompanying materials are
+* made available under the terms of the Eclipse Public License v1.0 which
+* accompanies this distribution, and is available at
+* http://www.eclipse.org/legal/epl-v10.html
+*************************************************************************** -->
+<tmfxml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:noNamespaceSchemaLocation="xmlDefinition.xsd">
+       
+       <stateProvider id="test.element.placement" version="1">
+               
+               <location id="CurrentWorker">
+            <stateAttribute type="constant" value="Worker" />
+            <stateAttribute type="eventField" value="workerno" />
+        </location>
+        
+               <!-- StateValues -->
+               <definedValue name="WORKING" value="3" />
+               <eventHandler eventName="start">
+                       <stateChange>
+                               <stateAttribute type="location" value="CurrentWorker" />
+                               <stateValue type="int" value="$WORKING" />
+                       </stateChange>
+               </eventHandler>
+               
+               <definedValue name="WAIT" value="4" />
+               <eventHandler eventName="wait">
+                       <stateChange>
+                               <stateAttribute type="location" value="CurrentWorker" />
+                               <stateValue type="int" value="$WAIT" />
+                       </stateChange>
+               </eventHandler>
+
+               <definedValue name="IDLE" value="5" />
+               <eventHandler eventName="awake">
+                       <stateChange>
+                               <stateAttribute type="location" value="CurrentWorker" />
+                               <stateValue type="int" value="$IDLE" />
+                       </stateChange>
+               </eventHandler>
+       </stateProvider>
+</tmfxml>
\ No newline at end of file
index d957ee9af046498e04ec52d7df5ac4374fceac89..1fd93e3a3d968abcc2a11aa36f5d03d2ca6269d6 100644 (file)
                        <xs:element maxOccurs="1" minOccurs="0" name="head" type="headProvider" >
                                <xs:annotation>
                                        <xs:documentation>Provide meta-information on this state provider, like labels and applicable trace types.</xs:documentation></xs:annotation></xs:element>
-                       <xs:element maxOccurs="unbounded" minOccurs="0" name="definedValue" type="definedValue" >
-                               <xs:annotation>
-                                       <xs:documentation>Define a value that maps a string used in the state provider to a numbered value.</xs:documentation></xs:annotation></xs:element>
-                       <xs:element maxOccurs="unbounded" minOccurs="0" name="location" type="location" >
-                               <xs:annotation>
-                                       <xs:documentation>Declare shortcuts to frequently used attribute/data locations. For instance, if a path to an often-used attribute is CPUs/{event.some_field}/Threads/Status, it may be a good idea to put this path in a location and then use the location name in the event handlers.</xs:documentation></xs:annotation></xs:element>
-                       <xs:element maxOccurs="unbounded" minOccurs="1" name="eventHandler" type="eventHandler" >
-                               <xs:annotation>
-                                       <xs:documentation>Define how a given event will modify the state system being built. For each event in the trace that causes a state change, a event handler should be defined.</xs:documentation></xs:annotation></xs:element>
+                       <xs:sequence maxOccurs="unbounded" minOccurs="1">
+                               <xs:choice maxOccurs="unbounded" minOccurs="0">
+                                       <xs:element maxOccurs="unbounded" minOccurs="0" name="definedValue" type="definedValue" >
+                                               <xs:annotation>
+                                                       <xs:documentation>Define a value that maps a string used in the state provider to a numbered value.</xs:documentation></xs:annotation></xs:element>
+                                       <xs:element maxOccurs="unbounded" minOccurs="0" name="location" type="location" >
+                                               <xs:annotation>
+                                                       <xs:documentation>Declare shortcuts to frequently used attribute/data locations. For instance, if a path to an often-used attribute is CPUs/{event.some_field}/Threads/Status, it may be a good idea to put this path in a location and then use the location name in the event handlers.</xs:documentation></xs:annotation></xs:element>
+                               </xs:choice>
+                               <xs:element maxOccurs="unbounded" minOccurs="1" name="eventHandler" type="eventHandler" >
+                                       <xs:annotation>
+                                               <xs:documentation>Define how a given event will modify the state system being built. For each event in the trace that causes a state change, a event handler should be defined.</xs:documentation></xs:annotation></xs:element>
+                       </xs:sequence>
                </xs:sequence>
                <xs:attribute name="id" type="xs:string" use="required" >
                        <xs:annotation>
This page took 0.029684 seconds and 5 git commands to generate.