Subject: Re: [xsl] Confusing namespaces and xslt From: Paul <pflists@xxxxxxxxx> Date: Thu, 2 Oct 2008 16:34:16 -0400 |
When I added those modes I saw nothing in the output, i.e. it was almost as if the template didn't match. When I removed them then I'd get a match. Thanks for your suggestions. I'm guessing that the second will work better for me since I can't be sure that items in the input xml will always be in the same order. Thanks! On Thu, Oct 2, 2008 at 4:29 PM, David Carlisle <davidc@xxxxxxxxx> wrote: > >> mode="after" don't work for me. > > what did you d these modes, did you get an error (which) or did you get > no error but a result that you didn't want? > > > There are many ways of adding an element depending on what property of > the source you want to trigger the insertion. > > for example you can do it from the parent, add an element after the > first existing child > > <xsl:template match="container"> > <xsl:apply-templates select="*[1]"/> > <tape/> > <xsl:apply-templates select="*[position()!=1]"/> > </xsl:template> > > Or perhaps yu want every box eleemnt to be followed by a tape, so > instead of the above > > > <xsl:template match="box"> > <xsl:copy> > <!-- Everything here (inside <xsl:copy>) only applies to elements --> > <xsl:apply-templates select="@*"/> > <xsl:apply-templates mode="content" select="."/> > <xsl:apply-templates mode="append" select="."/> > </xsl:copy> > <tape/> > </xsl:template> > > > > > > >> <xsl:template mode=content" match="box"> >> <xsl:element name="box"> >> </xsl:attribute name="width">10</xsl:attribute> >> </xsl:attribute name="height">8</xsl:attribute> >> </xsl:element> >> <xsl:element name="tape> >> </xsl:element> >> </xsl:template> >> >> or is there a better way of doing it? One concern is that using the >> above I'm nuking whatever was in box to start with. >> > as above you can just use apply-templates so that box has the normal > processing in addition to adding tape. there's n need to use xsl:element > unless you need to calculate the element name, if you _did_ want to fix > the attributes as in your example I'd do > > > <xsl:template mode=content" match="box"> > <box width="10" height="8"/> > </xsl:element> > </xsl:template> > > > > > > David > > ________________________________________________________________________ > The Numerical Algorithms Group Ltd is a company registered in England > and Wales with company number 1249803. The registered office is: > Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom. > > This e-mail has been scanned for all viruses by Star. The service is > powered by MessageLabs. > ________________________________________________________________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Confusing namespaces and , David Carlisle | Thread | Re: [xsl] Confusing namespaces and , David Carlisle |
Re: [xsl] Confusing namespaces and , David Carlisle | Date | Re: [xsl] Confusing namespaces and , David Carlisle |
Month |