final ResourceKey context)
throws ResourceCreationException, ResourceLoadingException
{
try
{
final Parser parser = CSSParserFactory.getInstance().createCSSParser();
final ResourceKey key;
final long version;
if (context == null)
{
key = data.getKey();
version = data.getVersion(manager);
}
else
{
key = context;
version = -1;
}
final DocumentContext documentContext;
final StyleSheetHandler handler = new StyleSheetHandler();
handler.init(StyleKeyRegistry.getRegistry(), manager, key, version, null);
parser.setDocumentHandler(handler);
final InputSource inputSource = new InputSource();
inputSource.setByteStream(data.getResourceAsStream(manager));
handler.initParseContext(inputSource);
handler.setStyleRule(new CSSStyleRule(null, null));
parser.parseStyleDeclaration(inputSource);
final DependencyCollector dependencies = handler.getDependencies();
if (context != null)
{
dependencies.add(data.getKey(), data.getVersion(manager));