Skip to content

Conversation

@EzraBrooks
Copy link

@EzraBrooks EzraBrooks commented Oct 27, 2025

Please merge #227 first so the diff on this PR is less wonky :) I'll make this not a draft and rebase it once that's merged.

Reverts a change from #200 that, while well-intentioned, appears to me to make it harder to validate the XSD with traditional tools. The change made the recommended way of using the XSD the <? xml-model ?> processing instruction, which is non-standard and not broadly supported.

By way of evidence, using the popular xmlschema library in Python:

PS C:\Users\ezram\urdfdom\xsd> gc -Head 5 .\autogenerated.urdf
<?xml version="1.0" encoding="utf-8"?>
<?xml-model href="https://raw.githubusercontent.com/aminya/urdfdom/xsd/xsd/urdf.xsd"?>
<robot name="name1" version="1.0" xmlns="http://www.ros.org">
 <joint name="name1" type="type1">
   <mimic joint="joint1" multiplier="1" offset="0" />

PS C:\Users\ezram\urdfdom\xsd> pipx run --spec xmlschema  xmlschema-validate .\autogenerated.urdf
cannot get a schema for XML data, provide a schema argument
PS C:\Users\ezram\urdfdom\xsd> gc -Head 5 .\autogenerated.urdf
<?xml version="1.0" encoding="utf-8"?>
<robot name="name1" version="1.0" xmlns="http://www.ros.org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.ros.org urdf.xsd">
  <joint name="name1" type="type1">
    <mimic joint="joint1" multiplier="1" offset="0" />

PS C:\Users\ezram\urdfdom\xsd> pipx run --spec xmlschema  xmlschema-validate .\autogenerated.urdf
.\autogenerated.urdf is not valid

I also checked the source code of lxml and found no reference to xml-model.

I understand that the upside of this change, if you're using a schema validator that accepts the xml-model processing instruction, is that you can validate the robot element itself - whereas with the original implementation the robot element is the element referencing the schema location, so it isn't going to be validated. However, I think remaining compatible with the greater ecosystem of tools is more important than the convenience factor here.

Signed-off-by: Ezra Brooks <[email protected]>
Unfortunately, as convenient as it is, the `xml-model` processing
instruction is *not* standard and we should not rely on it as it does
not work with the lion's share of XSD implementations.

Signed-off-by: Ezra Brooks <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant