Namespace Strategy - cprima-forks/uipath-ai-skills GitHub Wiki
Namespace Strategy
The XAML namespace block is not static — it is constructed at workflow assembly time based on the activities present in the spec.
Feature Detection Pass
Before any XAML is emitted, generate_workflow walks the entire activity tree and sets boolean flags:
all_gen_names = {a.get("gen") for a in _walk_all_activities(activities)}
has_ui = all_gen_names ∩ ui_gens # nclick, ntypeinto, napplicationcard_*, ...
has_datatable = DataTable/DataRow in args/vars
OR {foreach_row, nextractdata} in spec
has_securestring= SecureString in any arg/variable type
has_http = "net_http_request" in spec
Plugin generators also contribute: if a plugin gen name appears in the spec, its registered namespace is included.
The sd: Prefix Collision
sd: is the conflict point. Studio uses it for two different namespaces depending on context:
- UI-only workflows:
sd=System.Drawing(needed by NApplicationCard's OCR engine blocks) - Non-UI workflows:
sd=System.Data(needed by DataTable variables and activities)
When a workflow has both UI activities and DataTable, both namespaces are needed simultaneously — but they cannot share the same prefix. This is the "Option B" strategy in _build_namespaces:
| Workflow content | sd: assignment |
Extra prefixes |
|---|---|---|
| UI only | System.Drawing |
sd1: = Drawing.Primitives |
| Non-UI | System.Data |
— |
| UI + DataTable | System.Data |
sdd: = Drawing, sdd1: = Drawing.Primitives |
Post-Processing Remapping
Generators always emit Drawing types with sd: (e.g., sd:Image, sd1:Rectangle) and DataTable types with sd2: (e.g., sd2:DataTable), regardless of which namespace strategy applies. After the full XAML body is assembled, a post-processing pass remaps the prefixes:
if has_ui and has_datatable:
body = (body
.replace("sd2:DataTable", "sd:DataTable")
.replace("sd:Image", "sdd:Image")
.replace("sd1:Rectangle", "sdd1:Rectangle")
)
This string replacement on generated output is a known fragility — see Friction: Structural Knowledge in F-Strings.
Conditional Namespace Prefixes
| Prefix | Condition | URI / CLR namespace |
|---|---|---|
ss: |
has_securestring |
System.Security |
uix: |
has_ui |
http://schemas.uipath.com/workflow/activities/uix |
uwah: |
has_http |
UiPath.Web.Activities.Http |
uwahm: |
has_http |
UiPath.Web.Activities.Http.Models |
| plugin prefixes | plugin gen in spec | registered by register_namespace() |
Always-Present Prefixes
These appear in every generated workflow regardless of content:
x:, s:, sap:, sap2010:, scg:, sco:, ui:, mc:, default namespace