Highlighted

How to add element content into its attribute value?

Avatar

Avatar

MC_Stuff

Avatar

MC_Stuff

MC_Stuff

24-05-2018

Trying to rewrite the output generated by a Sling rendering process from [A] to [B].

  • We can add an attribute (data-pt) at the startElement method of TrasformerFactory But struggle to get the value of its content (Test Drive) at the method startElement.
  • The value (Test Drive) available at methods characters  Or endElement of the transformer. Both the method does not have an option to add the attribute

Please let me know is it possible

  • to rewrite to [B] using sling rewriter?
  • If yes please get us the hint Or reference implementation example.
  • Otherwise any other recommendations? 

Thanks for your time.

[A]

<a href="https://forums.adobe.com/some/link">Test Drive</a>

[B]

<a href="https://forums.adobe.com/some/link" data-pt="Test Drive">Test Drive</a>

P.S: We are familiar with AEM materials & implementation.  Following articles really helped a lot & most of other internet blogs/kb are mostly based of it.  Please avoid responding with general google results.

https://www.slideshare.net/justinedelson/mastering-the-sling-rewriter

https://sling.apache.org/documentation/bundles/output-rewriting-pipelines-org-apache-sling-rewriter....

@justin_at_adobe

Message was edited by: MC Stuff