// Do the actual processing, if the 'href' attribute is specified.
if (url != null) {
// Prepare the asset resolver and page URI rewriter for later use.
AssetResolver assetResolver = getProtocol(context).getMarinerPageContext()
.getAssetResolver();
PageURIRewriter uriRewriter = getProtocol(context).getMarinerPageContext()
.getPageURIRewriter();
if (!uriRewriter.willPossiblyRewrite(PageURLType.ANCHOR)) {
// If the URL is not to be rewritten using page URI rewriter
// for which the current state of the page context is important,
// simply create a LinkAssetReference in standard way.
// The URL will be rewritten by PageURLRewriter when the
// getUrl() method gets called.
linkAssetReference = new LiteralLinkAssetReference(url, assetResolver,
PageURLType.ANCHOR);
} else {
// If the URL possibly is to be rewritten using page URI
// rewriter, rewrite the URL in-place, since at the moment the
// getUrl() method would be invoked, the page context would
// change and the page URI rewriter would return different
// result than expected.
url = assetResolver.rewriteURLWithPageURLRewriter(url, PageURLType.ANCHOR);
try {
url = uriRewriter.rewrite(new URI(url), PageURLType.ANCHOR).toString();
} catch (URISyntaxException e) {
throw new XDIMEException("Invalid URI: " + url, e);
}
// Create an instance of LinkAssetReference with already