Skip to content

Commit

Permalink
printElem, updated types.xsd & CMakeLists
Browse files Browse the repository at this point in the history
Signed-off-by: Jenn Nguyen <[email protected]>
  • Loading branch information
jennuine committed Jun 18, 2021
1 parent 84c642c commit 75b33b6
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 64 deletions.
42 changes: 22 additions & 20 deletions sdf/1.5/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
set (sdfs
actor.sdf
altimeter.sdf
audio_source.sdf
audio_sink.sdf
audio_source.sdf
battery.sdf
box_shape.sdf
camera.sdf
collision_engine.sdf
collision.sdf
contact.sdf
cylinder_shape.sdf
frame.sdf
forcetorque.sdf
frame.sdf
geometry.sdf
gps.sdf
gripper.sdf
Expand All @@ -20,16 +21,16 @@ set (sdfs
imu.sdf
inertial.sdf
joint.sdf
light.sdf
light_state.sdf
link.sdf
light.sdf
link_state.sdf
link.sdf
logical_camera.sdf
magnetometer.sdf
material.sdf
mesh_shape.sdf
model.sdf
model_state.sdf
model.sdf
noise.sdf
physics.sdf
plane_shape.sdf
Expand All @@ -39,38 +40,39 @@ set (sdfs
pose.sdf
projector.sdf
ray.sdf
rfidtag.sdf
rfid.sdf
rfidtag.sdf
road.sdf
root.sdf
scene.sdf
sensor.sdf
spherical_coordinates.sdf
sphere_shape.sdf
sonar.sdf
sphere_shape.sdf
spherical_coordinates.sdf
state.sdf
surface.sdf
transceiver.sdf
urdf.sdf
visual.sdf
world.sdf
)

set (SDF_SCHEMA)

foreach(FIL ${sdfs})
get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
get_filename_component(FIL_WE ${FIL} NAME_WE)
set(root root.sdf)

get_filename_component(ABS_FIL ${root} ABSOLUTE)
get_filename_component(FIL_WE ${root} NAME_WE)

list(APPEND SDF_SCHEMA "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.xsd")
list(APPEND SDF_SCHEMA "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.xsd")

add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.xsd"
COMMAND ${RUBY} ${CMAKE_SOURCE_DIR}/tools/xmlschema.rb
ARGS -s ${CMAKE_CURRENT_SOURCE_DIR} -i ${ABS_FIL} -o ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${ABS_FIL}
COMMENT "Running xml schema compiler on ${FIL}"
VERBATIM)
endforeach()
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.xsd"
COMMAND ${RUBY} ${CMAKE_SOURCE_DIR}/tools/xmlschema.rb
ARGS -s ${CMAKE_CURRENT_SOURCE_DIR} -i ${ABS_FIL} -o ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${ABS_FIL}
COMMENT "Running xml schema compiler on ${root}"
VERBATIM)

add_custom_target(schema1_5 ALL DEPENDS ${SDF_SCHEMA})

Expand Down
4 changes: 2 additions & 2 deletions sdf/1.5/schema/types.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
<xsd:simpleType name="vector3">
<xsd:restriction base="xsd:string">
<xsd:pattern value="(\s*(-|\+)?(\d+(\.\d*)?|\.\d+|\d+\.\d+[eE][-\+]?[0-9]+)\s+){2}((-|\+)?(\d+(\.\d*)?|\.\d+|\d+\.\d+[eE][-\+]?[0-9]+))\s*"/>
<xsd:pattern value="(\s*(-|\+)?(\d+(\.\d*)?|\.\d+|\d+\.\d+)([eE][-\+]?[0-9]+)?\s+){2}(-|\+)?(\d+(\.\d*)?|\.\d+|\d+\.\d+)([eE][-\+]?[0-9]+)?\s*"/>
</xsd:restriction>
</xsd:simpleType>

Expand All @@ -26,7 +26,7 @@

<xsd:simpleType name="pose">
<xsd:restriction base="xsd:string">
<xsd:pattern value="(\s*(-|\+)?(\d+(\.\d*)?|\.\d+|\d+\.\d+[eE][-\+]?[0-9]+)\s+){5}((-|\+)?(\d+(\.\d*)?|\.\d+|\d+\.\d+[eE][-\+]?[0-9]+))\s*"/>
<xsd:pattern value="(\s*(-|\+)?(\d+(\.\d*)?|\.\d+|\d+\.\d+)([eE][-\+]?[0-9]+)?\s+){5}(-|\+)?(\d+(\.\d*)?|\.\d+|\d+\.\d+)([eE][-\+]?[0-9]+)?\s*"/>
</xsd:restriction>
</xsd:simpleType>

