You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by Omar Crea <om...@thyme.it> on 2015/02/13 14:21:04 UTC

Moving nodes using Transformer

Hi all,

I'm new of Apache Sling, and I'm interested in the output rewriting
pipeline. What I want to achieve, within my html page, is to move certain
nodes (stylesheets and javascript) from the middle of the HTML document to
the <head> element.

The document is generated by a CMS, so I cannot control in advance where
stylesheets and scripts will be inserted.

Can this task be achieved using a Transformer? I suppose that I can do this
on the endDocument event, but I don't know how to flow through the entire
page to move nodes.

Thanks in advance,
Omar

-- 
Omar Crea

Mobile: +39 3926192511
Email: omar.crea@thyme.it
Skype: omarc.work

Thyme S.r.l.
Sede operativa:
Laboratorio Innovazione Breda
Via Venezia 23
20099 Sesto San Giovanni (MI)

Sede legale:
Via Fiordaliso 36
20095 Cusano Milanino (MI)

P.IVA 06416960968

Re: Moving nodes using Transformer

Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi,

On Fri, Feb 13, 2015 at 2:21 PM, Omar Crea <om...@thyme.it> wrote:
> ...What I want to achieve, within my html page, is to move certain
> nodes (stylesheets and javascript) from the middle of the HTML document to
> the <head> element....

> Can this task be achieved using a Transformer?...

You can certainly write an XSLT transform to do that, triggered by a
Sling Output Rewriting Pipeline.

That will probably cause the transformer to buffer the whole output,
might become inefficient depending on the input's size.

-Bertrand