You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Robin Green <gr...@hotmail.com> on 2000/08/15 21:36:41 UTC
[PATCH] Bugfix for document() function when called from Cocoon
I'm crossposting this to the cocoon-users list as some people have reported
problems using document() in Cocoon (can't remember what they were), and I
thought this might be related. (I realise this or similar problems may have
been posted hundreds of times to xalan-dev, but since the web mailing list
archive is still down, I can't tell.)
Here is a simple patch for a problem I encountered trying to insert another
xml file from within a Producer in Cocoon. The Producer calls Xalan, and the
XSLT sheet contains a line as follows:
...
<xsl:copy-of select="document(.)"/>
...
First some details of the problem. It wasn't inserting from an absolute file
URL, so I modified FuncDocument to print a stack trace, and got a
StackUnderflowException in org.apache.xalan.xslt.StylesheetHandler. Checking
for an empty stack fixed the problem. I don't understand what was going on,
but the fix works4me.
My config is:
Cocoon 1.8 latest CVS
xalan_1_2_D01
xerces_1_1_2
Sun JDK1.2.2_6 for Linux
and I'm using org.apache.cocoon.transformer.XalanTransformer as my interface
to Xalan. The file I'm inserting is
<?xml version="1.0"?>
<cms:part type="common"
xmlns:cms="http://www.i-tao.com/xmlns/cms"
xmlns:i-tao="http://www.i-tao.com/xmlns/i-tao-utils">
<i-tao:default-title/>
<menubar>
<link href="search.xml">Home</link>
<link href="search.xml">Search</link>
<link href="profilelondon.html">Profile</link>
<link href="contactus.xml">Contact us</link>
<link href="regoption.xml">Register</link>
<link href="products.xml?categoryid=11">Special Offers</link>
<link href="products.xml?categoryid=8">New Products</link>
<link href="products.xml?categoryid=6">Last-minute Purchases</link>
</menubar>
</cms:part>
Here is the patch
--- src/org/apache/xalan/xslt/StylesheetHandler.java Tue Aug 15 19:14:04
2000
+++ src/org/apache/xalan/xslt/StylesheetHandler.java.new Tue Aug 15
19:13:50 2000
@@ -1077,7 +1077,8 @@
// now we have to look up the stack...
if(null == nsh)
{
- ElemTemplateElement parent =
(ElemTemplateElement)m_elems.peek();
+ ElemTemplateElement parent =
+ (m_elems.empty () ? null :
(ElemTemplateElement)m_elems.peek());
while(null != parent)
{
int tok = parent.getXSLToken();
--
Robin Green
i-tao Ltd.
4 Skyline Village
Limeharbour
London E14 9TS
United Kingdom
Phone +44 20 7537 2233 Fax +44 70 8081 5118
http://www.i-tao.com
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com