Kees Hink wrote: > > On 10/22/2010 06:40 PM, Laurence Rowe wrote: >> >> >> Laurence Rowe wrote: >>> >>> >>> Kees Hink wrote: >>>> >>>> I'm now trying to change the img src attribute: >>>> >>>> <xsl:template >>>> match="i...@class='collage-image']"> >>>> <xsl:copy/>_thumb >>>> </xsl:template> >>>> >>>> and getting this error: >>>> >>>> XSLTApplyError: Attribute nodes must be added before any child nodes to >>>> an element. >>>> >>>> I've solved it by doing this: >>>> >>>> <xsl:template >>>> match="i...@class='collage-image']"> >>>> >>>> <xsl:attribute name="src"> >>>> <xsl:value-of select="./@src" />_thumb >>>> </xsl:attribute> >>>> </img> >>>> </xsl:template> >>>> >>> >>> It's probably better to match the attribute directly. See the example I >>> posted earlier at >>> https://codespeak.net/svn/z3/xdv/trunk/lib/xdv/tests/inline-xsl-example-modify-attribute/ >>> >> >> To be clear, I mean: >> >> <xsl:template match="i...@class='collage-image']/@src"> >> <xsl:attribute name="src"><xsl:value-of select="." >> />_thumb</xsl:attribute> >> </xsl:template> >> >> Laurence > > Thanks for pointing that out. > > As an extension of this, I'm trying to show images from news items in > another > scale, "news" instead of "mini". I tried this: > > <rules > ... > xmlns:str="http://exslt.org/strings" > > > > <xsl:template match="i...@class='newsImage']/@src"> > <xsl:value-of select="str:replace(., '_mini', '_news')" /> > </xsl:template> > > but alas, "XSLTApplyError: Attribute nodes must be added before any child > nodes > to an element." > > (This thread is turning into a nice list of > stuff-to-put-in-Diazo-documentation.) >
You must wrap it in <xsl:attribute name="src">...</xsl:attribute> as above. Laurence -- View this message in context: http://plone.293351.n2.nabble.com/complex-XSLT-in-collective-xdv-search-and-replace-in-HTML-tp5646426p5697319.html Sent from the Product Developers mailing list archive at Nabble.com. _______________________________________________ Product-Developers mailing list [email protected] http://lists.plone.org/mailman/listinfo/product-developers
