0
如何從xml獲取所有xmlns?使用XSLT。 比如我有XML:獲取帶xml前綴的所有名稱空間
<?xml version="1.0" encoding="UTF-8"?>
<cult:ProjectDocCoordination xmlns:smev="http://smev.gosuslugi.ru/request/rev111111" xmlns:cult="urn://x-artefacts-it-ru/dob/state-services/cult/ProjectDocCoordination/1.0" xmlns:commons="urn://x-artefacts-it-ru/dob/state-services/cult/commons/1.0">
<cult:Person>
<commons:FamilyName>Иванов</commons:FamilyName>
<commons:FirstName>Иван</commons:FirstName>
<commons:Patronymic>Иванович</commons:Patronymic>
<cult:OGRNIP>300000000000000</cult:OGRNIP>
<cult:Phone>9212345678</cult:Phone>
<cult:Email>[email protected]</cult:Email>
<cult:Address>Address</cult:Address>
</cult:Person>
<cult:ObjectRegion>ObjectRegion</cult:ObjectRegion>
<cult:ObjectName>ObjectName</cult:ObjectName>
<cult:ScientificDesignDeveloperInfo>
<cult:ProjectDocName>ProjectDocName</cult:ProjectDocName>
<cult:ProjectDocComposition>ProjectDocComposition</cult:ProjectDocComposition>
<cult:DeveloperLegalInfo>
<cult:DeveloperULName>ООО Удача</cult:DeveloperULName>
<cult:DeveloperULOPF>DeveloperULOPF</cult:DeveloperULOPF>
<cult:Address>Address</cult:Address>
</cult:DeveloperLegalInfo>
</cult:ScientificDesignDeveloperInfo>
<cult:LicenseInfo>
<cult:Number>001877</cult:Number>
<cult:Date>2014-06-06</cult:Date>
</cult:LicenseInfo>
<test:JobInfo xmlns:test="http://test.test.com">
<test:Number>67800</test:Number>
<test:Date>2014-08-06</test:Date>
<test:AgentName>Иванов Иван Иванович</test:AgentName>
<test:Phone>9212345678</test:Phone>
</test:JobInfo>
<cult:NoChangedCharacteristics>true</cult:NoChangedCharacteristics>
<cult:CapitalReconstruction>true</cult:CapitalReconstruction>
<cult:ResultInfo>Выдать лично на руки</cult:ResultInfo>
<cult:DocInfo>
<cult:Document1>
<smev:AppliedDocument smev:ID="ID_1">
<smev:CodeDocument>String</smev:CodeDocument>
<smev:Name>1.txt</smev:Name>
<smev:Number>1</smev:Number>
<smev:URL>1.txt</smev:URL>
<smev:Type>text/plain</smev:Type>
<smev:DigestValue>UjBsR09EbGhjZ0dTQUxNQUFBUUNBRU1tQ1p0dU1GUXhEUzhi</smev:DigestValue>
</smev:AppliedDocument>
</cult:Document1>
</cult:DocInfo>
</cult:ProjectDocCoordination>
我想要得到的東西這個(分隔符= $):
xmlns:smev="http://smev.gosuslugi.ru/request/rev111111"$xmlns:cult="urn://x-artefacts-it-ru/dob/state-services/cult/ProjectDocCoordination/1.0"$xmlns:commons="urn://x-artefacts-it-ru/dob/state-services/cult/commons/1.0"$xmlns:test="http://test.test.com"
還是這個(沒有 「的xmlns:」):
smev="http://smev.gosuslugi.ru/request/rev111111"$cult="urn://x-artefacts-it-ru/dob/state-services/cult/ProjectDocCoordination/1.0"$commons="urn://x-artefacts-it-ru/dob/state-services/cult/commons/1.0"$test="http://test.test.com"
offtop ...看起來你的文章主要是代碼;請添加更多的細節。
您使用的是哪個版本的XSLT?唯一的命名空間信息可以通過'// namespace :: * [not(。= ../../namespace::*)而不是(。='http://www.w3.org/XML/1998/namespace ')]'在XPath 1.0中使用XPath 2.0或'distinct-values(// namespace :: * [not(。='http://www.w3.org/XML/1998/namespace')])''。閱讀命名空間軸:http://www.w3.org/TR/xpath/#namespace-nodes –
我使用2.0版本。如果我使用「distinct-values(// namespace :: * [not(。='http://www.w3.org/XML/1998/namespace')])」,那麼我得到所有差異NS,但沒有字首。我怎樣才能得到每個NS的前綴? – Elvis