bamaer opened a new issue, #8936:
URL: https://github.com/apache/hop/issues/8936

   ### What needs to happen?
   
   Five small, independent fixes in the XML plugins. Each reproduces on 2.19.0 
and current `main`, and none changes behaviour for pipelines that work today.
   
   ### 1. Get data from XML: attribute fields read as empty when the element 
type isn't the English description
   
   The element type is stored and compared as its translated description 
(`getElementTypeDesc`), case-sensitively. A field whose element type is saved 
as `Attribut` (French UI), or as the code `attribute`, is treated as a node, so 
the attribute value comes out empty, with no error. A pipeline saved in a 
non-English UI silently breaks on an English one.
   
   **Reproduce:** a Get data from XML field with element type `Attribut` (or 
`attribute`) on an attribute XPath: the field is empty.
   
   **Fix:** when the transform initialises, accept the code or any translated 
description, case-insensitively.
   
   ### 2. Get data from XML: a file with a DOCTYPE can't be read, whatever 
`XML_ALLOW_DOCTYPE_DECL` says
   
   `Dom4JUtil.getSAXReader()` always sets `disallow-doctype-decl=true` and 
ignores `XML_ALLOW_DOCTYPE_DECL`, so `IgnoreDtdEntityResolver` is never reached.
   
   **Reproduce:** read an XML file that starts with `<!DOCTYPE …>`, with 
`XML_ALLOW_DOCTYPE_DECL=Y`: it fails with "DOCTYPE is disallowed".
   
   **Fix:** honour `XML_ALLOW_DOCTYPE_DECL`, as `XmlParserFactoryProducer` 
does. External DTD and external entity loading stay disabled.
   
   ### 3. XSLT action and XSLT transform: relative `xsl:include` / `xsl:import` 
resolve against the working directory
   
   The stylesheet (and the XML) are passed as a `StreamSource` without a 
systemId, so relative references resolve against Hop's working directory, not 
the stylesheet's folder.
   
   **Reproduce:** `a.xsl` with `<xsl:include href="b.xsl"/>` next to `b.xsl`; 
run the XSLT action from another directory: XTSE0165, `FileNotFoundException 
<cwd>/b.xsl`.
   
   **Fix:** `new StreamSource(stream, fileObject.getName().getURI())` for the 
stylesheet and the XML, in the action (`Xslt.java`) and the transform 
(`XsltData.java`).
   
   ### 4. XML Output (Advanced): zero input rows leave a 0-byte, invalid file, 
and the pipeline succeeds
   
   With no input rows the transform logs "Trying to write END_DOCUMENT when 
document has no root" on close, leaves an empty (invalid XML) file, and the 
pipeline still reports success.
   
   **Reproduce:** XML Output (Advanced) fed by an empty Data Grid.
   
   **Fix:** write the root element (an empty document) when there are no rows, 
and count a failure on close as an error.
   
   ### 5. XML Output (Advanced): a tree whose root element is the loop element 
fails at the second row
   
   With Loop set on the root element, the second row fails with Woodstox's 
"second root element" error, after a partial file has been written.
   
   **Reproduce:** Loop = Y on the root element, two input rows.
   
   **Fix:** reject this tree in `AdvancedXmlOutputValidator` (and `check()`) 
with a clear message.
   
   ---
   
   Each fix comes with a test, either a unit test or a small pipeline under 
`integration-tests/xml`.
   
   
   ### Issue Priority
   
   Priority: 2
   
   ### Issue Component
   
   Component: Transforms


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to