You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xsp-dev@xml.apache.org by "H. Whitlock" <wh...@UMDNJ.EDU> on 2002/04/05 20:26:53 UTC

this list --was Xsp w/out Cocoon

I'm just happy to see folks talking a bit on this list and hope you keep it
up. I used CocoonI as a basic transformation engine and am I'm only just
starting out with XSP and Cocoon2. I've gotten a good strong grip on the
site map (and it isn't so bad even for a clueless newbie). However, I wish I
had some more solid *working* examples in XSP from which to work.

Keep chatting so I can keep lurking!

Hat


Re: namespace dispatch

Posted by Matt Sergeant <ma...@sergeant.org>.
On Sunday 07 April 2002 3:11 pm, Ulrich Mayring wrote:
> Matt Sergeant wrote:
> > The XSP spec? ;-)
>
> Sorry, didn't want to be mean ;-)

It's not mean - we really aught to write one ;-)

> > Can you think of a use case for where an XSP taglib might be interested
> > in child tags that aren't expressions? I can't, but then again I'm used
> > to writing them without such an option.
>
> I'm not sure what you mean by "child tags that aren't expressions".

Well take for example in esql, you have:

  <esql:param>...</esql:param>

well that's fine as:

  <esql:param><param:foo/></esql:param>

(using AxKit's Param taglib, which puts the querystring/form param named "foo" 
there)

But it makes no sense as:

  <esql:param><b>Something in bold</b></esql:param>

Makes more sense now?

In AxKit's SAX parser sense this is really easy to understand - it's simply 
the difference between being in the taglib parser (i.e. you're seeing a 
registered namespace), or being in the "default" parser - which is used to 
build up the output.

> Also, I'm not sure if "use cases" is the appropriate term here, perhaps
> "problem cases" is a better term.

Fair point :-)

> If we support XSLT/XPATH, then someone
> is going to write a template that refers to its children or another part
> of the document entirely.

Such people deserve to be programming lisp ;-)

> Now, we can say that guy is dumb and shouldn't
> do it, but he will say we are dumb if we don't handle that in a uniform
> way :)

Hmm, well I guess that's why you do Java and I do Perl. I say we give users a 
powerful tool, and if they chop off their foot they should have been more 
careful.

> I think the case we're talking about here is actually a special case of
> a more general problem: what if we do SAX processing and someone writes
> an XSLT template with an XPATH that points to God-Knows-Where? Xalan has
> a feature called "incremental processing", which means on forward
> references it waits until all elements are there - although I don't
> understand how that can resolve backwards references. XSLTC uses a type
> of DOM, so no problems there. What does Perl's XSLT processor do in this
> regard?

I don't think there are any perl XSLT modules that support incremental 
processing yet (unless Xalan-C does) - but then given that MS XML and libxslt 
both kick all Java XSLT engines' butts, it's not that much of an issue (XSLTC 
perhaps excepted, but we haven't seen any published benchmarks with that 
yet).

-- 
<:->get a SMart net</:->

Re: namespace dispatch

Posted by Ulrich Mayring <ul...@mayring.de>.
Matt Sergeant wrote:
> 
> The XSP spec? ;-)

Sorry, didn't want to be mean ;-)

> Can you think of a use case for where an XSP taglib might be interested in
> child tags that aren't expressions? I can't, but then again I'm used to
> writing them without such an option.

I'm not sure what you mean by "child tags that aren't expressions".
Also, I'm not sure if "use cases" is the appropriate term here, perhaps
"problem cases" is a better term. If we support XSLT/XPATH, then someone
is going to write a template that refers to its children or another part
of the document entirely. Now, we can say that guy is dumb and shouldn't
do it, but he will say we are dumb if we don't handle that in a uniform
way :)

I think the case we're talking about here is actually a special case of
a more general problem: what if we do SAX processing and someone writes
an XSLT template with an XPATH that points to God-Knows-Where? Xalan has
a feature called "incremental processing", which means on forward
references it waits until all elements are there - although I don't
understand how that can resolve backwards references. XSLTC uses a type
of DOM, so no problems there. What does Perl's XSLT processor do in this regard?

cheers,

Ulrich

Re: namespace dispatch

Posted by Matt Sergeant <ma...@sergeant.org>.
On Sunday 07 April 2002 2:00 pm, Ulrich Mayring wrote:
> Matt Sergeant wrote:
> > t1 should never know about child elements - that's simply wrong-think. If
> > it takes some form of parameters it should only know about those
> > parameters, and XSP should only send parameters to a taglib when they are
> > actual expressions - otherwise you've just got plain output, which really
> > should never be seen by a taglib whatsoever.
>
> Does the XSP spec say anything in this regard? I think not, but perhaps
> it should. If two different semantics are possible, then there should be
> a tag or something that specifies which semantic is to be used in
> processing.

The XSP spec? ;-)

Can you think of a use case for where an XSP taglib might be interested in 
child tags that aren't expressions? I can't, but then again I'm used to 
writing them without such an option.

-- 
<:->get a SMart net</:->

Re: namespace dispatch

Posted by Ulrich Mayring <ul...@mayring.de>.
Matt Sergeant wrote:
> 
> t1 should never know about child elements - that's simply wrong-think. If it
> takes some form of parameters it should only know about those parameters, and
> XSP should only send parameters to a taglib when they are actual expressions
> - otherwise you've just got plain output, which really should never be seen
> by a taglib whatsoever.

Does the XSP spec say anything in this regard? I think not, but perhaps
it should. If two different semantics are possible, then there should be
a tag or something that specifies which semantic is to be used in processing.

cheers,

Ulrich

Re: this list --was Xsp w/out Cocoon

Posted by Matt Sergeant <ma...@sergeant.org>.
On Saturday 06 April 2002 9:37 pm, Ulrich Mayring wrote:
> Matt Sergeant wrote:
> > > startElement("foo") ==> t1 handler
> > > startElement("bar") ==> t2 handler
> > > endElement("bar") ==> t2 handler
> > > endElement("foo") ==> t1 handler
> >
> > Right. This is how it works.
> >
> > > But this way the t1 handler cannot know if the <t1:foo> element is
> > > empty or not.
> >
> > Why would it care? It all just DWIMs (Do What I Mean). In fact I would
> > consider it a HORRIBLE design error if t1 knew anything whatsoever about
> > t2 there.
>
> Yes, I absolutely agree that t1 shouldn't know about t2. But the
> question here is, should t1 know whether it has any children or not.
> Consider this template rule in t1:
>
> <xsl:template match="t1:foo">
> 	<xsl:if test="count(*) > 0">
> 		<yay/>
> 	</xsl:if>
> </xsl:template>
>
> Obviously, with namespace dispatch there will never be a <yay/> in the
> output, whereas with traditional processing there will be. However,
> different implementations of the same spec should produce the same result.

t1 should never know about child elements - that's simply wrong-think. If it 
takes some form of parameters it should only know about those parameters, and 
XSP should only send parameters to a taglib when they are actual expressions 
- otherwise you've just got plain output, which really should never be seen 
by a taglib whatsoever.

-- 
<:->get a SMart net</:->

Re: this list --was Xsp w/out Cocoon

Posted by Ulrich Mayring <ul...@mayring.de>.
Matt Sergeant wrote:
> 
> > startElement("foo") ==> t1 handler
> > startElement("bar") ==> t2 handler
> > endElement("bar") ==> t2 handler
> > endElement("foo") ==> t1 handler
> 
> Right. This is how it works.
> 
> > But this way the t1 handler cannot know if the <t1:foo> element is empty
> > or not.
> 
> Why would it care? It all just DWIMs (Do What I Mean). In fact I would
> consider it a HORRIBLE design error if t1 knew anything whatsoever about
> t2 there.

Yes, I absolutely agree that t1 shouldn't know about t2. But the
question here is, should t1 know whether it has any children or not.
Consider this template rule in t1:

<xsl:template match="t1:foo">
	<xsl:if test="count(*) > 0">
		<yay/>
	</xsl:if>
</xsl:template>

Obviously, with namespace dispatch there will never be a <yay/> in the
output, whereas with traditional processing there will be. However,
different implementations of the same spec should produce the same result.

> Invented for AxKit. I actually think it was a totally unique design
> pattern, as in all my time with XML, including talking to some rather
> large companies, I've never seen anyone else using it, and everyone I
> explain it to kinda goes "Wow, that's really useful". I probably should
> have patented it and retired on my millions of dollars ;-)

It is an interesting concept. I'll send you a couple million as soon as
it makes me rich :-)

Ulrich

Re: this list --was Xsp w/out Cocoon

Posted by Matt Sergeant <ma...@sergeant.org>.
On Sat, 6 Apr 2002, Ulrich Mayring wrote:

> Matt Sergeant wrote:
> >
> > You can also define your taglib as a pure SAX handler, and we use
> > namespace dispatch during the parse to send only the relevant tags to your
> > SAX handler - this makes it faster than a regular SAX filter approach.
>
> Now, this is an interesting idea. But what about this:
>
> <t1:foo><t2:bar/></t1:foo>
>
> You send the whole thing to the t1 handler.

No, see below.

> The t1 handler has to know
> about the t2 handler (and all other handlers)

Why? Taglibs need to know zip about each other.

>, this seems a bit
> complicated to synch. Or do you mean something like this:
>
> startElement("foo") ==> t1 handler
> startElement("bar") ==> t2 handler
> endElement("bar") ==> t2 handler
> endElement("foo") ==> t1 handler

Right. This is how it works.

> But this way the t1 handler cannot know if the <t1:foo> element is empty
> or not.

Why would it care? It all just DWIMs (Do What I Mean). In fact I would
consider it a HORRIBLE design error if t1 knew anything whatsoever about
t2 there.

> Would that be a feature or a mis-feature? :)

A feature.

> By the way: you talk about "namespace dispatch", is that some kind of a
> SAX function or did you invent that yourself for Axkit?

Invented for AxKit. I actually think it was a totally unique design
pattern, as in all my time with XML, including talking to some rather
large companies, I've never seen anyone else using it, and everyone I
explain it to kinda goes "Wow, that's really useful". I probably should
have patented it and retired on my millions of dollars ;-)

-- 
<!-- Matt -->
<:->Get a smart net</:->


Re: this list --was Xsp w/out Cocoon

Posted by Ulrich Mayring <ul...@mayring.de>.
Matt Sergeant wrote:
> 
> You can also define your taglib as a pure SAX handler, and we use
> namespace dispatch during the parse to send only the relevant tags to your
> SAX handler - this makes it faster than a regular SAX filter approach.

Now, this is an interesting idea. But what about this:

<t1:foo><t2:bar/></t1:foo>

You send the whole thing to the t1 handler. The t1 handler has to know
about the t2 handler (and all other handlers), this seems a bit
complicated to synch. Or do you mean something like this:

startElement("foo") ==> t1 handler
startElement("bar") ==> t2 handler
endElement("bar") ==> t2 handler
endElement("foo") ==> t1 handler

But this way the t1 handler cannot know if the <t1:foo> element is empty
or not. Would that be a feature or a mis-feature? :)

By the way: you talk about "namespace dispatch", is that some kind of a
SAX function or did you invent that yourself for Axkit?

cheers,

Ulrich

Re: this list --was Xsp w/out Cocoon

Posted by Matt Sergeant <ma...@sergeant.org>.
On Sat, 6 Apr 2002, Ulrich Mayring wrote:

> Matt Sergeant wrote:
> >
> >   package MyDateTimeTaglib;
>
> [...]
>
> I see. So Axkit does not define the taglibs in XSLT stylesheets, but in
> Perl code, right? Was there a particular reason why you chose that approach?

Well you can do either. It's just that the XSLT approach is next to
impossible to debug and unit test. Even with SiLLy.

You can also define your taglib as a pure SAX handler, and we use
namespace dispatch during the parse to send only the relevant tags to your
SAX handler - this makes it faster than a regular SAX filter approach.

> > No. That's a very old discussion. Get decent filtering software. If you do
> > that it means the list becomes a black hole, so that nobody from outside
> > can ever participate, which goes against the spirit of openness of the
> > Apache project.
>
> Sorry, I didn't mean to rehash an old discussion. I thought it was a
> mistake, because the other cocoon lists are set up differently. Then
> they should be changed to this "more open" style?

Well in my opinion yes, and I made sure the new AxKit lists were setup
that way. But you get to choose with Apache mailing lists, and I guess
whoever chose just doesn't think like me.

> And I am probably expected to reply to the author and cc: the list?

Your choice. Most people don't mind either way - especially with the very
slow Apache mailing list servers - you get replies faster that way.

-- 
<!-- Matt -->
<:->Get a smart net</:->


Re: this list --was Xsp w/out Cocoon

Posted by Ulrich Mayring <ul...@mayring.de>.
Matt Sergeant wrote:
> 
>   package MyDateTimeTaglib;

[...]

I see. So Axkit does not define the taglibs in XSLT stylesheets, but in
Perl code, right? Was there a particular reason why you chose that approach?

> No. That's a very old discussion. Get decent filtering software. If you do
> that it means the list becomes a black hole, so that nobody from outside
> can ever participate, which goes against the spirit of openness of the
> Apache project.

Sorry, I didn't mean to rehash an old discussion. I thought it was a
mistake, because the other cocoon lists are set up differently. Then
they should be changed to this "more open" style?

And I am probably expected to reply to the author and cc: the list?

cheers,

Ulrich

Re: this list --was Xsp w/out Cocoon

Posted by Matt Sergeant <ma...@sergeant.org>.
On Fri, 5 Apr 2002, Ulrich Mayring wrote:

> Matt Sergeant wrote:
> >
> > The only problem with this is that XSP is cross platform, and I bet you'd all
> > sniff at seeing Perl examples (especially once we show you how easy taglibs
> > are in perl :-).
>
> I've never seen *anything* that was easy to read in Perl, but if you say
> taglibs are easier than in Java, then at least I want to see it! ;-)
>
> And, this being an XSP-list, it can't possibly be off-topic.

Fine, so write your taglib in Java (you just need the stub in Perl).
Here's an example taglib:

  package MyDateTimeTaglib;

  # derive from TaglibHelper
  use base qw(Apache::AxKit::Language::XSP::TaglibHelper);

  # define the namespace
  $NS = 'http://axkit.org/example/datetime';

  # spec the taglib functions
  @EXPORT_TAGLIB = ( 'now()' );

  # define the functions
  sub now {
      return scalar localtime;
  }

Now if you wanted to use Java, the following should work in place of "sub
now":

use Inline Java => <<'END';
class SomeClass {
  public SomeClass() {
  }
  ...
}
END

sub now {
  my $some = new SomeClass();
  return $some->someMethodInJava();
}

Now I left out java code because it's been 3 years since I wrote any Java.
But you get the idea - in AxKit XSP taglibs can be simply Perl classes,
decorated with an @EXPORT_TAGLIB to allow them to function as taglibs. The
beauty of this is you can write standard Perl regression test suites with
the classes, and test them in the normal way. Or use the same class
outside of your XSP page, in another application.

Nice, clean and simple.

> Another note: perhaps the reply-to address for this list could be set to
> this list instead of to the sender, like it is in the other Cocoon lists?

No. That's a very old discussion. Get decent filtering software. If you do
that it means the list becomes a black hole, so that nobody from outside
can ever participate, which goes against the spirit of openness of the
Apache project.

-- 
<!-- Matt -->
<:->Get a smart net</:->


Re: this list --was Xsp w/out Cocoon

Posted by Ulrich Mayring <ul...@mayring.de>.
Matt Sergeant wrote:
> 
> The only problem with this is that XSP is cross platform, and I bet you'd all
> sniff at seeing Perl examples (especially once we show you how easy taglibs
> are in perl :-).

I've never seen *anything* that was easy to read in Perl, but if you say
taglibs are easier than in Java, then at least I want to see it! ;-)

And, this being an XSP-list, it can't possibly be off-topic.

Another note: perhaps the reply-to address for this list could be set to
this list instead of to the sender, like it is in the other Cocoon lists?

cheers,

Ulrich

Re: this list --was Xsp w/out Cocoon

Posted by Matt Sergeant <ma...@sergeant.org>.
On Friday 05 April 2002 7:26 pm, H. Whitlock wrote:
> I'm just happy to see folks talking a bit on this list and hope you keep it
> up. I used CocoonI as a basic transformation engine and am I'm only just
> starting out with XSP and Cocoon2. I've gotten a good strong grip on the
> site map (and it isn't so bad even for a clueless newbie). However, I wish
> I had some more solid *working* examples in XSP from which to work.
>
> Keep chatting so I can keep lurking!

The only problem with this is that XSP is cross platform, and I bet you'd all 
sniff at seeing Perl examples (especially once we show you how easy taglibs 
are in perl :-).

Matt.

Re: this list --was Xsp w/out Cocoon

Posted by Ulrich Mayring <ul...@mayring.de>.
"H. Whitlock" wrote:
> 
> However, I wish I
> had some more solid *working* examples in XSP from which to work.

What exactly are you after?

cheers,

Ulrich