Re: [xml] namespace problem



hmm now i deleted the body in the example and the namespace just want to read
 

<parameters>

<parameter description="" exchangeMode="EXCHANGE" group="" name="parameter1" path="">

<param parName="parameter1" type="DOUBLE" val="0.0"/>    <----- these attributes ... but i cant ...strange ... the line above works

</parameter>

</parameters>


do u have an idea what can be wrong?
2010/1/4 Andreas Wagner <andreaswagner7 gmail com>
Hi,
 
thx for ur example. The example works, but not my file. An example of a real file could be:
 
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<example>
  <header>
    <channels>
      <channel description="" group="can" name="headlight" path="" recordmode="3" type="BOOLEAN" value="false"/>
      <channel description="" group="can" name="light_intensity" path="" recordmode="3" type="DOUBLE" value="0.0"/>
      <channel description="" group="can" name="light_switch" path="" recordmode="3" type="UINT8" value="0"/>
    </channels>
    <const/>
    <parameters>
  <parameter description="" exchangeMode="EXCHANGE" group="" name="parameter_one" path="">
        <pValue:scalar parName="parameter_one" type="BOOL" val="TRUE"/>
      </parameter>
      <parameter description="" exchangeMode="EXCHANGE" group="" name="parameter_two" path="">
        <pValue:scalar parName="parameter_two" type="BOOL" val="FALSE"/>
      </parameter>
 </parameters>
    <assessments>
      <assess description="" name="headlightOff_ok" path="" recordmode="3" type="BOOLEAN" value="false"/>
      <assess description="" group="" name="headlightOn_ok" path="" recordmode="3" type="BOOLEAN" value="false"/>
      <assess description="" name="switchAuto_ok" path="" recordmode="3" type="BOOLEAN" value="false"/>
    </assessments>
    <measurments/>
    <assessmentheader/>
  </header>
  <body>
    <testlet id="0" isref="false" name="main" zoomscale="1.0">
      <signature>
        <input name="headlight"/>
        <output name="light_intensity"/>
        <output name="light_switch"/>
      </signature>
      <content:tpdiagram>
        <state id="0" posX="235" posY="111">
          <testlet id="1" isref="false" name="init light switch">
            <signature>
              <output name="light_switch"/>
            </signature>
            <content:dd/>
            <scenario:group assessment="" description="" id="2" name="all scenarios">
              <scenario:dd assessment="" description="" id="3" name="off">
                <eqn channel="light_switch" source="0"/>
              </scenario:dd>
              <scenario:dd assessment="" description="" id="4" name="on">
                <eqn channel="light_switch" source="1"/>
              </scenario:dd>
              <scenario:dd assessment="" description="" id="17" name="auto">
                <eqn channel="light_switch" source="2"/>
              </scenario:dd>
            </scenario:group>
          </testlet>
        </state>
        <state id="1" posX="253" posY="321">
          <testlet id="3" isref="false" name="constant light intensity">
            <signature>
              <output name="light_intensity"/>
            </signature>
            <content:dd/>
            <scenario:group assessment="" description="" id="6" name="all scenarios">
              <scenario:dd assessment="" description="" id="7" name="bright">
                <eqn channel="light_intensity" source="100.0"/>
              </scenario:dd>
              <scenario:dd assessment="" description="" id="9" name="dark">
                <eqn channel="light_intensity" source="0.0"/>
              </scenario:dd>
            </scenario:group>
          </testlet>
        </state>
        <state id="2" posX="259" posY="402">
          <testlet id="4" isref="false" name="changing light intensity">
            <signature>
              <output name="light_intensity"/>
            </signature>
            <content:dd/>
            <scenario:group assessment="" description="" id="13" name="all scenarios">
              <scenario:dd assessment="" description="" id="14" name="getting darker">
                <signal:embedded channel="light_intensity" chunkType="irregular" data_type="DOUBLE" endtime="60s" linear_interpolation="true" startTime="0" time="0, 20788732, 35s, 37s, 44760564, 49112676, 60s" value="0x1.9p6, 0x1.4bp6, 0x1.ep5, 0x1.9p5, 0x1.3p4, 0x1.9p2, 0x1.4p2"/>
              </scenario:dd>
              <scenario:dd assessment="" description="" id="19" name="getting lighter">
                <eqn channel="light_intensity" source="[signal from 0s to 50s]"/>
              </scenario:dd>
            </scenario:group>
          </testlet>
        </state>
        <state id="3" posX="455" posY="110">
          <testlet id="2" isref="true" name="set light switch" references="1">
            <signature>
              <output name="light_switch"/>
            </signature>
          </testlet>
        </state>
        <junction id="4" posX="75" posY="321"/>
        <junction id="5" posX="77" posY="111"/>
        <junction id="6" posX="80" posY="406"/>
        <final id="7" posX="457" posY="353"/>
        <final id="8" posX="629" posY="109"/>
        <transition from="4" id="9" name="" namePosX="161" namePosY="322" to="1">
          <transspec actions="" id="1" index="0" name="default"/>
        </transition>
        <transition from="5" id="10" name="" namePosX="158" namePosY="109" to="0">
          <transspec actions="" id="2" index="0" name="default"/>
        </transition>
        <transition from="6" id="11" name="" namePosX="169" namePosY="404" to="2">
          <transspec actions="" id="3" index="0" name="default"/>
        </transition>
        <transition from="0" id="12" name="wait" namePosX="341" namePosY="150" to="3">
          <transspec actions="" condition="t &gt;= 10" id="4" index="0" name="10s"/>
        </transition>
        <transition from="0" id="13" name="wait" namePosX="439" namePosY="32" to="8">
          <point posX="437" posY="10"/>
          <transspec actions="" condition="t &gt;= 60" id="5" index="0" name="60s"/>
        </transition>
        <transition from="1" id="14" name="" namePosX="342" namePosY="321" to="7">
          <transspec actions="" id="6" index="0" name="default"/>
        </transition>
        <transition from="2" id="15" name="" namePosX="358" namePosY="377" to="7">
          <transspec actions="" id="7" index="0" name="default"/>
        </transition>
        <transition from="3" id="16" name="wait" namePosX="556" namePosY="149" to="8">
          <transspec actions="" condition="t &gt;= 60" id="8" index="0" name="60s"/>
        </transition>
        <line yPos="226"/>
      </content:tpdiagram>
      <scenario:group assessment="" description="" id="0" name="all scenarios">
        <scenario:group assessment="#####ON-OFF-MODE#####&#10;&#10;# ===================&#10;# Whenever switch is turned to OFF the lights should be turned off immediately and stay off&#10;# immediately, i.e. after one cycle at the latest&#10;# ===================&#10;&#10;headlight_off = TPT.regexp([headlight(t) == false]);&#10;&#10;if (abs(headlight_off[0].getStartTime()) &lt;= 0.01 and abs(headlight_off[0].getLength() - 10) &lt;= 0.01):&#10;  headlightOff_ok := true;&#10;  headlightOff_ok.setComment(&quot;light switch OFF is okay&quot;);&#10;else:&#10;  headlightOff_ok := false;&#10;  headlightOff_ok.setComment(&quot;switch is OFF but headlights are on!&quot;);&#10;&#10;# ===================&#10;# Whenever switch is turned to ON the lights should be turned on immediately and stay on&#10;# immediately, i.e. after one cycle at the latest&#10;# ===================&#10;&#10;headlight_on = TPT.regexp([headlight(t) == true]);&#10;&#10;if (abs(headlight_on[0].getStartTime() - 10) &lt;= 0.01 and abs(headlight_on[0].getLength() - 60) &lt;= 0.01):&#10;  headlightOn_ok := true;&#10;  headlightOn_ok.setComment(&quot;light switch ON is okay&quot;);&#10;else:&#10;  headlightOn_ok := false;&#10;  headlightOn_ok.setComment(&quot;switch is ON but headlights are off!&quot;);" description="" id="11" name="On-Off-Mode">
          <scenario:tp assessment="" description="" id="1" name="headlight off -&gt; on (dark)" stateIds="0,1,3" subScenIds="3,9,4" transitionIds="9,10,12,14,16" transitionSpecs="1,2,4,6,8"/>
          <scenario:tp assessment="" description="" id="10" name="headlight off -&gt; on (bright)" stateIds="0,1,3" subScenIds="3,7,4" transitionIds="9,10,12,14,16" transitionSpecs="1,2,4,6,8"/>
        </scenario:group>
        <scenario:group assessment="" description="" id="12" name="Auto-Mode">
          <scenario:tp assessment="#####AUTO-MODE-DARK#####&#10;&#10;# ===================&#10;# When switch is in position AUTO the lights should be turned immediately off if brightness is 70% or below&#10;# immediately, i.e. after one cycle at the latest&#10;# ===================&#10;&#10;headlight_off = TPT.regexp([(t &gt;= 0.01) and (headlight(t) == false)]);&#10;&#10;# look for failure situations, i.e. where headlights are off&#10;if (headlight_off.getSize() == 0):&#10; # never off&#10;  switchAuto_ok := true;&#10;  switchAuto_ok.setComment(&quot;Headlights have been turned on correctly in AUTO mode&quot;);&#10;else:&#10; # off at least once&#10;  switchAuto_ok := false;&#10;  switchAuto_ok.setComment(&quot;It is dark in AUTO mode, but headlights are turned off!!&quot;);" description="" id="15" name="auto (dark)" stateIds="0,1" subScenIds="17,9" transitionIds="9,10,13,14" transitionSpecs="1,2,5,6"/>
          <scenario:tp assessment="&#10;#####AUTO-MODE-GETTING-DARKER#####&#10;&#10;# ===================&#10;# When switch is in position AUTO and if the brightness falls below 60% for at least 2 seconds, &#10;# the lights should go on immediately &#10;# immediately, i.e. after one cycle at the latest&#10;# ===================&#10;&#10;headlight_off = TPT.regexp([(t &gt;= 0.01) and (headlight(t) == false)]);&#10;headlight_on = TPT.regexp([(t &gt;= 0.01) and (headlight(t) == true)]);&#10;&#10;# look for failure situations, i.e. where headlights are off&#10;if(abs(headlight_off[0].getStartTime()) &lt;= 0.01 and abs(headlight_off[0].getLength() - (35 + 2)) &lt;= 0.01&#10; and abs(headlight_on[0].getLength() - (60-37)) &lt;= 0.01):&#10;  switchAuto_ok := true;&#10;  switchAuto_ok.setComment(&quot;Headlights have been turned on correctly in AUTO mode&quot;);&#10;else:&#10;  switchAuto_ok := false;&#10;  switchAuto_ok.setComment(&quot;It is dark in AUTO mode, but headlights are turned off!!&quot;);" description="" id="16" name="auto (getting darker)" stateIds="0,2" subScenIds="17,19" transitionIds="10,11,13,15" transitionSpecs="2,3,5,7"/>
        </scenario:group>
      </scenario:group>
    </testlet>
  </body>
</example>
 
The problem is that there are namespace (as you can see). But they are never declared and i can not parse the file correctly. So i thought with a small hack (insert in line two the namespace declaration with xmlns:pValue="http://dummies.org" xmlns:content=http://example.org" xmlns:scenario="http://thethirdone.com") but when i try to read the <pValue:scalar parName="parameter_one" type="BOOL" val="TRUE"/> node with its attributes, i get shit ;-) Is my declaration wrong? I can read attributes without namespace without problems, thats not the point, but just the namespaces are stupid.
 
With this line i can check that i am in the correct line of the file

cout <<

"in the correct line " << cur->line <<endl;     // but when i try to read the parName or the type, it is not possible

name =

xmlGetProp(cur,(const xmlChar *)"type");  // name = NULL ??

 

 






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]