Hi I am using sumo to generate traffic flow and trying to find a way to tune the parameters conveniently. So I want to use a variable to replace the parameter in the body of the net file. From the web, I found that entity may be helpful, but it seemed that I have made some mistake. The code, var_test.net.xml, is as following.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE net[
<!ENTITY pos "100.00">
]>
<net version="0.27" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/net_file.xsd">
<location netOffset="0.00,0.00" convBoundary="0.00,0.00,&pos;,0.00" origBoundary="10000000000.00,10000000000.00,-10000000000.00,-10000000000.00" projParameter="!"/>
<edge id="gneE0" from="gneJ0" to="gneJ1" priority="1">
<lane id="gneE0_0" index="0" speed="13.89" length="&pos;" shape="0.00,-1.65 &pos;,-1.65"/>
</edge>
<junction id="gneJ0" type="dead_end" x="0.00" y="0.00" incLanes="" intLanes="" shape="0.00,-0.05 0.00,-3.25"/>
<junction id="gneJ1" type="dead_end" x="&pos;" y="0.00" incLanes="gneE0_0" intLanes="" shape="&pos;,-3.25 100.00,-0.05"/>
</net>
In the code, I am trying to generate a road which has a length of 100 m, which I want to set as a entity. However, when using netedit
netedit -s var_test.net.xml
to open the file, it says:
Error: entity 'pos' not found
In file 'var_test.net.xml'
At line/column 8/66.
Error: entity 'pos' not found
In file 'var_test.net.xml'
At line/column 8/66.
Error: No nodes loaded.
Error: Failed to build network.
I am new to XML and don't know the reason of this. Could anyone please tell me how to correct my code, how to use a variable in sumo's net file or what I should learn at first? Thank you very much!!!
First the warning: "Here be dragons". Manual editing of SUMO networks is strongly discouraged. The preferred way is to use the plain XML format (either manually prepared/scripted, or generated by netedit's or netconvert's plain export), edit the resulting files and pass them through netconvert, like this:
netconvert -s input.net.xml --plain plain
<editor> plain.nod.xml plain.edg.xml
netconvert --node-files=plain.nod.xml --edge-files=plain.edg.xml --output-file=output.net.xml
But if you really insist to hack a net yourself, your XML is correct, the problem is, that SUMO uses by default an optimized parser for the networks which does not expand entities. If you enable XML validation, you get a slower parser which works as expected:
netedit -s var_test.net.xml --xml-validation.net always