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 2000/12/05 09:59:14 UTC

Re: Compiling via TemplateList

Joseph_Kesselman@lotus.com wrote:
> 
> >I'll whip something together in the next few hours and let you know when
> >it's out there.
> 
> Many thanks, sir.

Joe --

I've run into a snag.  The problem is in the replaceLastElement() method
of the extended Enumerator.  I'm really unable to replace the last
element returned with the CompiledTemplate because of the way
TemplateList is organized.  Since the template lists are anchored in a
Hashtable, if I try to accomplish the replace via a remove() and a
put(), I could screw up the underlying Enumerator that I'm using to
iterate through the Hashtable.  I don't know of a way to replace the
Hashtable element directly.

So, I think what has to happen is that the extended Enumerator would
have a next() method that would return each template in the composed
stylesheet.  The compiler would have to call this method until it
returned null, signifying there were no more templates.  After compiling
each template returned from next(), it would have to add the resulting
CompiledTemplate to a new TemplateList.  Then, when that was finished,
it would have to call compose() on the new TemplateList and then replace
m_templateList in StylesheetRoot with the new TemplateList.

This is definitely not as nice as just being able to call
replaceLastElement() but I don't see a way around it.  I could move this
functionality into the extended enumerator and trigger it when the
next() method reaches the last element but that seems ugly as well.

So, the code in the compiler would look something like this:

  ElemTemplate et;
  StylesheetRoot root = ...;
  TemplateList newTl = new TemplateList();
  TemplateList.TemplateWalker tw =
root.getTemplateListComposed().getWalker();
  while ( null != (et = tw.next()) )
  {
    CompiledTemplate ct = compileTemplate(et);
    newTl.setTemplate(ct);
  }
  newTl.compose();
  root.setTemplateListComposed(newTl);

What do you think?

Gary

How to retrieve the position of the parent node. (my example and question)

Posted by Krzysztof Zielinski <KZ...@supermedia.pl>.
Hi.

I have to retrieve the position of the parent node in section
 <xsl:template match="">...
The easiest way should be use function position() eg:
<xsl:value-of select="../position()"/>
This doesn't work.

I have made a work around and I retrieve the position of parent node in this
way
<xsl:value-of select="count(../preceding-sibling::node())+1"/>
It works.

I think it isn't nice.
Function position() should be changed to be possible make eg:
<xsl:value-of select="../position()"/>

I have attached an example.

Regards,
Krzysztof Zielinski
Web Application developer
kzielinski@supermedia.pl