STAG-DIFF(1p)
β¨ STAG-DIFF β¨
okay bestie, so this is the manual page for stag-diff, part of the User Contributed Perl Documentation collection. if you've ever needed to know whether two stag files are actually the same vibe or lowkey beefing, this is your girl π¦
πΈ NAME πΈ
stag-diff β finds the difference between two stag files. yes that's it. that's the whole job. and she does it beautifully. π
π SYNOPSIS π
stag-diff -ignore foo-id -ignore bar-id file1.xml file2.xml
like. look at her. so simple. so iconic. π
π DESCRIPTION π
So basically she compares two data trees and reports whether they match. and if they don't match?? bestie she WILL tell you. the mismatch gets reported. no secrets here, we're in a healthy communicative relationship π
π§ ARGUMENTS
-help|hβ shows this document. self care. read the docs, babes π«Ά-ignore|i ELEMENTβ these nodes get ignored for the purposes of comparison. lowkey ghosting them, and honestly? valid.
β οΈ important detail: attributes are treated as elements, prefixed by the containing element id. so keep that in mind, okay?
for example, if you have
<foo ID="wibble">
and you wish to ignore the ID attribute, then you would use the switch
-ignore foo-ID
you can specify multiple elements to ignore like this:
-i foo -i bar -i baz
you can also specify paths:
-i foo/bar/bar-id
-parser|p FORMATβ which parser to use. the default is XML. this can also be autodetected by the file suffix. other alternatives are sxpr and itext. seeData::Stagfor details π-report|r ELEMENTβ report mismatches as they occur on each element of type ELEMENT. and yes bestie, multiple elements can be specified. we love options π-verbose|vβ used in conjunction with the-reportswitch. shows the tree of the mismatching element. it's giving forensic investigator πβ¨
π₯ OUTPUT
if a mismatch is reported, a report is generated displaying the subpart of the tree that could not be matched. this will look like this:
REASON: no_matching_node: annotation
no_matching_node: feature_set
no_matching_node: feature_span
no_matching_node: evidence
no_matching_node: evidence-id
data_mismatch(:15077290 ne :15077291): evidence-id AND
evidence-id
ngl, due to the nature of tree matching, it can be difficult to specify exactly how trees do not match π. to investigate this, you may need to use the -r and -v options. for the above output, I would recommend using
stag-diff -r feature_span -v
she's got layers, okay?? you just gotta dig a lil π
π ALGORITHM π
both trees are recursively traversed... see the actual code for how this works π (yes, that's genuinely what the docs say, and honestly? respect the honesty)
the order of elements is not important. eg
<foo>
<bar>
<baz>1</baz>
</bar>
<bar>
<baz>2</baz>
</bar>
</foo>
matches
<foo>
<bar>
<baz>2</baz>
</bar>
<bar>
<baz>1</baz>
</bar>
</foo>
see?? same energy. different order. she does not care about your sequencing, she cares about your content π
β οΈ the drama part: the recursive nature of this algorithm means that certain tree comparisons will explode wrt time and memory. I think this will only happen with very deep trees where nodes high up in the tree can only be differentiated by nodes low down in the tree. so like... don't do that?? π
β οΈ also: both trees are loaded into memory to begin with, so it may thrash with very large documents. she's holding everything in her head at once, which is so relatable but also a warning πΈ
π AUTHOR π
Chris Mungall β cjm at fruitfly dot org. thank you for your service king π«Ά
β SEE ALSO β
Data::Stag
and that's the whole page bestie!! this was documented with perl v5.34.0, dated 2022-06-12, and filed under STAG-DIFF(1p) π stay matching, stay iconic β¨π
π¦ where this page comes from
- debian bookworm: libdata-stag-perl 0.14-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libdata-stag-perl 0.14-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libdata-stag-perl 0.14-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu questing: libdata-stag-perl 0.14-3
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms