XSLT问题,其中源xml文档使用默认名称空间 [英] Problem with XSLT where source xml document uses default namespace

查看:86
本文介绍了XSLT问题,其中源xml文档使用默认名称空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个源XML文档,该文档使用包含前缀和默认名称空间的名称空间.当我使用XSLT文档对其进行转换时,生成的翻译后的xml文档不正确,也就是说,缺少了源xml文档中的元素数据.

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.

当我从源xml文档中删除默认名称空间"时,转换将按预期进行.

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

问题:是否有一种方法可以解决问题而无需从源xml文档中编辑出默认名称空间?也就是说,将解决方案添加到XSLT文档中.

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文档:

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

问题默认名称空间为xmlns ="http://www.zolldata.com/UDX"

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

推荐答案

如果您的选择器不使用前缀,或者对XSLT中的所有选择器使用前缀,但不要忘记绑定它们,请在XSLT文档中指定相同的默认名称空间.到XML文档的默认名称空间.

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.

这篇关于XSLT问题,其中源xml文档使用默认名称空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