Repository navigation
Releases
v2.3.1
Fixed
| Change | Problem → solution | Commit |
|---|---|---|
A stylesheet compiled from its xsl:stylesheet element never streamed: the planner took the document node as the principal module |
The planner scopes the principal module to the element itself; an element inside a ds:Transform streams too. |
94cff9e |
v2.3.0
Streaming and hardening. XSLT 3.0 streaming runs on the cursor for templates,
grouping, xsl:try, xsl:merge, xsl:fork, accumulators and
xsl:source-document (2,661 W3C cases on the streamed path), and
TransformReader with Output keeps a transform's memory flat: 15–20 MB of
RSS at 564 MB, against 1.6–2.4 GB on the tree. Every fixed resource limit is
an option now, xmlconf passes 1,965 of 1,965, and the confirmed findings of
the security audits run since v2.2.0 are fixed (what they left open is in
docs/known-gaps.md). New API is additive; refusals that changed are listed
under Changed — behaviour.
Added
| Change | What it does | Commit |
|---|---|---|
Streamed record paths with //, wildcards and outermost() |
//rec, doc//rec, /*/*/rec, *:rec, p:* stream; nested matches ride inside their outermost record. Small records share one tree: 900-deep count(//rec) 2.0 s CPU. |
[df9677e][df9677e], [fd31bb3][fd31bb3], [382983c][382983c], [22af5f4][22af5f4] |
Streamed core for xsl:source-document |
One streamed path for every trusted container: wrappers, choose, loops, split selects; an error is the tree's: final where the stream raises it as the tree does, otherwise re-run on the tree. W3C streamed cases 450 → 2,661. | [ff0c463][ff0c463], [44db07f][44db07f], [096a587][096a587], [d1a98a8][d1a98a8] |
Stylesheet.TransformReader, TransformOptions.SourceParseOptions |
Applies a stylesheet to a reader, streaming it when the initial mode is streamable and verified (a 1 GB filter in 620 MB heap, not 7.3 GB); otherwise exactly Parse + Transform. | [bdf45d8][bdf45d8] |
Streamed xsl:apply-templates |
Template rules, built-in rules, next-match, apply-imports and tunnels run on the cursor in a streamable container: a 1 GB filter in 624 MB, not 7.4 GB. |
[c8c0a01][c8c0a01] |
Streamed xsl:for-each-group |
group-adjacent, -starting-with and -ending-with over a child path stream in a streamable container or rule, each group as it closes, current-group() read once off the cursor: a 1 GB log grouped in 158 MB heap, not 6.0 GB. |
[fe1eb18][fe1eb18] |
Streamed xsl:try |
A try in a streamable container or rule streams its body; a caught error skips the rest of the context on the cursor and the catch runs on the start tag's view. The catch sees the tree's first error. | [2447ca0][2447ca0] |
| Stylesheet functions in streamed selects | A call whose body is its value exactly (one xsl:sequence, no failing conversion) is split as its body; path ! f(.) of atomic values reads as path/f(.): an absorbing function over 1 GB of records in 3 MB heap, not 11 GB. |
[6abbb27][6abbb27] |
| Streamable attribute sets | xsl:use-attribute-sets on streamed literal result elements, xsl:element and xsl:copy. |
[26caed6][26caed6] |
| Streamed accumulators | xsl:accumulator values are computed as a streamed document is read, in a streamable xsl:source-document and through TransformReader: a running total over 1 GB in 3 MB heap, not 15 GB. |
[42902f3][42902f3] |
Streamed xsl:fork and xsl:map |
Several prongs or entries reading one streamed document each run on a parse of their own over one read of its bytes, in turn; outputs in prong order, the first error the tree's. | [2a1d6ad][2a1d6ad] |
Streamed xsl:merge |
Each for-each-source document of a streamable merge source is read on its own cursor and merged by key as the tree merges: two 512 MB logs in 3.9 MB of heap. |
[2089255][2089255] |
TransformOptions.Output |
Serializes the principal result to a writer as it is built: a 1 GB identity in 4.5 MB heap, not 9.4 GB. Written nodes no longer count toward MaxNodes; buffered results keep the cumulative count. |
[34e6b36][34e6b36] |
TransformOptions.SecondaryOutput |
Each xsl:result-document is serialized to the writer the function returns for its URI, as it is made, and closed at its end; a 1 GB split into 7,018 files in 5.6 MB heap. |
[e94d4e0][e94d4e0] |
TransformOptions.SourceValidation (SourceStrict, SourceLax) |
Validates the principal input against the stylesheet's schema; TransformReader validates it while streaming, with the tree's typing, defaults and error. |
[081c9d3][081c9d3] |
TransformOptions MaxNodes, MaxBytes, MaxNodesBuilt, MaxBytesBuilt |
Held and total-work bounds for result and temporary trees and strings. Zero keeps the defaults; negative removes the bound. | [294b965][294b965] |
xslt.CompileContext |
Compile with a context: a call waiting for the compile slot returns ctx.Err(); the static phase and nested fn:transform compiles run under it. |
[cfa135c][cfa135c], [4694fa3][4694fa3], [0ecee9c][0ecee9c] |
CompileOptions.MaxSchemaBytes, xslt.DefaultMaxSchemaBytes |
Total schema source xsl:import-schema may read per compile, closures included; zero means 16 MB. |
[4ad352d][4ad352d] |
xdm.FlattenContext, XIncludeOptions.Context |
A cancellable Flatten that returns its step refusal as an error, and a cancellable XInclude pass. |
[9399efd][9399efd] |
c14n.FromXPathFilterContext, FromXPathContext |
XML-DSig XPath transforms under a context; a filter's per-node evaluations share one item and byte budget. | [2a41550][2a41550] |
c14n.FromXPathFilterHere, FromXPathHere |
XML-DSig filters can call here(): the node bearing the expression, a text node read as its parent; a node outside the document is refused. |
[e0d2c13][e0d2c13] |
xdm.ParseOptions.Warn |
Receives xml:id errors (duplicate ID, non-NCName value) as XQDY0091 *xdm.Errors, at most 100 then one summary; nil stays silent. |
[0caab03][0caab03], [c6508c3][c6508c3] |
xslt.StreamingDocumentResolver, FileResolver.OpenDocument |
A resolver with OpenDocument streams streamable xsl:source-document and merge sources; one without it still builds the tree. |
[0d9c103][0d9c103] |
tests/streambench |
Measures one transform on the tree against the same transform streamed through TransformReader, per process: 15–20 MB of RSS at 11, 112 and 564 MB streamed, against 46 MB to 2.4 GB on the tree, at 0.9–1.5× the time (docs/benchmark.md, "Streaming against the tree"). |
[1db051a][1db051a] |
Changed — behaviour
| Change | What it means | Commit |
|---|---|---|
| XML-DSig XPath filters used XPath 2.0 numbers: number('1e3') was 1000, string(1 div 0) was 'INF', 1 < 2 < 3 was refused | New xpath.CompileOptions.XPath10 applies the XPath 1.0 number model and comparison grammar; c14n's FromXPath*/FromXPathFilter* use it, so some filters select different nodes and an exponent literal is refused. |
[1df119d][1df119d] |
An XSD validation refused at MaxDepth, or an assertion declined, has no validity code |
Its ValidationError.Code is "" (was cvc-elt.1 / cvc-assertion.3) and Err wraps xdm.ErrResourceLimit; the document is still refused. |
[de6e686][de6e686] |
A 1.1 restriction rejected after a subsumption budget decline wraps xdm.ErrResourceLimit |
Still refused, now as undecided with no constraint code; raising the xsd.Options budgets may admit it. |
[5203922][5203922] |
dtd.Validate reports undeclared attributes |
A document that validated before may now fail; Options.AllowUndeclared skips them, as it skips undeclared elements. |
[915eb63][915eb63] |
XQuery validate lax with no imported schema returns a copy of its operand |
The result is a new node, not the input node, as §3.21 requires; the input keeps no annotation. | [f46ec7b][f46ec7b] |
| A tree past the text store's block ceiling is an error, not a panic | Entry points that return an error return xdm.ErrResourceLimit; xdm/xdmbuild methods with no error return still panic, with an error value that matches it. |
[91f30c9][91f30c9] |
ParseOptions.MaxNodes counts text that is not all white space, comments and PIs |
A document near the bound may now be refused; whitespace-only text is still not counted. | [9e9a6f9][9e9a6f9], [089c346][089c346] |
| One XInclude pass shares a node budget | Everything its inclusions copy in counts against Parse.MaxNodes, once per level it is copied through. |
[eb4d0ae][eb4d0ae] |
An xsl:use-package cycle is XTSE3005 |
A package that uses itself, directly or through another, is a static error, not a crash. | [dce8830][dce8830] |
Compile refuses a stylesheet needing over 10,000 module visits |
Each include/import resolution counts, in the static phase and the compile; real stylesheets need about 120. | [77c3c5d][77c3c5d] |
| Package reads and compiles count as module visits | A package graph compiling over 10,000 package copies is refused with ErrResourceLimit; the W3C package cases need at most 16. |
[4c5c3ee][4c5c3ee] |
| A streamed parse refuses over 64 ancestor attributes per record past 16M copies | It returns ErrResourceLimit where Parse + Transform succeeds; back off to the tree on errors.Is. |
[f90e97d][f90e97d] |
A streamed xsl:merge of more than 64 inputs runs on the tree |
Output is unchanged; memory is the tree's. | [e621bf7][e621bf7] |
Serialize refuses an OutputSettings.Standalone other than "", omit, yes or no |
SEPM0016, where a value such as "true" was written raw. | [877b3af][877b3af] |
xsl:key entries are bounded per transform |
They are totalled across every index against MaxItems, so many keyed temporary trees can raise XPDY0130. |
[d06d0f3][d06d0f3] |
| c14n XPath transforms use XPath 1.0 rules | A relational comparison of two strings converts both to numbers, as XML-DSig requires. | [0c70a04][0c70a04] |
| Rooted file resolvers refuse UNC and device paths | //host/…, \\host\…, file:////host/… and \\?\… fail with "names a network path" on every OS unless a root is on that \\host\share. |
[60fed8a][60fed8a] |
dtd.Validate checks the root element against the DOCTYPE name |
A document whose root is another declared element is now invalid, as XML 1.0 requires.... |
v2.2.0
Memory footprint work: what a tree holds and what a transform peaks at. Output
is byte-identical; new API is additive.
Added
| Change | What it does | Commit |
|---|---|---|
| Streamed aggregates over records | A lone value-of/copy-of/sequence over one record path streams too; count/sum/min/max fold per record: 1 GB summed in 33 MB RSS. Any error re-runs on the tree. |
457aa03, 9f3d815, 48b1a38, 3157566, 4944511 |
Streamed xsl:source-document, first stage |
A streamable xsl:for-each/xsl:iterate over a child path reads one record at a time: 1 GB totalled at 27 MB RSS, not 3.7 GB, at about 2× CPU. Other shapes build the tree. |
3f185fe, 27757b3 |
xdm.ParseBursts |
Parses a document handing over one selected element at a time in a tree of its own, with limits counted over the whole document; memory stays at the spine plus one record. | b4b6052, 80f999f |
xslt.FileResolver.MaxNodes; MaxBytes reaches the parser |
Raising MaxBytes past 64 MB had no effect on fn:doc, the parser kept its own default. Both limits now apply to what the resolver parses. |
80f999f |
xdmbuild.InPlaceDocument |
A builder rooted at a new document node, for content built straight into it. | 302c932 |
Changed — streamability analysis
| Change | Problem → solution | Commit |
|---|---|---|
| Six constructs escaped the §19.8 check and compiled | A nested xsl:map-entry, extension instructions (their xsl:fallback), xsl:result-document serialization AVTs, boolean pattern predicates, mode="#all" rules and rule xsl:param defaults are now judged: such stylesheets get XTSE3430. |
b5703be, 8c391d8, ff0ed5e, ca1b029, 268acce, 7920635 |
| A verdict could rest on a declaration nobody checked | Verdicts carry an unverified bit for streamable functions, attribute sets, accumulators, modes and other modules; streamed execution requires it clear. No refusal changes. | b12ecbf, e94cdf9 |
Changed — memory
| Change | Problem → solution | Commit |
|---|---|---|
| Namespace nodes lived as long as their tree | //namespace::* on 5 MiB kept 140 MB. They are held weakly, 16 to a chunk, and freed when nothing holds them: under 0.5 MB after the query. |
ac4973e, fcab85a, e1b5e1f |
| Built-in shallow-copy built a document result twice | In a mode with no template rules it builds in place: parse-100mb identity peak 1091 → 930 MB, CPU −25 to −40%. | 302c932 |
| Built trees stored every whitespace-only text value | They share one value per string, as a parse does: an identity result is the size of its source again. | c60f8f3, 09f0c5d |
| A deep copy duplicated the source's text | xsl:copy-of of 4,096+ records borrows the source blocks it fills by half or more: XMark identity result −28%, peak −19%. |
546af03, b4cd614 |
Every copy-of was kept until the transform ended |
Each copied node was recorded against its original for accumulators, even with none declared: a 10 MB stream copying each record peaked at 830 MB. The table exists only when an accumulator does: 2.8 MB. Also in v2.1.1. | c7952b0 |
| Full record chunks were padded 6% by the malloc header | They are allocated two at a time past the 8th, 40,960 B exactly: parse-100mb retained 370 → 350.5 MB. | 907c674 |
v2.1.1
Memory and CPU fixes from go-xmlsec's measurements against v2.1.0. No API
change; output is byte-identical.
Fixed
| Change | Problem → solution | Commit |
|---|---|---|
c14n.ParsePrefixList was quadratic in the prefixes |
It deduplicated with a scan per token: 1 MiB of distinct prefixes took 10.9 s. It uses a map, keeping first-seen order: about 0.02 s. | ad8c47a |
Changed — memory
| Change | Problem → solution | Commit |
|---|---|---|
| A large text value cost up to 3.1× its size to parse | slices.Grow rounded the buffer past the hand-off check, so the value was copied twice. The buffer is grown exactly and handed to the tree when no later value wants it: 1 MiB 3.10 → 1.12×, 10 MiB 1.87 → 1.08×. |
707ca28 |
| A tag with many attributes or namespace declarations peaked at 13–22× its size | Duplicates past 8 attributes are found by sorting, no name index is built for such a tag, one scope index serves both lookups and repeated URIs are interned: 800K attributes 21.5 → 12.8× peak, 100K declarations 16.5 → 6.6×. | 5475837, b08624c |
| c14n allocated a map per element of a namespace node set; the namespace axis sorted through a map | The map is reused (2,000 elements: 4,016 → 18 allocations); scopeSlots uses one stable sort (4 → 1 allocation a call). |
9572c44, fd9750e |
/r/l[1] built every l child before the predicate ran |
A step whose first predicate is an integer literal stops at that match. | 5712d9f |
v2.1.0
Three memory audits across parsing, XPath/XQuery, XSLT, validation,
serialization and c14n, and the items go-xmlsec reported. Output is
byte-identical except where Changed says otherwise. New exported API, listed
under Added, makes this a minor release.
Added
| Change | What it does | Commit |
|---|---|---|
xpath.SerializeJSONTo, xpath.SerializeAdaptiveTo |
The json and adaptive methods written to an io.Writer instead of returned as a string. |
[599b2f9][599b2f9] |
xdm.Node.AddNamespaces |
Sets several namespace bindings on an element in one call. | [b42f04a][b42f04a] |
xdm.Node.Index, Node.SubtreeEnd, Tree.Len, Tree.NodeAt |
A node's dense, document-order position in its tree (attributes included, namespace nodes -1), stable once the node exists; size a table with SubtreeEnd() - Index() and look nodes up by position. |
[b37796b][b37796b] |
xdm.Node.InScopeNamespaceBindings |
Iterates an element's in-scope prefixes and URIs without making a namespace node for each. | [73249e2][73249e2] |
xdm.ArrayItem.AppendMembers |
Appends an array's members to a slice without an intermediate copy. | [59ac569][59ac569] |
xpath.CompileBounded, xpath.MaxRegexpProgram |
regexp.Compile that refuses a program over 100,000 instructions; used by XPath and XSD patterns. |
[c1c2bb9][c1c2bb9] |
xpath.Env.MaxDigits, xpath.MaxDigits |
Bounds the digits of an xs:integer or xs:decimal cast or arithmetic result; 0 is 10^6, negative is none. |
[8577906][8577906] |
xdm.AppendIntegers, xpath.Context.WithVars |
Appends a run of integers allocated a chunk at a time; binds several variables in one scope. | [30c7c07][30c7c07], [5951f24][5951f24] |
xpath.Context.NodesRefused, ItemsRefused |
Whether the node budget was crossed, and whether a running item total is past the item bound, without charging either. | [4e8f0a5][4e8f0a5], [21995a6][21995a6] |
Changed
| Change | What to do | Commit |
|---|---|---|
xsd and dtd error messages clip document-supplied strings to 1 KB plus "..." |
Nothing, unless you match messages longer than 1 KB. Message wording is not part of the contract. | [20958aa][20958aa], [bd865e4][bd865e4] |
| json and adaptive serialization can leave partial output when an error is raised mid-document | Treat the writer's content as invalid on error, as the XML methods already required. | [599b2f9][599b2f9] |
New refusals: maps and arrays nested past 1,000 levels in json/adaptive output (XPDY0130), deep-equal and map:find (XPDY0001), with their own counter, apart from function recursion; regexes over 100,000 instructions (FORX0002, or a pattern error in XSD); picture widths over 65,536 (FOFD1340); xsl:key and group-by keys past 5,000,000 retained (XPDY0130); integers over 10^6 digits (FOCA0003, FOAR0002); sequences built by , or !, xsl:next-iteration values, unparsed-text-lines lines, parse-json/json-doc values and stored accumulator items past MaxItems (XPDY0130); xsl:copy-of of a document past MaxNodes (XPDY0130) |
Nothing for real inputs: the largest W3C suite regex is 4,313 instructions. All wrap xdm.ErrResourceLimit. |
[702c6e6][702c6e6], [014a862][014a862], [c1c2bb9][c1c2bb9], [21995a6][21995a6], [8577906][8577906], [dcb49b2][dcb49b2], [c73a06b][c73a06b], [a3d8ef6][a3d8ef6], [40cd52c][40cd52c], [b35ec14][b35ec14] |
The CLI drops its collector from GOGC=200 to 100 once the live heap passes 128 MB |
Nothing; set GOGC to keep a fixed value. Peak RSS −20% on DocBook's largest table, about 12% more user CPU. |
[f3449f7][f3449f7] |
The FileResolver no longer evicts to admit a document that does not fit beside its cache |
A document refused admission is parsed again on its next request, so across transforms it is not the same tree; within one transform it is. | [f49ff92][f49ff92] |
xdm.ProcessXInclude returns a parsed tree unchanged when it has no XInclude element |
Nothing; a parsed tree is frozen. A built tree is still copied. | [e139525][e139525], [9c3a983][9c3a983] |
Fixed
| Change | Problem → solution | Commit |
|---|---|---|
xsd error messages kept attacker strings whole |
A 1 MB namespace in 200 attributes kept 105 MB. fail and attrName clip to 1 KB: 0.13 MB. |
[20958aa][20958aa] |
| The DTD validator built every element's path, quadratic in depth | A valid 990-deep chain of 4 KB names allocated 2 GB. The path is rendered only for a failure, text unchanged. | [8dcb07f][8dcb07f] |
DTD validity messages kept #FIXED, enum and ID values whole |
200 mismatches on a 1 MB #FIXED value kept 105 MB. fail clips to 1 KB. |
[bd865e4][bd865e4] |
The nested fn:transform cache kept compiles for dead resolvers |
A fresh resolver per call kept 49 MB on DocBook. Resolvers are weak keys and dead entries are dropped: 0.3 MB. | [a5b385d][a5b385d] |
Sequences built by , or ! were not counted against MaxItems |
A 70-byte doubling fold-left built 134M items against the 5M limit, at 6.3 GB; through recursive with-param too. They are charged above 64 items. Also in v2.0.3. |
[dcb49b2][dcb49b2] |
| RELAX NG reported a valid document invalid | (a?){13} a{13} against 13 <a/> hit the derivative cap, naming a oneOrMore the schema lacks; xmllint accepts it. Choice chains merge alternative by alternative: N = 12, 13, 18, 30 validate. Also in v2.0.3. |
[44229aa][44229aa] |
| Serializing a sequence of atomic values was quadratic | 1 to 100000 took 21.6 s and 6.95 GB, joined by repeated concatenation. Each run is joined once: 0.056 s. Also in v2.0.3. |
[a9ad280][a9ad280] |
| Text lines, JSON values, DTD default values, integer digits and accumulator values grew past the limits | unparsed-text-lines kept 5.2 GB, 2 MB of DTD defaults 1.97 GB, a 4M-digit cast 34 GB, a 200 KB accumulator 12.4 GB. Each is charged, bounded, stored once or shared. Also in v2.0.3. |
[c73a06b][c73a06b], [be5afc3][be5afc3], [8577906][8577906], [40cd52c][40cd52c] |
xsl:copy-of of a document was not counted against MaxNodes |
It copied 5.7M nodes and exited 0, where shallow-copy is refused. It is charged before copying. | [b35ec14][b35ec14] |
| Deeply nested maps and arrays crashed the process | serialize(..., json) or deep-equal on a 400,000-deep array from a 96-byte query overflowed the Go stack. They are refused with a resource-limit error; xdm.Flatten is iterative. Also in v2.0.3. |
[702c6e6][702c6e6] |
A built-in shallow-copy rule returned a truncated result past MaxNodes with no error |
A 1M-element identity copy emptied a third of its elements and exited 0. The transform now fails with XPDY0130 whenever the node budget was crossed. Also in v2.0.3. | [4e8f0a5][4e8f0a5] |
| Sequential regex repeats compiled to huge programs | \pL{1000} repeated 150 times passes Go's 1,000-repeat check: 181 KB of patterns kept 984 MB. Programs over 100,000 instructions are refused in XPath and XSD. |
[c1c2bb9][c1c2bb9] |
fn:replace, picture widths, xsl:key and group-by grew past their budgets |
replace charged after building (12.8 GB for 500 KB in), [D01,1000000000] allocated 2.8 GB, and use="1 to 1000" over 100k nodes 3.2 GB. Each is charged or refused first. |
[c1c2bb9][c1c2bb9], [21995a6][21995a6] |
| Caches bounded by entries held gigabytes of long keys or documents | Regex, collation and char-atom keys over 1 KB are not cached; the FileResolver document cache is also bounded by 32 MB of source. |
[c1c2bb9][c1c2bb9], [de4a515][de4a515] |
Changed — memory
| Change | Problem → solution | Commit |
|---|---|---|
| Namespace URIs were tokeniser-arena strings | Each parsed tree kept a 32 KB arena block alive. URIs are copied at declaration: DocBook trees retain 31.6 → 12.3 MB. | [18d374d][18d374d] |
| Every parse allocated a 32 KB string-arena block | The first block is sized to the input: DocBook corpus parse 37.6 → 19.6 MB a pass. | [9e13f70][9e13f70] |
TrackPositions kept the source text to count lines |
Line starts are recorded as the text is read: a tracked 10 MB tree retains 50.4 → 41.5 MB. | [ec1ac54][ec1ac54] |
| Parsed trees kept build-only indexes, slack and copied long text twice | Indexes dropped at freeze, the last text block trimmed, long text handed over: DocBook retains a further −10%. | [2ad3a32][2ad3a32], [a5ab736][a5ab736], [4440665][4440665] |
| Each parse allocated three read windows | They are pooled: DocBook corpus parse 19.8 → 17.1 MB a pass. | [6345114][6345114] |
isBase64Binary copied each value into a []rune |
One byte pass: a 380 KB value 1.54 MB → 0 allocations. | [5d8fceb][5d8fceb] |
| DTD content matching, ID bookkeeping and bound facets allocated per child or value | Two reused state sets, one ID map, bounds parsed once: dtd validation −47%, xsd instance −24%. |
[e056467][e056467], [f09c1a3][f09c1a3], [14c84b5][14c84b5] |
| XQuery FLWOR tuples copied names, rebuilt values and grew results by doubling | Shared names, own value, reserved results, version set once, no per-call library: XMark q1–q20 eval 194.9 → 119.0 MB. | [ba9e7a0][ba9e7a0], [f890740][f890740], [a8d6e7b][a8d6e7b], [24b963c][24b963c], [73af7a8][73af7a8], [f148247][f148247] |
a to b and fn:distinct-values used big arithmetic and eager promotion keys |
int64 ranges, keys written once a double arrives: distinct-values(1 to 100000) 96.0 → 53.2 MB. |
[70ff980][70ff980], [ef5f064][ef5f064] |
| Compiled stylesheets held ~980 copies of one namespace map and pinned module trees | Interned by content; instructions keep the map, not the element: compiled CEN 9.1 → 6.1 MB, DocBook 12.4 → 9.3 MB. | [490fc5a][490fc5a], [dcb15d1][dcb15d1] |
| XSLT calls built parameter maps, memo keys, namespace frames and error text per call | A slice of pairs, a reused key buffer, one-step frames, lazy text, shared global cells: DocBook section.001 −15%. | [e3b6288... |
v2.0.3
An XPath cost fix from an external audit. No API change.
Fixed
| Change | Problem → solution | Commit |
|---|---|---|
fn:normalize-space built a list of every token |
180 calls on a 15 MB value allocated 133 GB. It now collapses in one pass and returns a collapsed value uncopied: 0 GB, 8x faster. | 4264de8 |
w3cschemas
| Change | What to do | Commit |
|---|---|---|
w3cschemas v0.8.3 requires go-xml v2.0.3 |
Nothing; the pin follows the release. | — |
v2.0.2
A parser cost fix from an external audit. No API change.
Fixed
| Change | Problem → solution | Commit |
|---|---|---|
| Parsing was quadratic in the namespace declarations in scope | Each prefix scanned the whole stack: 100k declarations and 300k attributes took 33 s. The stack is indexed past 32 bindings: 0.35 s. | 8b7aab2 |
v2.0.1
A security and release-gate update from an external audit of v2.0.0. No API
change. Build with a patched Go as well:
docs/security.md explains which
fixes ship in Go releases rather than here.
Fixed
| Change | Problem → solution | Commit |
|---|---|---|
golang.org/x/text v0.36.0 loops forever on some invalid input (GO-2026-5970) |
Reached through collation. go-xml requires v0.41.0, the newest that still builds with Go 1.25. | 18efb89 |
tests/check.sh fast failed in a checkout without the W3C suites |
The vendored-schemas lane ran its driver with no roots. It is now SKIP, "fixture roots absent". | 27f463d |
Added
| Change | What it does | Commit |
|---|---|---|
CI job vulncheck |
Runs govulncheck over go-xml and w3cschemas on the newest Go. |
18efb89 |
TestTrailingSlashSymlinkStaysConfined in each confined resolver |
Pins that a name ending in / cannot follow a symlink out of an os.Root, even on a Go without the GO-2026-4970 fix. |
b8f35ea |
w3cschemas
| Change | What to do | Commit |
|---|---|---|
w3cschemas v0.8.0 requires go-xml v2 |
Catalog returns a v2 *xsd.CatalogResolver; import github.com/knroy/go-xml/v2/xsd with it. v0.7.x stays with go-xml v1. |
b76c85d |
v2.0.0
v2 is a new major version with a new module path, github.com/knroy/go-xml/v2.
Nodes are rebuilt as 40-byte records and the XPath context is split, which
changes the exported Go API; the command-line tool's flags and output do not
change. docs/migrating-to-v2.md has before/after
code for every breaking change, and internal/tools/nodeaccess rewrites most
of it. v1 continues at github.com/knroy/go-xml, released from the v1
branch.
Behaviour changes to check before upgrading. Results, error codes and
serialized output are those of v1, except:
generate-id()strings are record positions, so stored ids change.- Nodes of different trees order by when each tree was numbered (a
constructed fragment: when first compared). - An XSLT global variable is evaluated on first use, so the failure of one
nothing reads is not reported (XSLT 3.0 §2.14). One withxsl:message,
xsl:assert,xsl:result-documentorfn:tracein its own body is still
evaluated at the start. - During a transform, a Go-built function item or a context-taking resolver
receives a copy of the context, not the caller's own.
Changed — breaking
| Change | What to do | Commit |
|---|---|---|
Module path github.com/knroy/go-xml/v2 |
Import github.com/knroy/go-xml/v2/<package>; nodeaccess -v1 moves a module's imports. w3cschemas still requires v1. |
— |
xdm.Node fields are unexported |
Call the method of the same name (n.Name()); range Children(), Attrs(), NamespaceDecls(); index with ChildAt, AttrAt. |
a8e5346 |
| Trees are built top-down by appending; a parsed tree is frozen | AppendElement, AppendText, AppendAttr, AppendCopy replace SetParent, SetChildren, AppendChild, AddAttr. |
3f33dce, [f64b0d1][f64b0d1] |
xdm.ProcessXInclude returns a new tree |
tree, err = xdm.ProcessXInclude(tree, opts); the input is not edited. |
[fb2426e][fb2426e] |
xdmbuild relinking setters removed (SetParent, SetChildren, ReplaceChild, …) |
Use the xdm.Node method of the same name, or build a changed copy; Builder.ReplaceOpen swaps in a typed copy. |
6b34bc3, 13c4f5f |
xpath.Context per-evaluation fields move to xpath.Env |
ctx.Docs = r → ctx.WithEnv(func(e *xpath.Env) { e.Docs = r }); read ctx.Env().Docs. |
9af0e77 |
xpath.Context static fields become methods; WithNow removed |
ctx.Version → ctx.Version(), set with WithVersion; WithNow(t) → WithEnv setting Now and HasNow. |
9af0e77 |
Context.StaticNamespaces is set only for an expression that reads it |
A host function resolves prefixes against a resolver it captured itself. | [d5a980b][d5a980b] |
Context.Position, Size and Depth are int32 |
Convert where an int is mixed in; WithFocus keeps its int parameters. |
7f6f168 |
LazyVar.Share removed; Context.WithLazyVars takes an *xpath.EvalLock |
Pass the lock (nil for a fresh one) and call lock.Share() where LazyVar.Share() was. |
[fbd4b74][fbd4b74] |
xsd.HTTPResolver moves to xsd/xsdnet; build tag goxml_nohttp removed |
Use xsdnet.HTTPResolver; importing xsd no longer links net/http. |
5509745 |
xsd.ValidateOptions.Annotate removed |
Validate only checks; take a typed tree from ValidateCopy or another ...Copy function. |
21105fe |
Added
| Change | What it does | Commit |
|---|---|---|
xdm.NewFragment, Tree.NewRoot, Copy, CopyPruned, ShallowCopy, NamespaceNodes, … |
The construction and reading calls the record layout is built on. | 3f33dce, 86f991c, [d337fd9][d337fd9] |
xdm.Node.TreeHasTyping, SetAssessedTyping, DescendantsInheritBase |
Whether a tree was ever typed; write a node's typing in one call; whether a subtree sets its own base URI. | 40dbca2, 8faf349, ae36039 |
xdmbuild.Builder.AppendCopyOf, NSDecl, NoteDeclaredList |
Copy a node straight into the tree being built; note a list of namespace bindings once. | 484cb4e, 2c5ea0b |
xpath.LazyVar, ReadyVar, Context.WithLazyVars, WithStaticHost |
Variables evaluated on first reference, forced once from any goroutine once shared; a static host for expressions compiled without one. | 7c5121c, [d5a980b][d5a980b] |
xpath.EvalLock, xpath.EvalLocker |
A re-entrant lock a host runtime shares once other goroutines can reach it; free until shared. | [fbd4b74][fbd4b74], 4954bf0 |
go-xml xquery -validate strict|lax, xquery.Query.Schema |
Validate the input against the schema the query imports before it runs. Also in v1.8.0. | 130360b |
tests/record.sh, tests/recdiff |
Record every suite case's output and diff two checkouts, with allowed differences by rule. | 5aa004e |
docs/benchmark.md v1 against v2; docs/profiling.md |
The benchmark with both versions against the reference engines; where v2's time goes and how to measure a change. | [dcf9d53][dcf9d53] |
Fixed
| Change | Problem → solution | Commit |
|---|---|---|
| A function item returned by a transform raced when called from several goroutines | key(), accumulators and memoised functions wrote shared maps. One re-entrant lock per transform, also around Go extension calls and fn:transform. |
[fbd4b74][fbd4b74], 4954bf0 |
| A called template or function could read a caller's local variable | It happened where a global of the same name existed. Locals now live in frames that each call raises. | a0250dd |
| go-xml did not compile for 32-bit targets | The xs:date year bound overflowed int, and array positions past 2^31 could wrap. CI now vets linux/386, linux/arm, windows/386. Also in v1.8.0. |
4f6ed50 |
docs/xquery.md said import schema ... at is not resolved from the command line |
It is, through the query's directory, -allow-dir roots and -catalog. |
— |
Changed — performance
Ratios are warm time over the reference engine from
docs/benchmark.md, v1 at f45068c against v2.0.0.
| Change | Problem → solution | Commit |
|---|---|---|
| A parsed node was a 280-byte struct of 16 pointers | 40-byte records in per-tree chunks. A 100 MB parse peaks at 371 MB (v1 2.2 GB); parse 0.54× → 0.46× encoding/xml. |
a81dff2, b08a3d4, 2dd09c0 |
Every scope change copied a 512-byte xpath.Context |
A 96-byte scope over a shared Env and a static part; Compiled.Eval swaps a pointer. |
9af0e77, 7f6f168 |
| XSLT evaluated every global eagerly and gave each local and call a context copy | Lazy globals, one locals stack per transform, absent-component bits, int64 arithmetic. DocBook 0.46× → 0.20× Saxon. | 7c5121c, a0250dd, 1e976a3, 496f46a |
XQuery copied constructed content twice, and //name walked the tree each time |
Content is copied once into the builder; a document indexes its element names on first use. XMark 1.00× → 0.77× Saxon. | 484cb4e, [babd534][babd534] |
| Typed validation copied the tree twice and wrote 80 bytes of typing per node | The source is validated read-only and copied once; typing shares its names. XSD 0.73× → 0.61× Xerces. | [d3f4824][d3f4824], 8e29a38, 3208c54 |
RELAX NG re-walked derivatives per element and hashed names through sync.Map |
Sizes stored once, typed memos, reused buffers: −23 to −30% CPU, long documents −84% allocations. | ae4f4d1, [ea89438][ea89438], [fb7a15b][fb7a15b] |
| C14N and the serializer paid a call or a defer per token and element | C14N writes to its own buffer; the serializer has no defers. C14N −10 to −12% CPU. | 63155c7, [da27a7c][da27a7c] |
| Package init built large tables and compiled regexps on every run | Built on first use: init allocations 1,893 → 785, cold XSD validation −3 to −4%. default.pgo regenerated for v2. |
[c249ce3][c249ce3], 47db4aa, [c5184cb][c5184cb] |
[babd...
v1.8.1
A security and release-gate update from an external audit of v2.0.0, which
applies to v1 too. No API change. Build with a patched Go as well:
docs/security.md explains which
fixes ship in Go releases rather than here.
Fixed
| Change | Problem → solution | Commit |
|---|---|---|
golang.org/x/text v0.36.0 loops forever on some invalid input (GO-2026-5970) |
Reached through collation. go-xml requires v0.41.0, the newest that still builds with Go 1.25. | b785a84 |
tests/check.sh fast failed in a checkout without the W3C suites |
The vendored-schemas lane ran its driver with no roots. It is now SKIP, "fixture roots absent". | ca9760c |
Added
| Change | What it does | Commit |
|---|---|---|
CI job vulncheck |
Runs govulncheck over go-xml and w3cschemas on the newest Go. |
— |
TestTrailingSlashSymlinkStaysConfined in each confined resolver |
Pins that a name ending in / cannot follow a symlink out of an os.Root, even on a Go without the GO-2026-4970 fix. |
2a9b961 |