Created
June 15, 2016 20:35
-
-
Save justinedelson/cdcf502413740bef9539faf74385a599 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CharacterTransformerFactory implements TransformerFactory { | |
@Override | |
public Transformer createTransformer() { | |
return new CharacterTransformer(); | |
} | |
private class CharacterTransformer extends AbstractTransformer { | |
@Override | |
public void characters(char[] ch, int start, int length) throws SAXException { | |
String str = new String(ch, start, length); | |
if (str.contains("<!--") && str.contains("-->")) { | |
str = str.replace("<!--", "<!-- HELLO"); | |
super.characters(str.toCharArray(), 0, str.length()); | |
} else { | |
super.characters(ch, start, length); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment