From 5895bbaa8a4087efd575170940052b1e0b167c50 Mon Sep 17 00:00:00 2001 From: hlousek Date: Mon, 4 Jun 2018 07:49:50 +0200 Subject: [PATCH] Add support for xml:lang in xs:description element to choose the preferred language. --- lib/xsdParser.coffee | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/xsdParser.coffee b/lib/xsdParser.coffee index 3524f48..4c837c5 100644 --- a/lib/xsdParser.coffee +++ b/lib/xsdParser.coffee @@ -111,9 +111,23 @@ module.exports = ## Get documentation string from node getDocumentation: (node) -> - @normalizeString(node?.annotation?[0].documentation[0]._ ? - node?.annotation?[0].documentation[0]) + langUser = navigator.language + docs = node?.annotation?[0].documentation + if ! docs + return null + docEn = null + docAny = null + for doc in docs + langDoc = doc.$?.lang + if langDoc == langUser + return @normalizeString(doc._) + if langDoc == 'en' + docEn = doc + else + docAny = doc + return @normalizeString(if docEn then docEn._ else + if docAny then docAny._) # Initialize a type object from a Simple or Complex type node. initTypeObject: (node, typeName) -> @@ -372,3 +386,4 @@ module.exports = else attributes.push attr type.xsdAttributes = attributes +