From 142a3a302b9486eeabfb17b3643c3305ad7c4105 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benito=20Palacios=20S=C3=A1nchez?= Date: Sat, 5 Dec 2015 12:19:52 +0100 Subject: [PATCH] Prevent errors from invalid XPaths --- .gitignore | 1 + CHANGELOG.md | 1 + lib/xsd.coffee | 2 +- lib/xsdParser.coffee | 3 +-- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index ade14b9..f12b1ac 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .DS_Store npm-debug.log node_modules +.imdone diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ad4ede..393c8e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## 0.7.5 * Merge attributes from extension types. * Throw errors to console to not annoy the user. +* Prevent error from invalid XPaths. ## 0.7.4 * Fix using a root type as children too. diff --git a/lib/xsd.coffee b/lib/xsd.coffee index 5f8adfe..2d3438b 100644 --- a/lib/xsd.coffee +++ b/lib/xsd.coffee @@ -78,7 +78,7 @@ module.exports = type = xsdParser.roots[xpath[0]] xpath.shift() # Remove root node. - while xpath && xpath.length > 0 + while xpath && xpath.length > 0 && type nextTag = xpath.shift() nextTypeName = @findTypeFromTag nextTag, type type = @types[nextTypeName] diff --git a/lib/xsdParser.coffee b/lib/xsdParser.coffee index 48ebb11..f1e529e 100644 --- a/lib/xsdParser.coffee +++ b/lib/xsdParser.coffee @@ -58,12 +58,11 @@ module.exports = # TODO: Process all Attributes definition. # TODO: Process all AttributeGroup - # TODO: Process all Group # Post parse the nodes and resolve links. @postParsing() - console.log @types + # Return calling the complete callback. complete()