Return-Path: Delivered-To: apmail-xml-cocoon-dev-archive@xml.apache.org Received: (qmail 48449 invoked by uid 500); 10 Sep 2002 15:15:53 -0000 Mailing-List: contact cocoon-dev-help@xml.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: cocoon-dev@xml.apache.org Delivered-To: mailing list cocoon-dev@xml.apache.org Received: (qmail 48431 invoked from network); 10 Sep 2002 15:15:53 -0000 Message-ID: <3D7E0CD8.3030308@alma.nu> Date: Tue, 10 Sep 2002 17:16:40 +0200 From: =?ISO-8859-1?Q?Per-Olof_Nor=E9n?= Reply-To: per-olof.noren@alma.nu User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0rc2) Gecko/20020510 X-Accept-Language: en-us, en MIME-Version: 1.0 To: cocoon-dev@xml.apache.org Subject: Re: XSP bug: can get generate() to skip elements using java 'if's References: Content-Type: multipart/mixed; boundary="------------000000070101000807060206" X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N --------------000000070101000807060206 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Hi per and Michael, I had to end the logic tag to make theese sort of things work: if (!request.isUserInRole("root")) { Not authorized } As I figured it�s like <% in asp. You�re in different "modes" when in logic element and outside. Attached is a real-life example (with for loops, not if statements, but the behaviour is probably the same) that is used from a flowscript to generate a "datePicker" calendar. Regards, Per-Olof Noren < >> >> >> >> if (!request.isUserInRole("root")) >> { >> Not authorized >> } >> else >> { >> >> >> >> >> >> >> } >> >> >> >> Per Kreipke wrote: > Michael, > > Thanks for the tip. However, your tip makes the problem even more > interesting. > > When the 'if' statement is true, the does appear on the > toplevel element and the XML is valid (no more array bounds exception). > > But when the 'if' statement is false, the element isn't the top most, > it's emitted after the element. E.g. is a sibling of the > element and the XML has _two_ top level elements, also invalid. > > Per > > >>-----Original Message----- >>From: Enke, Michael [mailto:michael.enke@wincor-nixdorf.com] >>Sent: Tuesday, September 10, 2002 2:58 AM >>To: cocoon-dev@xml.apache.org >>Subject: Re: XSP bug: can get generate() to skip elements using java >>'if's >> >> >>Per Kreipke wrote: >> >>>The following XSP snippet will cause an >> >>ArrayIndexOutOfBoundsException in >> >>>Cocoon 2.0.3 because the start of the outer element is never >> >>emitted to the >> >>>SAX stream. >>> >>>XSP Snippet: >> >> >>I would always write it as: >> >> >> >> >> >> if (!request.isUserInRole("root")) >> { >> Not authorized >> } >> else >> { >> >> >> >> >> >> >> } >> >> >> >> >> >>note: replaced by >>and replaced by >> >>Michael >> >>--------------------------------------------------------------------- >>To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org >>For additional commands, email: cocoon-dev-help@xml.apache.org >> >> > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org > For additional commands, email: cocoon-dev-help@xml.apache.org --------------000000070101000807060206 Content-Type: text/xml; name="pickDate.xsp" Content-Transfer-Encoding: 8bit Content-Disposition: inline; filename="pickDate.xsp" java.text.DateFormat java.text.ParseException java.text.SimpleDateFormat java.util.Calendar java.util.Date java.util.GregorianCalendar java.util.Locale V�lj datum Date highlightDate = new Date(); CompiledExpression highlight = jxpathContext.compile("highlight"); Object value = highlight.getValue(jxpathContext); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); try { highlightDate = format.parse((String) value); } catch (Exception e) { System.out.println("Exception during parse"); e.printStackTrace(); highlightDate = new Date(); } Calendar calendar = new GregorianCalendar(); calendar.setFirstDayOfWeek(Calendar.MONDAY); calendar.setMinimalDaysInFirstWeek(1); calendar.setTime(highlightDate); calendar.add(Calendar.MONTH, -1); Date prev = calendar.getTime(); calendar.setTime(highlightDate); calendar.add(Calendar.MONTH, 1); Date next = calendar.getTime(); calendar.setTime(highlightDate); new SimpleDateFormat("MMMMMMMMMMMM").format(highlightDate) calendar.get(Calendar.YEAR) format.format(prev) format.format(next) calendar.setTime(highlightDate); Date theDate = null; int weeks = calendar.getActualMaximum(Calendar.WEEK_OF_MONTH); for (int week = 1; week <= weeks; week++) { calendar.setTime(highlightDate); calendar.set(Calendar.WEEK_OF_MONTH, week); calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); calendar.get(Calendar.WEEK_OF_YEAR) for (int j = 1; j <= 7; j++) { theDate = calendar.getTime(); String a = format.format(theDate); String b = format.format(highlightDate); format.format(theDate) calendar.get(Calendar.DAY_OF_MONTH) a.equalsIgnoreCase(b) calendar.add(Calendar.DAY_OF_WEEK, 1); } } --------------000000070101000807060206 Content-Type: text/plain; charset=us-ascii --------------------------------------------------------------------- To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org For additional commands, email: cocoon-dev-help@xml.apache.org --------------000000070101000807060206--