如何从输出xml中删除命名空间?
发布时间:2020-12-16 07:53:44 所属栏目:百科 来源:网络整理
导读:以下是我的xsl xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ms="http://www.test.com/schemas/test" xmlns:ns="urn:schemas-microsoft-com:xslt" exclude
以下是我的xsl
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ms="http://www.test.com/schemas/test" xmlns:ns="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="ms ns"> <xsl:output method="xml" indent="yes"/> <xsl:template match="/"> <XMLResponse> <xsl:apply-templates select="ms:ProductRS/ms:Product"/> </XMLResponse> </xsl:template> <-- some templates here --> </xsl:stylesheet> 在输出我喜欢下面 <?xml version="1.0" encoding="UTF-16"?> <XMLResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Product>-----</Product> </XMLResponse> 我需要从xml输出中删除xmlns:xsi =“http://www.w3.org/2001/XMLSchema-instance”
要排除一个命名空间,那么你应该这样表示:
exclude-result-prefixes =“ms ns xsi” 基本上你的样式表如下所示: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ms="http://www.test.com/schemas/test" xmlns:ns="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="ms ns xsi"> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |