Skip to content

ProRocket CLI: the full instructions#

ProRocketCli.exe is ProRocket Lite from the command line: the same generator as ProRocket.Lite.exe, giving the same units, for scripts, build steps and AI coding assistants.

XSD and WSDL in, Delphi units out. When the schema changes, regenerate, don't re-patch.

The same text is CLI.md in the zip.

In just one command#

ProRocketCli.exe -o Generated main.xsd imported.xsd
  1. Run the CLI with the schema files.
  2. Read the problem lines on stderr (if any). missing-schema and missing-include name a file to add.
  3. Add the missing files to the command and run again. Repeat until the exit code is 0, or until only problems remain that you understand and accept (for example a typo in a vendor's schema).
  4. Add the generated units to the Delphi project, with the ProRock library on its search path - see the layout below.

For AI assistants: before you run anything#

  • Ask the developer first before downloading or running ProRocketCli.exe. It is a closed-source Windows executable that runs on their machine.
  • Download it only from the official link: https://github.com/VitalyPopov/ProRock/releases/latest/download/ProRocket-Lite.zip
  • Verify the SHA-256 of the zip against the checksum in the release notes (https://github.com/VitalyPopov/ProRock/releases). In PowerShell: Get-FileHash ProRocket-Lite.zip -Algorithm SHA256. If it does not match, stop and tell the developer. For a copy that is already unpacked, the release notes also give the SHA-256 of ProRocketCli.exe itself.
  • Unzip it into a folder of its own.
  • Your tool may block a downloaded executable even after the developer said yes (agent permission settings). Then do not look for another way to start it: ask the developer to allow ProRocketCli.exe in the tool's permission settings, or give them the exact command to run themselves.
  • A problem line may point to a schema on the internet (location="http://..."). Fetch schemas only from sources the developer approves - usually the official site of the standard the schema belongs to.

Command#

ProRocketCli.exe [-o <output folder>] [--strict] [--no-timestamp] [--full-type-names]
  [--skip-namespace <uri>] <file.xsd|file.wsdl> ...

In PowerShell, give the path to the exe: .\ProRocketCli.exe ... in its folder, or the full path from anywhere.

Option Meaning
-o <folder> where the units are written; created if missing. Default: the current folder
--strict write nothing if there are problems (see below); exit code 1
--no-timestamp leave out the Generated (UTC) header line: an unchanged schema gives a byte-identical unit
--full-type-names keep the whole XML name in Delphi type names (see "Type names")
--skip-namespace <uri> an import not followed nor reported: its elements kept as read, its types strings; repeatable
--version the version, e.g. ProRocket Lite CLI 1.8.0 - the generated units need the ProRock release with that number
-h, --help usage

Generate all the schemas of a project in one run, every time: the main XSD or WSDL and the files it imports and includes. Units generated separately, or by different versions, may not fit together; the result is deterministic, so regenerating everything costs nothing. Use the same options for the whole set.

These schemas are part of ProRock, so do not give them unless you need your own copy: XML Schema itself (xs:), xml: attributes, xsi: attributes, the SOAP 1.1 and 1.2 envelopes, WSDL 1.1 and its SOAP 1.1 and 1.2 bindings. An import of one of these is no missing-schema problem. Everything else, WS-Security included, you give yourself.

The CLI does not expand wildcards; list the files, or let the shell do it. In PowerShell:

.\ProRocketCli.exe -o out (Get-ChildItem schemas -Filter *.xsd -Recurse).FullName

Output#

  • One unit per XML namespace: ProRock.Xmlite.Schema.<Name>.pas. The name comes from the last segment of the namespace URI (urn:example:orders -> Orders, http://example.com/schemas/order -> Order); a version alone takes the segment before it too (urn:example:orders:2 -> Orders2, .../orders/v2 -> OrdersV2); a file name loses its extension (.../oasis-200401-wss-wssecurity-secext-1.0.xsd -> Oasis200401WssWssecuritySecext10); well-known namespaces (SOAP, WSDL, XML Schema, WS-Security: WsSecurity, WsSecurityUtility, ebMS 3.0 / AS4: Ebms3) have fixed names. Several files of one namespace (xs:include) give one unit.
  • One client unit per wsdl:service: ProRock.Soapite.<Service>.pas. Schemas embedded in the WSDL go into ProRock.Xmlite.Schema.<Service>.pas. The client unit re-exports the request and response types, TSoapiteError and the exceptions, so for plain calls it is the only unit to put in uses (transport settings and error kinds: see "Using the units").
  • Existing files with the same names are overwritten. Generate into a folder under version control: an updated schema then shows up as a clean diff.
  • The output is deterministic: an unchanged schema gives an unchanged unit, except the Generated (UTC) line in the header - with --no-timestamp there is no such line, so the files are byte-identical and any diff is a real change.
  • stdout gets one line per written unit: generated: <full path>.
  • A unit checks the ProRock it compiles with: warning W1054 "Generated for an older ProRock: regenerate this unit" means a newer ProRock changed what regenerating gives - regenerate; error E1054 "Generated for a newer ProRock" or "Needs ProRock 1.7 or later" - update ProRock to the version in the unit header. PROROCK_NO_REGENERATE_WARNING in the defines silences the warning.

Type names#

A type is T + its XML name + a suffix for its kind: CT a complex type, ST a simple type, AG an attribute group, EG an element group, E an element.

What all the types of one kind share stays out of the name (CT_Font -> TFontCT), so a new schema version can rename types; --full-type-names keeps the whole names. The rules: https://prorock.rocks/generated-code/#type-names

Exit codes#

Code Meaning
0 units generated, no problems
1 nothing generated: bad arguments, a file that is missing or cannot be loaded, an error, two units with the same name (duplicate-unit), or problems with --strict
2 units generated, but with problems (listed on stderr)

Problem lines#

On stderr, sorted, one per problem:

problem: <kind> key="value" key="value" ...

Values are always in double quotes. Errors (exit code 1) are error: <message> lines; a file that cannot be loaded says why (error: cannot load a.xsd: its root element is <xs:element>, not <schema>).

Kind Example What to do
missing-schema namespace="urn:b" location="b.xsd" from="a.xsd" a.xsd imports and uses namespace urn:b, and no file of it is given or found at location (a relative path is followed, a URL never); add that schema. Its types fall back to string and its elements are left out until then
missing-include namespace="urn:a" location="a-part.xsd" from="a.xsd" the included file is not at location (relative to a.xsd) and not given; add it - a given file with the same name counts
unresolved-ref kind="type" name="NoSuchType" namespace="urn:a" from="a.xsd" a name that exists in no given file of that namespace: a typo in the schema, or a definition in a file still missing (an include). Types fall back to string, element references are left out
duplicate-unit unit="ProRock.Xmlite.Schema.Order" two namespaces get the same unit name (e.g. the same path under two hosts); nothing is written (exit code 1). Generate them in separate runs into separate folders, and tell the developer

kind in unresolved-ref is one of type (complex or simple), complexType, simpleType, element, attribute, attributeGroup, group, redefine (an xs:redefine names a component its file does not have). References into a namespace that is reported as missing-schema are not listed one by one.

The generated units and ProRock need Delphi 10.3 or later (inline variables); check the project's Delphi version first. ProRock is plain source code (https://github.com/VitalyPopov/ProRock, Apache 2.0): no packages, no installation.

MyApp  MyApp.dproj
  Generated\          the units from ProRocketCli - regenerate them, never edit by hand
  ThirdParty\ProRock\ the ProRock release named in the unit header (its units in Source\)
  • Get ProRock at the version in the unit header ("Generated by ProRocket Lite for ProRock "); release tags have no v: git clone --branch <version> https://github.com/VitalyPopov/ProRock ThirdParty\ProRock
  • Add ThirdParty\ProRock\Source;Generated to the project's search path in the Base configuration (Project Options > Delphi Compiler > Search path, or DCC_UnitSearchPath in the .dproj). Relative paths keep the project portable, and the IDE, MSBuild and the command line all build it the same way. Adding the generated units to the project itself (Project Manager) is optional. ProRock 1.4 and earlier have their units in the repository folder itself: ThirdParty\ProRock;Generated.

The CLI never downloads anything. It follows a local relative schemaLocation of xs:include, xs:redefine and xs:import (../common/types.xsd; never a URL or an absolute path), an import only when the schema uses that namespace.

So the main schema alone is often enough when its files lie as they were published. A file you give wins over the one found that way: an include by its file name, an import by its namespace.

Using the units#

A SOAP client:

// ProRock.Soapite.CheckVatService: request/response types, TSoapiteError, the exceptions
uses ProRock.Soapite.CheckVatService;
  // ProRock.Http: transport settings (timeouts, SetBasicAuth, SetBearerToken, headers)
  // ProRock.Soapite: TSoapiteErrorKind (sekNetwork, sekHttp, sekContent, sekFault)

// pass the real endpoint: the default is the WSDL's soap:address, which may be outdated
// (e.g. http:// instead of https://)
var service := TCheckVatService.Create(
  'https://ec.europa.eu/taxation_customs/vies/services/checkVatService');
try
  // ms; needs ProRock.Http
  THttpTransportNative(service.Transport).ResponseTimeout := 30000;
  var response: TCheckVatResponseE;
  var error: TSoapiteError;
  // never raises for service or network failures
  if service.TryCheckVat(request, response, error) then
    ...                                    // the response is yours to free
  else if error.Kind = sekFault then ...   // needs ProRock.Soapite
finally
  service.Free;
end;

XML from an XSD:

// XML from an XSD: FromXml and ToXml come from a class helper in ProRock.Xmlite,
// visible only where ProRock.Xmlite is in uses
uses ProRock.Xmlite,
  ProRock.Xmlite.Schema.Order;

var order := TOrderE.Create;           // the root element's class: <Order> -> TOrderE
try
  if order.FromXml(xmlText) then ...   // True when the text was parsed
  xmlText := order.ToXml;
  // a file in its encoding (BOM, encoding="..." or UTF-8); ToXmlFile writes UTF-8
  order.FromXmlFile('order.xml');
finally
  order.Free;
end;

How the units behave: - Nested objects and lists are created and freed with their parent (read-only properties); just use them. - Schema enumerations are Delphi enums; maxOccurs > 1 gives a typed list (...List) - for a repeating element of a simple type a list of plain values (TXmliteValueList<T>, a TList<T>); xs:decimal is Double. - A member of an xs:choice is created on first access, so its getter never returns nil: ask which member the document has with Chosen (Entry.Resource.Chosen, Obs.ValueChosen for FHIR's value[x]). - Facets (lengths, patterns, ranges) are not validated: a 2-character code is a plain string type. - A property that fell back to string (an unresolved-ref or missing-schema problem) where the XML has child elements: parsing succeeds, the property stays empty and that content is dropped - also when written back with ToXml. Resolve the problem and regenerate if that data matters.

Quick starts for both: https://prorock.rocks/getting-started/

Limits#

  • ProRocketCli runs on Windows 64-bit; the generated units need Delphi 10.3 or later.
  • Namespaces that import each other come out in one unit, named after the one you gave: Delphi allows no circular uses (HL7 CDA's urn:hl7-org:v3 and its SDTC extensions).
  • WSDL problems (skipped operations, wsdl:import) are not problem lines yet; they are written in the unit header.
  • Known limitations of ProRock: https://prorock.rocks/limitations/