Expand Down
44 changes: 24 additions & 20 deletions sdf/1.6/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
set (sdfs
actor.sdf
air_pressure.sdf
altimeter.sdf
atmosphere.sdf
audio_source.sdf
audio_sink.sdf
audio_source.sdf
battery.sdf
box_shape.sdf
camera.sdf
collision_engine.sdf
collision.sdf
contact.sdf
cylinder_shape.sdf
frame.sdf
forcetorque.sdf
frame.sdf
geometry.sdf
gps.sdf
gripper.sdf
Expand All @@ -21,16 +23,17 @@ set (sdfs
imu.sdf
inertial.sdf
joint.sdf
light.sdf
lidar.sdf
light_state.sdf
link.sdf
light.sdf
link_state.sdf
link.sdf
logical_camera.sdf
magnetometer.sdf
material.sdf
mesh_shape.sdf
model.sdf
model_state.sdf
model.sdf
noise.sdf
physics.sdf
plane_shape.sdf
Expand All @@ -40,38 +43,39 @@ set (sdfs
pose.sdf
projector.sdf
ray.sdf
rfidtag.sdf
rfid.sdf
rfidtag.sdf
road.sdf
root.sdf
scene.sdf
sensor.sdf
spherical_coordinates.sdf
sphere_shape.sdf
sonar.sdf
sphere_shape.sdf
spherical_coordinates.sdf
state.sdf
surface.sdf
transceiver.sdf
urdf.sdf
visual.sdf
world.sdf
)

set (SDF_SCHEMA)

foreach(FIL ${sdfs})
get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
get_filename_component(FIL_WE ${FIL} NAME_WE)
set(root root.sdf)

get_filename_component(ABS_FIL ${root} ABSOLUTE)
get_filename_component(FIL_WE ${root} NAME_WE)

list(APPEND SDF_SCHEMA "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.xsd")
list(APPEND SDF_SCHEMA "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.xsd")

add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.xsd"
COMMAND ${RUBY} ${CMAKE_SOURCE_DIR}/tools/xmlschema.rb
ARGS -s ${CMAKE_CURRENT_SOURCE_DIR} -i ${ABS_FIL} -o ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${ABS_FIL}
COMMENT "Running xml schema compiler on ${FIL}"
VERBATIM)
endforeach()
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.xsd"
COMMAND ${RUBY} ${CMAKE_SOURCE_DIR}/tools/xmlschema.rb
ARGS -s ${CMAKE_CURRENT_SOURCE_DIR} -i ${ABS_FIL} -o ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${ABS_FIL}
COMMENT "Running xml schema compiler on ${root}"
VERBATIM)

add_custom_target(schema1_6 ALL DEPENDS ${SDF_SCHEMA})

Expand Down
4 changes: 2 additions & 2 deletions sdf/1.6/schema/types.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
<xsd:simpleType name="vector3">
<xsd:restriction base="xsd:string">
<xsd:pattern value="(\s*(-|\+)?(\d+(\.\d*)?|\.\d+|\d+\.\d+[eE][-\+]?[0-9]+)\s+){2}((-|\+)?(\d+(\.\d*)?|\.\d+|\d+\.\d+[eE][-\+]?[0-9]+))\s*"/>
<xsd:pattern value="(\s*(-|\+)?(\d+(\.\d*)?|\.\d+|\d+\.\d+)([eE][-\+]?[0-9]+)?\s+){2}(-|\+)?(\d+(\.\d*)?|\.\d+|\d+\.\d+)([eE][-\+]?[0-9]+)?\s*"/>
</xsd:restriction>
</xsd:simpleType>

Expand All @@ -26,7 +26,7 @@

