<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<p>Hi Hempushpa,</p>
<p><br>
You may want to talk to <span id="assignee-val" class="view-issue-field editable-field inactive" title="Click to edit"><span class="user-hover user-hover-replaced" id="issue_summary_assignee_clanger" rel="clanger">Christoph on
JDK-8168664, he might have temped a fix at the time.
Otherwise, feel free to create a new bug and PR, and we can
start from there.<br>
</span></span></p>
<p><br>
Thanks,</p>
<p>Joe<br>
</p>
<div class="moz-cite-prefix">On 4/23/25 7:03 AM, Hempushpa Sahu
wrote:<br>
</div>
<blockquote type="cite" cite="mid:SJ4PPF6D7B23F3FEA3AEBBD32A4999EB9FA9DBA2@SJ4PPF6D7B23F3F.namprd15.prod.outlook.com">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style>@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face
{font-family:Aptos;}p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
font-size:11.0pt;
font-family:"Aptos",sans-serif;
mso-ligatures:standardcontextual;
mso-fareast-language:EN-US;}a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#467886;
text-decoration:underline;}span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Aptos",sans-serif;
color:windowtext;}.MsoChpDefault
{mso-style-type:export-only;
font-size:11.0pt;
mso-fareast-language:EN-US;}div.WordSection1
{page:WordSection1;}</style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal">Problem Description : <o:p></o:p></p>
<p class="MsoNormal">XSLT transformation creating unique
namespace prefixes.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Analysis & Observation : <o:p></o:p></p>
<p class="MsoNormal">The XSLT transformation is generating a new
namespace prefix for every XML element, even when the
namespace value matches that of the parent element. This leads
to large XML file transformations exceeding the file size and
memory limits on our systems.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">The behaviour in OpenJDK has remained
consistent since JDK 8; however, the namespace prefix issue is
not something we find optimum.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">During our investigation of the OpenJDK
codebase, we identified defect
<a href="https://bugs.openjdk.org/browse/JDK-8167179" moz-do-not-send="true" class="moz-txt-link-freetext">https://bugs.openjdk.org/browse/JDK-8167179</a>,
which was intended to resolve the namespace prefix issue in
the OpenJDK 8 release. However, our testing confirms that the
issue persists across multiple versions, including OpenJDK 8,
11, 17, and 22. Additionally, we found an open bug report <a href="https://bugs.openjdk.org/browse/JDK-8168664" moz-do-not-send="true" class="moz-txt-link-freetext">
https://bugs.openjdk.org/browse/JDK-8168664</a> in the
OpenJDK issue tracker referencing a similar problem. Notably,
there has been no recent activity on this bug for several
years<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Suggested Solution:<o:p></o:p></p>
<p class="MsoNormal">Introduced a hashmap, and storing the
unique namespace-url from root node and checking if new url
namespace-url encountered then we will store it in the hashmap
and increment the namespace prefix, else we will not increment
the prefix.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Implemented in existing function
startXslElement() of
src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/runtime/BasisLibrary.java<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"> else {<o:p></o:p></p>
<p class="MsoNormal"> // Need to generate a prefix?<o:p></o:p></p>
<p class="MsoNormal"> if (namespace != null &&
namespace.length() > 0) {<o:p></o:p></p>
<p class="MsoNormal"> prefix = generatePrefix();<o:p></o:p></p>
<p class="MsoNormal"> qname = prefix + ':' + qname;<o:p></o:p></p>
<p class="MsoNormal"> handler.startElement(namespace,
qname, qname);<o:p></o:p></p>
<p class="MsoNormal">
handler.namespaceAfterStartElement(prefix, namespace);<o:p></o:p></p>
<p class="MsoNormal"> }<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">The above code is changed to <o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal"> else {<o:p></o:p></p>
<p class="MsoNormal"> // Need to generate a prefix?<o:p></o:p></p>
<p class="MsoNormal"> if (namespace
!= null && namespace.length() > 0) {<o:p></o:p></p>
<p class="MsoNormal">
//Check if prefix needs to be incremented.<o:p></o:p></p>
<p class="MsoNormal">
if (!namespaceMap.containsKey(namespace))<o:p></o:p></p>
<p class="MsoNormal">
{<o:p></o:p></p>
<p class="MsoNormal">
namespaceMap.put(namespace,
threadLocalPrefixIndex.get().getAndIncrement());<o:p></o:p></p>
<p class="MsoNormal">
prefix = "ns"+namespaceMap.get(namespace);<o:p></o:p></p>
<p class="MsoNormal">
qname = prefix + ':' + qname;<o:p></o:p></p>
<p class="MsoNormal">
handler.startElement(namespace, qname, qname);<o:p></o:p></p>
<p class="MsoNormal">
handler.namespaceAfterStartElement(prefix,
namespace);<o:p></o:p></p>
<p class="MsoNormal">
}<o:p></o:p></p>
<p class="MsoNormal">
else<o:p></o:p></p>
<p class="MsoNormal">
{<o:p></o:p></p>
<p class="MsoNormal">
//Namespace URI already exist in map.<o:p></o:p></p>
<p class="MsoNormal">
prefix = "ns"+namespaceMap.get(namespace);<o:p></o:p></p>
<p class="MsoNormal">
qname = prefix + ':' + qname;<o:p></o:p></p>
<p class="MsoNormal">
handler.startElement(namespace, qname, qname);<o:p></o:p></p>
<p class="MsoNormal">
handler.namespaceAfterStartElement(prefix,
namespace);<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">
}<o:p></o:p></p>
<p class="MsoNormal"> }<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">Releases:<o:p></o:p></p>
<p class="MsoNormal">OpenJDK 8, 11, 17 & 22 the issue is
seen.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Note:<o:p></o:p></p>
<p class="MsoNormal">Proceeding with this approach, we will need
to update the test files. For instance, we have identified one
test case that validates the namespace prefix in the result -
test/jaxp/javax/xml/jaxp/unittest/transform/NamespacePrefixTest.java<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Next steps: <o:p></o:p></p>
<p class="MsoNormal">We want to take the above-mentioned fix to
OpenJDK.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Please review and suggest if the above
understanding is right and we shall take the fix to OpenJDK.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</blockquote>
</body>
</html>