xsl-list
[Top] [All Lists]

RE: [xsl] Slow XSLT

2008-03-13 03:29:13

For each Row in my xml I need to output a <tr>. So I apply templates. 

<xsl:variable name=set" select="Report/Rows//Row" /> .....
 <xsl:apply-templates select="$set"/>

If you're only using the variable once, then this is exactly equivalent to:

<xsl:apply-templates select="Report/Rows//Row"/> .....

That doesn't mean it's wrong to declare a variable and use it only once, I'm
just pointing out the equivalence. Your arguments that you are using a
variable because of the intervening RowGrp elements don't make sense -
that's an argument for using "//" in the middle of this path, but not an
argument for using a variable.


<xsl:template name="Row">
......
<tr>
 <xsl:param name="set"/>
  <xsl:apply-templates select="$set[postion()]/*"/> 
  </tr> 
<xsl:template>

There are a couple of syntax errors here, and a couple of semantic errors. 

1. If xsl:param appears in an xsl:template, then it must come first

2. postion() should be position()

3. as already pointed out, the predicate [position()] is legal but
meaningless

4. (and I suspect this is the root cause of your confusion), you're
declaring a parameter $set, and not giving it a value. The $set inside your
template bears no relationship to the $set in the calling code, they are two
different variables that just happen to have the same name. You could give
them the same value if the caller did <xsl:with-param name="set"
select="$set"/>, but I can't see why you would want to. If you don't give
the parameter a value, then the default is a zero-length string, and I would
expect that to cause a type error when you do apply-templates, on the
grounds that you can only apply templates to nodes, not to strings.

I haven't seen anything in your problem description that indicates why you
need to make things so complicated. Perhaps I've missed something - you keep
hinting that you haven't shown us the whole problem. From all I've seen, you
can solve the problem using the vanilla push-processing coding style
demonstrated by David Carlisle's responses.

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


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>