The constructor of PiDirective lowercases the target name with tgt.toLowerCase(Locale.ENGLISH) before storing it in this.target, see src/main/java/org/xembly/PiDirective.java around line 38. The lowercased value is later used in Document.createProcessingInstruction(this.target.raw(), this.data.raw()) around line 60, so the case information from the caller is lost in the produced DOM.
XML 1.0 Names are case-sensitive, and the PITarget production in section 2.6 inherits that. Calling new Directives().pi("MyApp", "x") ends up emitting <?myapp x?> instead of <?MyApp x?>, which is observably different from what every other XML toolchain produces for the same input. Callers that expect the target they wrote to round-trip through xembly silently get a different document.
The lowercasing looks like it was meant to detect the reserved xml prefix (case-insensitive per the spec), but storing the lowercased form goes further than that and rewrites the user input. The fix is to keep tgt as-is in this.target and, if a check is still wanted, reject targets that match (?i)^xml$ instead of folding the case.
The constructor of
PiDirectivelowercases the target name withtgt.toLowerCase(Locale.ENGLISH)before storing it inthis.target, seesrc/main/java/org/xembly/PiDirective.javaaround line 38. The lowercased value is later used inDocument.createProcessingInstruction(this.target.raw(), this.data.raw())around line 60, so the case information from the caller is lost in the produced DOM.XML 1.0 Names are case-sensitive, and the
PITargetproduction in section 2.6 inherits that. Callingnew Directives().pi("MyApp", "x")ends up emitting<?myapp x?>instead of<?MyApp x?>, which is observably different from what every other XML toolchain produces for the same input. Callers that expect the target they wrote to round-trip through xembly silently get a different document.The lowercasing looks like it was meant to detect the reserved
xmlprefix (case-insensitive per the spec), but storing the lowercased form goes further than that and rewrites the user input. The fix is to keeptgtas-is inthis.targetand, if a check is still wanted, reject targets that match(?i)^xml$instead of folding the case.