Problem with XSLT where source xml document uses default namespace

人走茶凉 提交于 2019-12-01 17:57:43

问题


Have a source xml document that uses namespace containing prefixes and a default namespace. When I transform it using a XSLT doc, the resulting translated xml document is incorrect, that is, element data from the source xml document is missing.

When I remove the "default namespace" from the source xml document, the transformation works as expected.

Question: is there a way to resolve problem without the need to edit out the default namespace from the source xml document? That is, add the solution to the XSLT document.

XML Document:

<MyElement xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:xsd="http://www.w3.org/2001/XMLSchema"
           xmlns="http://www.zolldata.com/UDX">

where the problem default namespace is xmlns="http://www.zolldata.com/UDX"


回答1:


Specify same default namespace in XSLT document if your selectors do not use prefixes, or use prefixes for all selectors in the XSLT, but don't forget to bind them to the default namespace of your XML document.



来源:https://stackoverflow.com/questions/1343532/problem-with-xslt-where-source-xml-document-uses-default-namespace

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!