What is the best way to strip/replace the {} characters from the Sitecore item @id output in xslt?
Problem:
I have to identity certain tags in my html from the id attribute. Using names is dangerous because of the risk of the Sitecore end user typing spaces or illegal characters in the name.
On the other hand using the item id causes the id in the html to say: id="{xxxxxxxx-xxx(...)}, in which case the {} are illegal as characters in html id attribute.
So:
What is the best way to strip/replace the {} characters from the xslt @id output?
Right way to do this would be with NormalizeGuid.
I have used before (on Sitecore V5) NormalizeGuid Method from MainUtils.
I just tested on Sitecore 6.2 but it is breaking because there are 2 same method names. This results in an
XslTransformExceptionWhich version of Sitecore you are using? I suggest trying out NormalizeGuid:
Goes something like:
Web.Config
XSLT
and
If you get RTE it is possible to fix it with a custom wrapper class. Take a look this post.
Actually, I think you can get around this by using
GenerateShortID()it’s also in MainUtil.