diff --git a/lib/CSDLSearch.js b/lib/CSDLSearch.js index 2683a58..2c4e904 100644 --- a/lib/CSDLSearch.js +++ b/lib/CSDLSearch.js @@ -97,6 +97,9 @@ function findByType(metadata, typeName) { if(schema === undefined) { schema = metadata._options.cache.getSchema(namespace); if(schema === undefined) { + if(metadata.References === undefined) { + return null; + } namespace = remapNamespace(metadata.References, namespace); if(namespace !== undefined) { schema = metadata._options.cache.getSchema(namespace); diff --git a/lib/Metadata.js b/lib/Metadata.js index a825fb2..86e7e84 100644 --- a/lib/Metadata.js +++ b/lib/Metadata.js @@ -35,6 +35,9 @@ Metadata.prototype.done = function(error) { callback = callback.bind(this.context); delete this.context; } + if(this._options.cache) { + this._options.cache.addMetadata(this); + } callback(error, this); } } diff --git a/lib/cache/csdlCache.js b/lib/cache/csdlCache.js index cadaea9..4a17c89 100644 --- a/lib/cache/csdlCache.js +++ b/lib/cache/csdlCache.js @@ -79,5 +79,9 @@ CSDLCache.prototype.getSchema = function(namespace) { return undefined; } +CSDLCache.prototype.addMetadata = function(metadata) { + this.metadataCache.push(metadata); +} + module.exports = CSDLCache; /* vim: set tabstop=2 shiftwidth=2 expandtab: */ diff --git a/package.json b/package.json index 0797c47..05a84d3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "CSDLParser", - "version": "0.1.4", + "version": "0.1.5", "description": "CSDL Metadata Parser", "main": "./index.js", "scripts": {