Skip to content

Write the library version as BTCPP_version in the <root> of generated XML - #1264

Merged
facontidavide merged 1 commit into
masterfrom
feat/btcpp-version-attribute
Oct 26, 2026
Merged

facontidavide merged 1 commit into
masterfrom
feat/btcpp-version-attribute

Conversation

@facontidavide

Copy link
Copy Markdown
Collaborator

Summary

writeTreeNodesModelXML() and WriteTreeToXML() now write the library version in <root>:

<root BTCPP_format="4" BTCPP_version="4.11">

The value is major.minor, taken from LibraryVersionString(). On master it reads 4.10 until the version is bumped.

Why

Groot2 needs to know which BT.CPP version a file or a monitored tree targets:

Groot2 will let users pick the target version in its Preferences and will write the same attribute. With this PR, XML generated by the library carries it too, including the tree that Groot2Publisher sends.

Compatibility

  • No API/ABI change.
  • The parser ignores the attribute. Every 4.x release only reads BTCPP_format and main_tree_to_execute from <root>, so files written by 4.11 still load in older versions.
  • The XSD declares BTCPP_version as an optional attribute, so files without it still validate.

Tests

BehaviorTreeFactory.WrittenXMLHasLibraryVersion checks that both writers emit the attribute and that the output loads and runs again. It fails without the change. The full suite passes: 596 passed, 2 skipped.

🤖 Generated with Claude Code

…erated XML

writeTreeNodesModelXML() and WriteTreeToXML() now add BTCPP_version="<major>.<minor>"
to <root>, next to BTCPP_format. It tells tools like Groot2 which builtin node
models and attributes (e.g. the _onlyIf/_onStart preconditions of 4.11) are
available. The XSD declares it as an optional attribute.

The parser ignores it, as all BT.CPP 4.x releases already ignore unknown <root>
attributes, so files written by 4.11 still load in older versions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@facontidavide
facontidavide merged commit a9d6e56 into master Oct 26, 2026
16 checks passed
@facontidavide
facontidavide deleted the feat/btcpp-version-attribute branch October 26, 2026 06:34
@sonarqubecloud

Copy link
Copy Markdown

facontidavide added a commit to vivoeiva/BehaviorTree.CPP that referenced this pull request Nov 8, 2026
Master gained the _onlyIf/_onStart preconditions (BehaviorTree#1261) and the
BTCPP_version root attribute (BehaviorTree#1264); the checked-in XSD was stale and
the new 'generated schemas are up to date' CI step would fail.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ME1hnSFSzibU5phxboGsjk
facontidavide added a commit that referenced this pull request Nov 8, 2026
* Add 'generic' parameter to writeTreeXSD()

When generic=true, oneNodeGroup uses xs:any processContents="lax" instead
of a closed xs:choice, allowing unknown custom node elements to pass
validation. Top-level xs:element declarations are also emitted so that lax
processing can still resolve and validate the known built-in node types by name.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Add generate_xsd tool

Generates the generic XSD schema from the default factory (built-in nodes
only) and prints it to stdout, suitable for use as a generic static validator
that stays in sync with the built-in node inventory.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Fix non-deterministic port attribute order in writeTreeXSD()

PortsList is an unordered_map so iterating it directly produced XSD
attributes in hash-table order, which varies across runs and platforms.
Sort ports into a std::map before emitting xs:attribute elements.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Add writeTreeSchematron() for cross-reference validation of BT XML files

XSD alone cannot express constraints like "every custom node element used
in a BehaviorTree body must have a matching TreeNodesModel entry"

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Add generate_schematron tool

Generates an ISO Schematron schema (btcpp4.sch) complementing the generic XSD

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Add generated XSD and Schematron schemas

* Add validate_xml.py - XSD and Schematron validation tool

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Only built-ins should go into generic xsd file

* Add tests for writeTreeXSD() and writeTreeSchematron()

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Fix implicit conversion

* Also handle inout_port in XSD

* Fix reconfiguration after editing src/btcpp4_schematron.sch

* Fix writeTreeXSD() signature not to break ABI

* Change placeholder replacement logic for Schematron

* Add more test cases for InsideXmlComment()

* Add xsd and schematron checks to CI (intentionally broken)

* Fix clang-format issues

* Regenerate schemas to pass CI

* Add guard for --no-xsd --no-sch together

to validate_xml.py

* Remove rule checking explicit notation against TreeNodeModel

* Regenerate Schematron file

* Add Schematron Rule B: explicit-notation node structure constraints

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Regenerate Schematron file

* Drop insideXmlComment(): keep the placeholder out of the template comment

insideXmlComment() was added to the public xml_parsing.h only so that
writeTreeSchematron() could skip the ##BUILTIN_PIPE## placeholder where
the template comment mentions it. Rewording the comment so it no longer
contains the placeholder makes a plain replace-all enough, removes the
helper from the public API, and also fixes the generated bt4.sch, whose
comment still described an unexpanded placeholder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Regenerate tools/generated/bt4.xsd for _onlyIf, _onStart, BTCPP_version

Master gained the _onlyIf/_onStart preconditions (#1261) and the
BTCPP_version root attribute (#1264); the checked-in XSD was stale and
the new 'generated schemas are up to date' CI step would fail.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ME1hnSFSzibU5phxboGsjk

* Regenerate bt4.xsd and bt4.sch for the Finally node (#1229)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ME1hnSFSzibU5phxboGsjk

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Davide Faconti <davide.faconti@gmail.com>
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