Transformations that utilizes 'namespace-uri()' function generates different namespace prefixes. As a result subsequent transformations of the same XML content with the same XSL will result in different content generated. The example of two subsequent iterations results can be: Iteration 1: <?xml version="1.0" encoding="UTF-8"?> <ns0:TestRoot xmlns:ns0="test.xmlns"> <ns1:Element1 xmlns:ns1="test.xmlns"> </ns1:Element1> <ns2:Element2 xmlns:ns2="test.xmlns"> </ns2:Element2> </ns0:TestRoot> Iteration 2: <?xml version="1.0" encoding="UTF-8"?> <ns3:TestRoot xmlns:ns3="test.xmlns"> <ns4:Element1 xmlns:ns4="test.xmlns"> </ns4:Element1> <ns5:Element2 xmlns:ns5="test.xmlns"> </ns5:Element2> </ns3:TestRoot> Such behavior can lead to the high memory usages by cached transformer/templates instances: The unique namespace prefixes will be stored in Xerces SymbolTable associated with the cached transformer. The BasisLibrary::generatePrefix method should be fixed to generate the same prefixes numbers for each transformation operation, i.e. the prefix index counter should be made thread local and needs to be reset during the start of each transformation process.
|