if (content instanceof CSSStringValue)
{
final CSSStringValue sval = (CSSStringValue) content;
if (CSSStringType.STRING.equals(sval.getType()))
{
return new StaticTextToken(sval.getValue());
}
else
{
// this is an external URL, so try to load it.
final CSSFunctionValue function = new CSSFunctionValue
("url", new CSSValue[]{sval});
return evaluateFunction(function, process, element);
}
}
if (content instanceof CSSFunctionValue)
{
return evaluateFunction((CSSFunctionValue) content, process, element);
}
if (content instanceof CSSConstant)
{
if (ContentValues.DOCUMENT_URL.equals(content))
{
final Object docUrl = process.getDocumentContext().getMetaAttribute
("document-url");
if (docUrl != null)
{
return new StaticTextToken(String.valueOf(docUrl));
}
final ResourceKey baseKey =
DocumentContextUtility.getBaseResource(process.getDocumentContext());
final ResourceManager resourceManager =
DocumentContextUtility.getResourceManager(process.getDocumentContext());
final URL url = resourceManager.toURL(baseKey);
if (url != null)
{
return new StaticTextToken(url.toExternalForm());
}
return null;
}
final ContentToken token = (ContentToken) tokenMapping.get(content);