-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reference local schema files #535
base: sdf9
Are you sure you want to change the base?
Changes from 1 commit
5dd4749
aef3ab8
3abba02
97e291a
463eb4a
84c642c
75b33b6
6f32833
9b61cb9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,6 +79,11 @@ def printElem(_file, _spaces, _elem) | |
_elem.get_elements("element").each do |elem| | ||
printElem(_file, _spaces+6, elem) | ||
end | ||
|
||
_elem.get_elements("include").each do |inc| | ||
printIncludeRef(_file, _spaces+6, inc); | ||
end | ||
|
||
_file.printf("%*s</xsd:choice>\n", _spaces+4, "") | ||
|
||
# Print the attributes for the complex type | ||
|
@@ -130,8 +135,7 @@ def printIncludeRef(_file, _spaces, _inc) | |
|
||
################################################# | ||
def printInclude(_file, _spaces, _attr) | ||
loc = "http://sdformat.org/schemas/" | ||
loc += _attr.attributes['filename'].sub("\.sdf","\.xsd") | ||
loc = _attr.attributes['filename'].sub("\.sdf","\.xsd") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I should have been more clear in the issue description in that we do still want to be able to have xsd files that can be stored on sdformat.org/schemas. At a glance, this looks like it will embed the absolute paths of the local machine in to the generated schemas. That's useful for tests, but I think we do still want this script to generate xsd that can be uploaded to the website. I wonder if instead of using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the tip! How's this? aef3ab8 |
||
_file.printf("%*s<xsd:include schemaLocation='%s'/>\n", _spaces, "", loc) | ||
end | ||
|
||
|
@@ -181,22 +185,44 @@ def printXSD(_file, _spaces, _elem) | |
printDocumentation(_file, _spaces, _elem.elements["description"].text) | ||
end | ||
|
||
_file.printf("%*s<xsd:include schemaLocation='http://sdformat.org/schemas/types.xsd'/>\n", _spaces, "") | ||
_file.printf("%*s<xsd:include schemaLocation='#{$path}/schema/types.xsd'/>\n", _spaces, "") | ||
|
||
includedSchemas = [] | ||
|
||
# Print the inclues for the complex type | ||
# Print the includes for the complex type | ||
# The includes must appear first | ||
_elem.get_elements("include").each do |inc| | ||
filename = inc.attributes['filename'] | ||
includedSchemas << filename | ||
|
||
printInclude(_file, _spaces, inc); | ||
end | ||
|
||
# Print the nested includes for the complex type | ||
# that have not already been included | ||
_elem.get_elements("element").each do |elem| | ||
elem.get_elements("include").each do |inc| | ||
filename = inc.attributes['filename'] | ||
|
||
if includedSchemas.grep(filename).size == 0 | ||
printInclude(_file, _spaces, inc) | ||
end | ||
end | ||
end | ||
|
||
if _elem.get_elements("element").size > 0 || | ||
_elem.get_elements("attribute").size > 0 || | ||
_elem.get_elements("include").size > 0 | ||
|
||
# Print the complex type with a name | ||
_file.printf("%*s<xsd:element name='%s'>\n", _spaces, "", | ||
_elem.attributes["name"]) | ||
_file.printf("%*s<xsd:complexType>\n", _spaces+2, "") | ||
|
||
if _elem.attributes['name'] == "pose" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed 75b33b6 |
||
_file.printf("%*s<xsd:complexType mixed='true'>\n", _spaces+2, "") | ||
else | ||
_file.printf("%*s<xsd:complexType>\n", _spaces+2, "") | ||
end | ||
|
||
if _elem.attributes['name'] != "plugin" && | ||
(_elem.get_elements("element").size > 0 || | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if we should be changing these names because they are actually used by Gazebo-classic. If I remember correctly, keeping the original names causes an issue with the generated xsd. I was hoping we can fix that issue without renaming these elements.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed them back in aef3ab8