On Tue, 7 Jul 2026 17:15:48 GMT, Andrew John Hughes <[email protected]> wrote:
>> When XSLT output method is html, characters supported by the target encoding >> were serialized as HTML entity references (for example, é as eacute;). This >> caused failures when the generated output was later processed as XML. >> >> **Solution:** >> Update HTML serializer to write characters directly when they are supported >> by the configured encoding, and retain existing entity escaping behavior for >> unsupported characters. >> >> **Testing:** >> Verified XSLT transformation with accented characters and confirmed >> generated output can be parsed successfully without XML parsing failures. >> >> Performed Tier1 and Tier2 tests in Linux with and without the fix. No >> regression found >> >> >> The bug report for the same: https://bugs.openjdk.org/browse/JDK-8387291 >> >> --------- >> - [x] I confirm that I make this contribution in accordance with the >> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai). > > Incidentally, there are no XML tests in tier1 and tier2 only has > `javax/xml/crypto` and `com/sun/org/apache/xml/internal/security` via > `jdk_security2`. You likely want `jtreg:javax/xml/jaxp` too. @gnu-andrew I applied the changes from the following Apache Xalan commit you suggested: https://github.com/apache/xalan-java/commit/666e9b9df6f9f4bef281d4547d088bfa67009bad#diff-315ec5a1a41f86fa47ac6e1c53eb71ee0ee293c2dc2ca00acdafe8b4799a43f5 However, the testcase was still failing after applying the commit. === Transformed Output === <Order DocumentType="0001" DraftOrderFlag="N" EnterpriseCode="XYZ" EntryType="Web" OrderNo="" OrderDate="" SellerOrganizationCode="XYZ" BuyerOrganizationCode="" ReqDeliveryDate="" ReqShipDate=""> <OrderLines> <OrderLine OrderedQty="1" PrimeLineNo="1" SubLineNo="1"> <Item ItemID="XYZItem10" UnitOfMeasure="EACH" ProductClass="Good" ItemShortDesc="75 compléments premium et appétissants au poulet 300 gr" ManufacturerItemDesc="75 compléments premium et appétissants au poulet 300 gr"></Item> </OrderLine> </OrderLines> <PersonInfoShipTo Country="US"></PersonInfoShipTo> <PersonInfoBillTo Country="US"></PersonInfoBillTo> </Order> ========================= [Fatal Error] :4:110: The entity "eacute" was referenced, but not declared. ✗ FAILED: SAXParseException Error at line 4, column 110 Message: The entity "eacute" was referenced, but not declared. org.xml.sax.SAXParseException; lineNumber: 4; columnNumber: 110; The entity "eacute" was referenced, but not declared. at java.xml/com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:263) at java.xml/com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:335) at java.xml/javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:122) at HTMLEntityParsingTest.main(HTMLEntityParsingTest.java:48) Therefore, I made an additional change in **`ToHTMLStream.java`**: else if (escapingNotNeeded(ch) && ch >= CharInfo.ASCII_MAX) { // Non-ASCII character that is encodable in the output encoding: // write it literally rather than as a named HTML entity (e.g. é) // so the output remains valid XML when parsed by an XML parser. cleanLength++; } The above change resolved the issue, and the final patch is provided below. === Transformed Output === <Order DocumentType="0001" DraftOrderFlag="N" EnterpriseCode="XYZ" EntryType="Web" OrderNo="" OrderDate="" SellerOrganizationCode="XYZ" BuyerOrganizationCode="" ReqDeliveryDate="" ReqShipDate=""> <OrderLines> <OrderLine OrderedQty="1" PrimeLineNo="1" SubLineNo="1"> <Item ItemID="XYZItem10" UnitOfMeasure="EACH" ProductClass="Good" ItemShortDesc="75 compléments premium et appétissants au poulet 300 gr" ManufacturerItemDesc="75 compléments premium et appétissants au poulet 300 gr"></Item> </OrderLine> </OrderLines> <PersonInfoShipTo Country="US"></PersonInfoShipTo> <PersonInfoBillTo Country="US"></PersonInfoBillTo> </Order> ========================= ✓ SUCCESS: Document parsed! ------------- PR Comment: https://git.openjdk.org/jdk/pull/31689#issuecomment-5366007419
