Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

How to add element content into its attribute value?

Avatar

Avatar
Validate 1
Level 8
MC_Stuff
Level 8

Likes

78 likes

Total Posts

467 posts

Correct Reply

158 solutions
Top badges earned
Validate 1
Boost 50
Boost 5
Boost 3
Boost 25
View profile

Avatar
Validate 1
Level 8
MC_Stuff
Level 8

Likes

78 likes

Total Posts

467 posts

Correct Reply

158 solutions
Top badges earned
Validate 1
Boost 50
Boost 5
Boost 3
Boost 25
View profile
MC_Stuff
Level 8

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