Return-Path: Delivered-To: apmail-cocoon-dev-archive@www.apache.org Received: (qmail 62872 invoked from network); 16 Jun 2008 19:01:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 16 Jun 2008 19:01:22 -0000 Received: (qmail 85752 invoked by uid 500); 16 Jun 2008 19:01:23 -0000 Delivered-To: apmail-cocoon-dev-archive@cocoon.apache.org Received: (qmail 85663 invoked by uid 500); 16 Jun 2008 19:01:23 -0000 Mailing-List: contact dev-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@cocoon.apache.org List-Id: Delivered-To: mailing list dev@cocoon.apache.org Received: (qmail 85652 invoked by uid 99); 16 Jun 2008 19:01:23 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 16 Jun 2008 12:01:23 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [212.85.125.162] (HELO v007528.home.net.pl) (212.85.125.162) by apache.org (qpsmtpd/0.29) with SMTP; Mon, 16 Jun 2008 19:00:31 +0000 Received: from host-87-99-3-122.lanet.net.pl (HELO ?192.168.1.5?) (lgawron.mobilebox@home@87.99.3.122) by m029.home.net.pl with SMTP; Mon, 16 Jun 2008 19:00:45 -0000 Message-ID: <4856B857.3040607@mobilebox.pl> Date: Mon, 16 Jun 2008 21:00:39 +0200 From: Leszek Gawron User-Agent: Thunderbird 2.0.0.14 (Windows/20080421) MIME-Version: 1.0 To: dev@cocoon.apache.org Subject: Re: jx:element patch References: <4853B69C.1040401@tt.com.au> <48568FEA.9070307@tuffmail.com> In-Reply-To: <48568FEA.9070307@tuffmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Grzegorz Kossakowski wrote: > Kamal pisze: >> Hi, >> I am responsible for JIRA issue 2211, including the associated patch. >> I will be honest, I didn't really understand what I did. > > If your patch is a result of random typing then I'm truly impressed. ;-) > >> I knew enough to test it and make sure it worked, but there are some >> points I would like to clarify: >> >> Firstly, I was looking at the code for jx:attribute, in particular this: >> >> final Attributes EMPTY_ATTRS = new AttributesImpl(); >> String elementName = "attribute"; >> >> TextSerializer serializer = new TextSerializer(); >> StringWriter writer = new StringWriter(); >> serializer.setOutputCharStream(writer); >> >> ContentHandlerWrapper contentHandler = new >> ContentHandlerWrapper(serializer, serializer); >> contentHandler.startDocument(); >> >> contentHandler.startElement(JXTemplateGenerator.NS, elementName, >> elementName, EMPTY_ATTRS); >> Invoker.execute(contentHandler, objectModel, executionContext, >> macroContext, namespaces, this.getNext(), this.getEndInstruction()); >> contentHandler.endElement(JXTemplateGenerator.NS, elementName, >> elementName); >> contentHandler.endDocument(); >> valueStr = writer.toString(); >> Am I right in saying that the text serializer is what ensures that XML >> ouput is not serialized in the attributes? I looked at the javadoc for >> TextSerializer and found little useful information. > > Yep, I guess that TextSerializer implements text output method described > for XSLT, see[2]. It means > that will evaluate it's content (descendant elements) and > will pull only text result > of this evaluation. This enables one to use for example macros to > generate the value of attribute. > >> I noticed that there is very little validation for jx:attribute. You >> can put in any old value for an attribute name, including invalid >> values such as values with spaces and colons (':') in them. I took a >> very different approach for jx:element and tested that the prefix and >> name are valid. > > Obviously, your approach is much, much better. I appreciate your > attention to details. > >> Is there are reason why jx:attribute does not check that the name is a >> correct name? > > I think the only reason is that original authors forgot about > implementing these checks. Are you a > volunteer to fix that? :) > >> Also, in xsp:element, apparently[1], you could not specify a namespace >> without a prefix and visa versa. I chose to relax this to just not >> allowing a prefix without a namespace. Is this right? > > To be honest, I don't remember why such a rule has been established. > Could anyone comment? It should be totally ok to declare a namespace without a prefix[1]: Cheaper by the Dozen 1568491379

This is a funny book!

[1] http://www.w3.org/TR/REC-xml-names/#defaulting -- Leszek Gawron http://www.mobilebox.pl/krs.html CTO at MobileBox Ltd.