Subject: RE: [xsl] Slow XSLT From: Cleyton Jordan <cleytonjordan@xxxxxxxxxxx> Date: Thu, 13 Mar 2008 11:09:54 +0000 (GMT) |
Hi Michael and David, I would like to thank you for all your input and help. It is really appreciated. I will try to use the the vanilla push-processing coding style demonstrated by David Carlisle's responses to improve the speed of my transformation for the rows. Michael, you are right I was typing everything using the browser and made lots of mistake in my code examples. I am sorry about that. David, thanks again for your example code. Just for completeness, this an extract of my xml but well formatted. The Rows and Columns can grow a lot: <?xml version="1.0"?> <Report> <Measures> <Measure idx="1" heading="Total Pages"/> <Measure idx="2" heading="Cost"/> </Measures> <Columns> <ColGrp heading="Year"> <Col heading="2003"/> <Col heading="2004"/> </ColGrp> </Columns> <Rows> <RowGrp heading="Name 1"> <Row heading="A"> <Cell/> <Cell> <Msr idx="1" val="42.00"/> <Msr idx="2" val="64230"/> </Cell> </Row> <Row heading="Other"> <Cell/> <Cell> <Msr idx="1" val="36.00"/> <Msr idx="2" val="35820"/> </Cell> </Row> <Row heading="Another"> <Cell> <Msr idx="1" val="14.20"/> <Msr idx="2" val="128030"/> </Cell> <Cell/> </Row> </RowGrp> <RowGrp heading=""> <Row heading="Totals"> <Cell> <Msr idx="1" val="14.20"/> <Msr idx="2" val="128030.00"/> </Cell> <Cell> <Msr idx="1" val="78.00"/> <Msr idx="2" val="100050.00"/> </Cell> </Row> </RowGrp> </Rows> </Report> --- Michael Kay <mike@xxxxxxxxxxxx> wrote: > > > > 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/ > > ___________________________________________________________ Win a BlackBerry device from O2 with Yahoo!. Enter now. http://www.yahoo.co.uk/blackberry
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Slow XSLT, Michael Kay | Thread | RE: [xsl] Slow XSLT, Cleyton Jordan |
Re: [xsl] How do I avoid NaN (Simp, David Carlisle | Date | Re: [xsl] Manipulating elements dep, Adil Ladhani |
Month |