[ http://issues.apache.org/jira/browse/XALANJ-2140?page=all ]

Brian Minchau updated XALANJ-2140:
----------------------------------

    Fix Version: 2.7
                     (was: CurrentCVS)

> Re-use the same transformer with stylesheet containing xsl:key doesn't work 
> correctly
> -------------------------------------------------------------------------------------
>
>          Key: XALANJ-2140
>          URL: http://issues.apache.org/jira/browse/XALANJ-2140
>      Project: XalanJ2
>         Type: Bug
>   Components: XSLTC
>     Versions: 2.6
>  Environment: windows jdk 1.4.2_06 xsltc
>     Reporter: arn44
>     Assignee: Henry Zongaro
>     Priority: Critical
>      Fix For: 2.7
>  Attachments: j2140.patch.txt
>
> Hello, 
> I have a problem with a stylesheet containing a xsl:key. 
> I have the impression that the  Transformer object guard into memory 
> preceding xml source.
> Here a testcase to reproduce the problem.
> The first transformation and the third should produce the same thing. 
> It is true with Xalan interpretive.
> It is not the case in xsltc.
> _________________________
> package test;
> import junit.framework.TestCase;
> import java.io.ByteArrayOutputStream;
> import java.io.File;
> import java.util.Properties;
> import javax.xml.transform.Source;
> import javax.xml.transform.Transformer;
> import javax.xml.transform.TransformerFactory;
> import javax.xml.transform.stream.StreamResult;
> import javax.xml.transform.stream.StreamSource;
> public class XSLTTest extends TestCase {
>     public XSLTTest(String arg0) {
>         super(arg0);
>     }
>     public void testKey() throws Exception {
>         String key = "javax.xml.transform.TransformerFactory";
>         String value = "org.apache.xalan.xsltc.trax.TransformerFactoryImpl";
>         Properties props = System.getProperties();
>         props.put(key, value);
>         System.setProperties(props);
>         TransformerFactory tFactory = TransformerFactory.newInstance();
>         String xsl = getClass().getResource("test.xsl").getPath();
>         //1 transformation
>         Source xml = new StreamSource(new File(getClass()
>                                                    .getResource("habP1.xml")
>                                                    .getPath()));        
>         ByteArrayOutputStream out = new ByteArrayOutputStream();
>         Transformer transformer = tFactory.newTransformer(new 
> StreamSource(xsl));
>         transformer.transform(xml, new StreamResult(out));
>         System.out.println(out.toString());
>         //2 transformation
>         xml = new StreamSource(new File(getClass().getResource("habP0.xml")
>                                             .getPath()));
>         ByteArrayOutputStream out2 = new ByteArrayOutputStream();
>         transformer.transform(xml, new StreamResult(out2));
>         System.out.println(out2.toString());
>         //3 transformation
>         xml = new StreamSource(new File(getClass().getResource("habP1.xml")
>                                             .getPath()));
>         ByteArrayOutputStream out3 = new ByteArrayOutputStream();
>         transformer.transform(xml, new StreamResult(out3));
>         System.out.println(out3.toString());
>         assertEquals(out.toString(),out3.toString());
>     }
> }
> --------test.xsl----------------------
> <?xml version="1.0"?>
> <xsl:stylesheet version="1.0" 
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
>     <xsl:output method="text" encoding="ISO-8859-1" indent="yes"  />
> <xsl:key name="clef_habilitations" match ="action" use = "nom"  />
>       <xsl:template match="/">        
>               
> -<xsl:value-of select="key('clef_habilitations','nom1')/nom" />-
> -<xsl:value-of select="key('clef_habilitations','nom2')/nom" />-
>       </xsl:template>
> </xsl:stylesheet>
> ---------habP0.xml------------------------
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <habilitation>
>               <action>
>                       <nom>nom1</nom>
>               </action>
>               <action>
>                       <nom>nom2</nom>
>               </action>
>               <action>
>                       <nom>nom3</nom>
>               </action>
>               <action>
>                       <nom>nom4</nom>
>               </action>               
>       
>       </habilitation>
> ------------habP1.xml--------------
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <habilitation>
>               <action>
>                       <nom>nom1</nom>
>               </action>
>               <action>
>                       <nom>nom3</nom>
>               </action>
>               <action>
>                       <nom>nom4</nom>
>               </action>
>               
>       
>       </habilitation>
> ----------System.out---------------------
>               
> -nom1-
> --
>       
>       
>               
> -nom1-
> -nom2-
>       
>       
>               
> -nom1-
> -nom3-
>       

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to