由于命名空间,Xml样式表不起作用

时间:2014-11-28 13:01:51

标签: xml web-services soap namespaces

我想得到以下全名,结果应该是" Root Administratoren"



<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
	<GetAllGroupsOfUserResponse xmlns="http://fuu/fuu/fuu/">
		<GetAllGroupsOfUserResult>
			<Group>
				<DataId>11</DataId>
				<ObjectGuid>31ea4ee1-cf85-44ac-846e-6ef58542af2c</ObjectGuid>
				<FullName>Root Administratoren</FullName>
			</Group>
		</GetAllGroupsOfUserResult>
	</GetAllGroupsOfUserResponse>
</soap:Body>
</soap:Envelope>`
&#13;
&#13;
&#13;

我正在使用这个XML-Stylesheet

&#13;
&#13;
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl" xmlns:tmp="http://tempuri.org/">
	<xsl:output method="xml" indent="yes" />
	<xsl:template match="/">
		<Result>
			<xsl:for-each select="ArrayOfGroup/Group">
			<FullName>
				<xsl:value-of select="FullName" />
			</FullName>
			</xsl:for-each>
		</Result>
	</xsl:template>
</xsl:stylesheet>
&#13;
&#13;
&#13;

但是当我删除它工作的命名空间时我没有得到结果但是xml必须保持这种状态。 感谢您的帮助

问候 亚历

1 个答案:

答案 0 :(得分:1)

为默认命名空间添加新前缀,并将其与XPath中的每个元素一起使用。 另外,添加//以获取所有ArrayOfGroup元素。

 <xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl" xmlns:tmp="http://tempuri.org/"
xmlns:fuu="http://fuu/fuu/fuu/"
>
	<xsl:output method="xml" indent="yes" />
	<xsl:template match="/">
		<Result>
			<xsl:for-each select="//fuu:ArrayOfGroup/fuu:Group">
			<FullName>
				<xsl:value-of select="fuu:FullName" />
			</FullName>
			</xsl:for-each>
		</Result>
	</xsl:template>
</xsl:stylesheet>

相关问题