Ошибка XML при использовании sap.tnt.SideNavigation с загруженными фрагментами

#xml #sapui5

#xml #sapui5

Вопрос:

Учитывая sap.tnt.ToolPage панель навигации с sideContent панелью, OpenUI5 1.98.0.

При навигации с помощью панели навигации я периодически наблюдаю следующую ошибку в консоли:

Ошибка: com/myApp/view/documents/Documents.view.xml не удалось загрузить ресурс из ./view/documents/Documents.view.xml . Проверьте, нет ли «файл не найден» или ошибок синтаксического анализа. Причина: Error: Invalid XML: This page contains the following errors: error on line 41 at column 3: Specification mandates value for attribute data-sap-ui-component

 Below is a rendering of the page up to the first error.  at Object.error (LoaderExtensions-dbg.js:339:15)  at p (jquery-dbg.js:3500:29)  at Object.fireWith [as rejectWith] (jquery-dbg.js:3630:7)  at y3 (jquery-dbg.js:9913:13)  at XMLHttpRequest.lt;anonymousgt; (jquery-dbg.js:10172:9)  

Панель навигации sideContent заполняется из фрагмента:

 lt;tnt:sideContentgt;   lt;core:Fragment  fragmentName = "com.myApp.view.fragment.SideNavigation"  type = "XML" /gt;  lt;/tnt:sideContentgt;  

То SideNavigation :

 lt;SideNavigation  xmlns:core = "sap.ui.core"  xmlns = "sap.tnt"  expanded = "true"  id = "sideNavigation"  selectedKey = "{/selectedKey}"gt;   lt;NavigationList items = "{  path: '/navigation',  templateShareable: false  }"gt;   lt;core:Fragment  fragmentName = "com.myApp.view.fragment.NavigationList"  type = "XML" /gt;   lt;/NavigationListgt;   lt;fixedItemgt;   lt;NavigationList  items = "{  path: '/fixedNavigation',  templateShareable: false  }"gt;   lt;core:Fragment  fragmentName = "com.myApp.view.fragment.NavigationList"  type = "XML" /gt;   lt;/NavigationListgt;   lt;/fixedItemgt;  lt;/SideNavigationgt;  

То NavigationListItem :

 lt;NavigationListItem  xmlns = "sap.tnt"  expanded = "{expanded}"  href = "#/{key}"  icon = "{icon}"  items = "{  path: 'items',  templateShareable: false  }"  key = "{key}"  text = "{  path: 'titleI18NKey',  formatter: '.formatter.getText'  }"gt;   lt;NavigationListItem  href = "#/{key}"  key = "{key}"  text = "{  path: 'titleI18NKey',  formatter: '.formatter.getText'  }" /gt;  lt;/NavigationListItemgt;  

Despite the warning regarding the invalid XML, the XML validators claim that the XML is correct. Another weird thing is that this error appears not at any click on the navigation bar but at the click on the specific items, while all the items are loaded from the JSON-model and are identical, minimum manually-written code.

I’ve tried to check deeper and find out that additionally I get an CSP error:

Refused to apply inline style because it violates the following Content Security Policy directive: «style-src https://*.hana.ondemand.com ‘self'». Either the ‘unsafe-inline’ keyword, a hash (‘sha256-ICa0DhwZQJsOd/Rn0N8H6FdQ71GfNL op2zhAQ Y4mM=’), or a nonce (‘nonce-…’) is required to enable inline execution. Note that hashes do not apply to event handlers, style attributes and javascript: navigations unless the ‘unsafe-hashes’ keyword is present.

But removal of the CSP completely doesn’t solve the issue, therefore I don’t think the CSP is the reason for the error.

Any way, it’s quite strange to get an XML-error in case of a valid XML-template. Any idea what can lead to this error at clicking on the navigation side bar?

The the result, the navigation between the views is not always functioning, I assume, it might be an asynchronous view loading issue or something related more to how OpenUI5 operates, rather then to my custom code, since there is almost no custom code and the views are literally empty and contain only single title.

Perhaps, one more important thing, the navigation is defined in the model, initialized via manifest.json :

 "sideNavigation": {  "type": "sap.ui.model.json.JSONModel",  "uri": "model/menus/sideNavigation.json" }  

sideNavigation :

 {  "selectedKey": "",   "navigation": [  {  "icon": "sap-icon://home",  "key": "index",  "titleI18NKey": "Home"  }  ] }  

P.S. I’ve tried on 1.97.0 and 1.96.2, the same issue.