You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Gary L Peskin <ga...@firstech.com> on 2001/02/13 02:08:54 UTC

Re: SAX Exception using the Xalan processor when disabling cookies on the browser

> Nicole Henrich wrote:
> 
> I'm using the Xalan XSLTProcessor to generate html from a XML and a
> XSL file.
> 
> Here is the source code:
> 
>   XSLTProcessor processor = XSLTProcessorFactory.getProcessor();
>   StringReader xmlSource =
> compositeManager.outputXml().toStringReader();
>   String xslFile = "file:C:/xsl/toto.xsl";
>   StringWriter htmlSource = new StringWriter();
>   XSLTInputSource inputXml = new XSLTInputSource(xmlSource);
>   XSLTInputSource inputXsl = new XSLTInputSource(xslFile);
>   XSLTResultTarget resultTarget = new XSLTResultTarget(htmlSource);
>   processor.process(inputXml, inputXsl, resultTarget);
> 
> where compositeManager.outputXml().toStringReader() creates a
> StringReader
> containing the XML code.
> 
> This code works well if I allow cookies in my browser. Else it
> generates the following SAX Exception :
>     The entity name must immediately follow the '&' in the entity
> reference.
> 
> But if the XML file physically exists on the server and the associated
> XSLTInputSource is created
> with the location of this file, it works even without cookies:
> 
>   XSLTProcessor processor = XSLTProcessorFactory.getProcessor();
>   String xmlFile = "file:C:/xml/toto.xml";
>   String xslFile = "file:C:/xsl/toto.xsl";
>   StringWriter htmlSource = new StringWriter();
>   XSLTInputSource inputXml = new XSLTInputSource(xmlFile);
>   XSLTInputSource inputXsl = new XSLTInputSource(xslFile);
>   XSLTResultTarget resultTarget = new XSLTResultTarget(htmlSource);
>   processor.process(inputXml, inputXsl, resultTarget);
> 
> The problem is, I have to generate one XML for each page and for each
> client, because it contains
> dynamical data specific to each client, and I would like to make it
> working even without cookies.
> But it seems the processor uses the session information to associate
> each xml with its client.
> 
> It there a solution to this problem ? Thank you very much for your
> help.

Nicole --

I can't really tell exactly what's going on from the information that
you supplied. However, it sounds like you're using some kind of a
servlet engine and that the sample code that you supplied is inside a
servlet.  Does that sound right?

Then, from the fact that things behave differently with or without
cookies, I'd guess that your servlet engine is trying to preserve
session information with URL rewriting when cookies are not available. 
It seems like it's inserting the session information into the rewritten
URL and using & to separate the parameters.  Xalan is getting confused
because the XML standard requires an entity to following the &.  If the
servlet engine wants an &, it should be writing &amp;

If we saw the stack trace that you're receiving, we could probably
identify the problem better.  In the meantime, is there a way to disable
the session info and/or rewrite the URL in an XML compliant fashion?

Gary