<xsd:simpleType name="pose">
<xsd:restriction base="xsd:string">
<xsd:pattern value="(\s*(-|\+)?(\d+(\.\d*)?|\.\d+|\d+\.\d+[eE][-\+]?[0-9]+)\s+){5}((-|\+)?(\d+(\.\d*)?|\.\d+|\d+\.\d+[eE][-\+]?[0-9]+))\s*"/>
<xsd:pattern value="(\s*(-|\+)?(\d+(\.\d*)?|\.\d+|\d+\.\d+)([eE][-\+]?[0-9]+)?\s+){5}(-|\+)?(\d+(\.\d*)?|\.\d+|\d+\.\d+)([eE][-\+]?[0-9]+)?\s*"/>
</xsd:restriction>
</xsd:simpleType>

Expand Down
16 changes: 8 additions & 8 deletions sdf/1.7/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ set (sdfs
air_pressure.sdf
altimeter.sdf
atmosphere.sdf
audio_source.sdf
audio_sink.sdf
audio_source.sdf
battery.sdf
box_shape.sdf
camera.sdf
collision_engine.sdf
collision.sdf
contact.sdf
cylinder_shape.sdf
frame.sdf
forcetorque.sdf
frame.sdf
geometry.sdf
gps.sdf
gripper.sdf
Expand All @@ -24,16 +24,16 @@ set (sdfs
inertial.sdf
joint.sdf
lidar.sdf
light.sdf
light_state.sdf
link.sdf
light.sdf
link_state.sdf
link.sdf
logical_camera.sdf
magnetometer.sdf
material.sdf
mesh_shape.sdf
model.sdf
model_state.sdf
model.sdf
noise.sdf
physics.sdf
plane_shape.sdf
Expand All @@ -43,15 +43,15 @@ set (sdfs
pose.sdf
projector.sdf
ray.sdf
rfidtag.sdf
rfid.sdf
rfidtag.sdf
road.sdf
root.sdf
scene.sdf
sensor.sdf
spherical_coordinates.sdf
sphere_shape.sdf
sonar.sdf
sphere_shape.sdf
spherical_coordinates.sdf
state.sdf
surface.sdf
transceiver.sdf
Expand Down
2 changes: 1 addition & 1 deletion sdf/1.7/schema/types.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

<xsd:simpleType name="pose">
<xsd:restriction base="xsd:string">
<xsd:pattern value="(\s*(-|\+)?(\d+(\.\d*)?|\.\d+|\d+\.\d+)([eE][-\+]?[0-9]+)?\s+){5}(-|\+)?(\d+(\.\d*)?|\.\d+|\d+\.\d+)([eE][-\+]?[0-9]+)?\s*"/>
<xsd:pattern value="((\s*(-|\+)?(\d+(\.\d*)?|\.\d+|\d+\.\d+)([eE][-\+]?[0-9]+)?\s+){5}(-|\+)?(\d+(\.\d*)?|\.\d+|\d+\.\d+)([eE][-\+]?[0-9]+)?\s*)?"/>
</xsd:restriction>
</xsd:simpleType>

Expand Down
14 changes: 3 additions & 11 deletions tools/xmlschema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,7 @@ def printElem(_file, _spaces, _elem)
printDocumentation(_file, _spaces+2, _elem.elements["description"].text)
end

if _elem.attributes['name'] == "pose"
_file.printf("%*s<xsd:complexType mixed='true'>\n", _spaces+2, "")
else
_file.printf("%*s<xsd:complexType>\n", _spaces+2, "")
end
_file.printf("%*s<xsd:complexType>\n", _spaces+2, "")

_file.printf("%*s<xsd:choice maxOccurs='unbounded'>\n", _spaces+4, "")

Expand Down Expand Up @@ -162,7 +158,7 @@ def printInclude(_file, _spaces, _attr)
doc = REXML::Document.new File.new(loc)

doc.elements.each_with_index("element") do |elem, i|
printXSD(_file, _spaces+2, elem)
printElem(_file, _spaces+2, elem)
end
end

Expand Down Expand Up @@ -220,11 +216,7 @@ def printXSD(_file, _spaces, _elem)
printDocumentation(_file, _spaces+2, _elem.elements["description"].text)
end

if _elem.attributes['name'] == "pose"
_file.printf("%*s<xsd:complexType mixed='true'>\n", _spaces+2, "")
else
_file.printf("%*s<xsd:complexType>\n", _spaces+2, "")
end
_file.printf("%*s<xsd:complexType>\n", _spaces+2, "")

if _elem.attributes['name'] != "plugin" &&
(_elem.get_elements("element").size > 0 ||
Expand Down

0 comments on commit 75b33b6

Please sign in to comment.