Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

Link Rewriter Transfrmer - Not processing VML tags

Avatar

Community Advisor

Hi 

   I am working on a component in which I have some VML tags like below . 

 

<!--[if mso]>
<v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="/content/wknd/en/sports/la-skateparks" style="height:36px;v-text-anchor:middle;width:150px;" arcsize="5%" strokecolor="#EB7035" fillcolor="#EB7035">
<w:anchorlock/>
<center style="color:#ffffff;font-family:Helvetica, Arial,sans-serif;font-size:16px;">I am a button &rarr;</center>
</v:roundrect>
<![endif]-->

I want to rewrite the href="/content/wknd/en/sports/la-skateparks" value to lets say something like href="https://abc.com/sports/la-skateparks" . I have class which implements TransformerFactory for this ( something like this ) , but it is taking all the HTML tags we refer . Since the above tag is a VML based tag and not an HTML tag, even when I give the same, it is not picking up the href from this tag. Do any one have an idea on how to get this work in AEM ? May be I am missing something here. 

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@Suraj_Kamdi Hey sorry , My mistake I had to add [V:ROUNDRECT] and [/V:ROUNDRECT] . ( the starting tag and closing tag) to the generate-htmlparser config node. This is working only if I don't have

<!--[if mso]>

The entire VML tag is inside the [if mso] tag and this is treated as comments in HTML. Hence the above one is not working when it is commented.  

View solution in original post

6 Replies

Avatar

Community Advisor

@VeenaVikraman 

Please update those tag in includeTags="[A,IMG,SCRIPT,LINK]" configuration file first

Config file path = > /apps/project-name/config/rewriter/default

 

 

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
    jcr:primaryType="nt:unstructured"
    contentTypes="[text/html]"
    enabled="{Boolean}true"
    paths="[/content/project-name]"
    generatorType="htmlparser"
    order="1"
    serializerType="htmlwriter"
    transformerTypes="[linkchecker,versioned-clientlibs,project-name-url-rewriter]">
    <generator-htmlparser
        jcr:primaryType="nt:unstructured"
        includeTags="[A,IMG,SCRIPT,LINK]"/>
</jcr:root>

 

 

 

I hope this will help.

Thanks & Regard,

Suraj Kamdi

Avatar

Community Advisor
I tried adding it in tags .. I tried adding v , also tried adding v:roundrect . But both didn't pick

Avatar

Community Advisor

Then you need to update your transformer class.. see the below example for "<a> "tag

 

 @Override
   public void startElement(String uri, String localName, String qName,
                           Attributes attributes) throws SAXException {
      if ("a".equals(localName) && shouldBeTransformed(attributes)) {
         String href = attributes.getValue("href");
         String modifiedHref = modifyHref(href);
         AttributesImpl attributesImpl = new AttributesImpl(attributes);
         attributesImpl.setValue(attributes.getIndex(href), modifiedHref);
         super.startElement(uri, localName, qName, attributesImpl);
      } else {
         super.startElement(uri, localName, qName, attributes);
      }
   }

just write extra logic to handle other than HTML tags. 

Hope This will Help

Avatar

Correct answer by
Community Advisor

@Suraj_Kamdi Hey sorry , My mistake I had to add [V:ROUNDRECT] and [/V:ROUNDRECT] . ( the starting tag and closing tag) to the generate-htmlparser config node. This is working only if I don't have

<!--[if mso]>

The entire VML tag is inside the [if mso] tag and this is treated as comments in HTML. Hence the above one is not working when it is commented.