[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: "re-calling" a template from <a> anchor

Subject: RE: "re-calling" a template from <a> anchor
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 11 May 2007 00:22:28 +0100
RE:  "re-calling" a template from <a> anchor
Actually:

In XSLT 2.0, if you create an element node as part of the sequence
constructor for an attribute node, the elements are atomized. So

<e>
  <xsl:attribute name="n">
    <e>23</e>
  </xsl:attribute>
</e>

generates <e n="23"/> - it's not an error.

In XSLT 1.0, if you do the same thing, it's a recoverable error:
"implementations may either signal the error or ignore the offending nodes".
It's never been clear whether this means "ignore the offending nodes and all
their descendants". So you might get an error, or <e n=""/>, or <e n="23"/>.

I suspect that the error that occurred was due to infinite recursion and not
to creating invalid XML structures, but it's really impossible to know from
the information that was given. In any case, the stylesheet needs a complete
redesign, so the details aren't very relevant.

Michael Kay
http://www.saxonica.com/ 


> -----Original Message-----
> From: bryan rasmussen [mailto:rasmussen.bryan@xxxxxxxxx] 
> Sent: 11 May 2007 00:09
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re:  "re-calling" a template from <a> anchor
> 
> to clarify, I mean that it looks like you are doing wrong the 
> last two things abel suggested you were doing wrong, and I 
> tried to show an example of how it looked like you were doing 
> it wrong.
> 
> Cheers,
> Bryan Rasmussen
> 
> On 5/11/07, bryan rasmussen <rasmussen.bryan@xxxxxxxxx> wrote:
> > I'm thinking it looks like abel's last two suggestion, an unending 
> > recursion with the recursion writing elements inside of elements.
> >
> > the template test writes out an a element with a href attribute.
> >
> > <a href=""></a>
> >
> > but you call it again, in the way you're doing it means you 
> would be 
> > trying to do this:
> >
> > <a href="<a hreff=""></a>"></a>
> >
> > also you are doing it in such a way that it looks like it will keep 
> > calling itself with howmany = 10 after the first time you reach 
> > howmany = 10.
> >
> > You probably need to specify closer what you want, most here could 
> > help you solve these particular problems but without 
> knowing clearly 
> > what you want the solution wouldn't be any big help, I guess.
> >
> > Cheers,
> > Bryan Rasmussen
> > On 5/10/07, Abel Braaksma <abel.online@xxxxxxxxx> wrote:
> > > Vaduvoiu Tiberiu wrote:
> > > > Hi all. Can anyone tell me if it's possible to 
> "re-call" a template from an anchor? something like:
> > > >
> > > > <xsl:template name="test">
> > > >     <xsl:param name="howmany" select="5">
> > > >         <xsl:value-of 
> select="parent/child[position()>$howmany]/>
> > > >                 <a><xsl:attribute 
> name="href"><xsl:call-template 
> > > > name="test"><xsl:with-parameter name=howmany 
> select=10></....</a>
> > > >
> > > > I tried it but I get an Http error 500. So I'm trying 
> to display a 
> > > > fixed number(e.g. 5) of elements and have a link wich 
> when clicked 
> > > > displays the next 5 elements let's say. The only way I 
> figured to 
> > > > do it was to call the same template but I can't make it work. 
> > > > Anyone have any solution? 10x
> > > >
> > >
> > > Not sure what you are trying here. MK already pointed out 
> that you 
> > > may not understand the processing model. You recursively call a 
> > > template to create an attribute, which is fine, but unlikely to 
> > > create what you want (an attribute can't contain an 
> element, which 
> > > is what your code seems to imply...), since your snippet is not 
> > > well-formed XML, or even XSLT, so I can't tell for sure 
> without seeing more.
> > >
> > > Error 500 means: internal error. If you use Cocoon, you should be 
> > > able to find the XSLT error in the logs. My guess is, 
> since you are 
> > > recursively calling a template inside xsl:attribute, that 
> the error 
> > > is something like "can't create element inside an attribute" or 
> > > similar. Or is just says "syntax error"... Or... since this 
> > > recursive loop won't end, it just runs out of stack space.
> > >
> > > Cheers,
> > > -- Abel

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.