Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


MY XML is not working


MY XML is not working

Author
Message
niladri.primalink
niladri.primalink
SSC-Enthusiastic
SSC-Enthusiastic (117 reputation)SSC-Enthusiastic (117 reputation)SSC-Enthusiastic (117 reputation)SSC-Enthusiastic (117 reputation)SSC-Enthusiastic (117 reputation)SSC-Enthusiastic (117 reputation)SSC-Enthusiastic (117 reputation)SSC-Enthusiastic (117 reputation)

Group: General Forum Members
Points: 117 Visits: 226
I have written a sql syntax to create an XML. Here is the code
Code:
WITH XMLNAMESPACES ( 'urn:swift:saa:xsd:saa.2.0' AS Saa)
select
'2.0.2' 'Saa:Revision',
DbtrAcct_Id_IBAN 'Saa:Header/Saa:Message/Saa:SenderReference',
1 'Saa:Header/Saa:Message/Saa:MessageIdentifier',
'camt.056.001.01' 'Saa:Header/Saa:Message/saa:Format',
'cn=mx01,0='+DbtrAgt_FinInstnId_BIC+'o=swift' 'Saa:Header/Saa:Message/Saa:Sender/SaaBigGrinN' ,
'cn=mx99,0='+CdtrAgt_FinInstnId_BIC+'o=swift' 'Saa:Header/Saa:Message/Saa:Receiver/SaaBigGrinN',
'swift.generic.fast!p' 'Saa:Header/Saa:Message/Saa:NetworkInfo/Saa:Service',
'Payment File from Bank BANKAABB' 'Saa:Header/Saa:Message/Saa:NetworkInfo/Saa:SWIFT:NetNetworkInfo/Saa:FileDescription',
'Sent on 01/04/2009' 'Saa:Header/Saa:Message/Saa:NetworkInfo/Saa:SWIFT:NetNetworkInfo/Saa:FileInfo',
'SHA=256' 'Saa:Header/Saa:Message/Saa:SecurityInfo/Saa:SWIFTNetSecurityInfo/Saa:SWIFTNetSecurityInfo',
'pnRSc38nofZ3AF1pmWSnmoLpfprVb/pJXx5l+PhJC68=' 'Saa:Header/Saa:Message/Saa:SecurityInfo/Saa:SWIFTNetSecurityInfo/Saa:FileDigestValue',
filename 'Saa:Header/Saa:Message/Saa:FileLogicalName',
cast(dbo.FIM_GetXMLCamt056UDF(2,1) as xml) 'Saa:Body'
from FimBank_TransDetails ftd where ftd.AutoId=2
for XML path (''),
root ('SaaBigGrinataPDU'), ELEMENTS XSINIL


I got an error "XML name space prefix 'saa' declaration is missing for FOR XML column name 'Saa:Header/Saa:Message/saa:Format'."

Searched in google but no satisfactory answer I am getting.

However I want to see the output like below

<SaaBigGrinataPDU mins:Saa="urn:swift:saa:xsd:saa.2.0">
<Saa:Revision>2.0.2</Saa:Revision>
<Saa:Header>
<Saa:Message>
<Saa:SenderReference>File1</Saa:SenderReference>
<Saa:MessageIdentifier>Req001</Saa:MessageIdentifier>
<saa:Format>File</Saa:Format>
<Saa:Sender>
<SaaBigGrinN>cn=mx01,0=bankaabb,o=swift</SaaBigGrinN>
</Saa:Sender>
<Saa:Receiver>
<SaaBigGrinN>cn=mx99,0=bankyyzz,o=swift</SaaBigGrinN>
</Saa:Receiver>
<Saa:NetworkInfo>
<Saa:Service>Service.FileAct</Saa:Service>
<Saa:SWIFT:NetNetworkInfo>
<Saa:FileDescription>Payment File from Bank BANKAABB</Saa:FileDescription>
<Saa:FileInfo>Sent on 01/04/2009</Saa:FileInfo>
</Saa:SWIFT:NetNetworkInfo>
</Saa:NetworkInfo>
<Saa:SecurityInfo>
<Saa:SWIFTNetSecurityInfo>
<Saa:FileDigestAlgorithm>SHA=256</Saa:FileDigestAlgorithm>
<Saa:FileDigestValue>pnRSc38nofZ3AF1pmWSnmoLpfprVb/pJXx5l+PhJC68=</Saa:FileDigestValue>
</Saa:SWIFTNetSecurityInfo>
</Saa:SecurityInfo>
<Saa:FileLogicalName>Payments-Bank BANKAABB</Saa:FileLogicalName>
</Saa:Message>
</Saa:Header>
<Saa:Body>payments,fct</Saa:Body>
</SaaBigGrinataPDU>


Could you please guide me? Please help


Thanks in advance!!
Mark Cowne
Mark Cowne
SSCrazy
SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)

Group: General Forum Members
Points: 2091 Visits: 22787
XML is generally case-sensitive so try changing

'Saa:Header/Saa:Message/saa:Format'."


to

'Saa:Header/Saa:Message/Saa:Format'."

____________________________________________________

Deja View - The strange feeling that somewhere, sometime you've optimised this query before

How to get the best help on a forum

http://www.sqlservercentral.com/articles/Best+Practices/61537




niladri.primalink
niladri.primalink
SSC-Enthusiastic
SSC-Enthusiastic (117 reputation)SSC-Enthusiastic (117 reputation)SSC-Enthusiastic (117 reputation)SSC-Enthusiastic (117 reputation)SSC-Enthusiastic (117 reputation)SSC-Enthusiastic (117 reputation)SSC-Enthusiastic (117 reputation)SSC-Enthusiastic (117 reputation)

Group: General Forum Members
Points: 117 Visits: 226
Thanks for your reply

But I am now getting error

Column name 'Saa:Header/Saa:Message/Saa:NetworkInfo/Saa:SWIFT:NetNetworkInfo/Saa:FileDescription' contains an invalid XML identifier as required by FOR XML; ':'(0x003A) is the first character at fault.


Please help!
niladri.primalink
niladri.primalink
SSC-Enthusiastic
SSC-Enthusiastic (117 reputation)SSC-Enthusiastic (117 reputation)SSC-Enthusiastic (117 reputation)SSC-Enthusiastic (117 reputation)SSC-Enthusiastic (117 reputation)SSC-Enthusiastic (117 reputation)SSC-Enthusiastic (117 reputation)SSC-Enthusiastic (117 reputation)

Group: General Forum Members
Points: 117 Visits: 226
Hi

it is now working

DECLARE @xmlDoc XML

WITH XMLNAMESPACES ('urn:swift:saa:xsd:saa.2.0' AS Saa)
SELECT @xmlDoc =(select
'2.0.2' 'Saa:Revision',
DbtrAcct_Id_IBAN 'Saa:Header/Saa:Message/Saa:SenderReference',
1 'Saa:Header/Saa:Message/Saa:MessageIdentifier',
'camt.056.001.01' 'Saa:Header/Saa:Message/Saa:Format',
'cn=mx01,0='+DbtrAgt_FinInstnId_BIC+'o=swift' 'Saa:Header/Saa:Message/Saa:Sender/SaaBigGrinN' ,
'cn=mx99,0='+CdtrAgt_FinInstnId_BIC+'o=swift' 'Saa:Header/Saa:Message/Saa:Receiver/SaaBigGrinN',
'swift.generic.fast!p' 'Saa:Header/Saa:Message/Saa:NetworkInfo/Saa:Service',
-- 'Payment File from Bank BANKAABB' 'Saa:Header/Saa:Message/Saa:NetworkInfo/Saa:SWIFT:NetNetworkInfo/Saa:FileDescription',
-- 'Sent on 01/04/2009' 'Saa:Header/Saa:Message/Saa:NetworkInfo/Saa:SWIFT:NetNetworkInfo/Saa:FileInfo',
'SHA=256' 'Saa:Header/Saa:Message/Saa:SecurityInfo/Saa:SWIFTNetSecurityInfo/Saa:SWIFTNetSecurityInfo',
'pnRSc38nofZ3AF1pmWSnmoLpfprVb/pJXx5l+PhJC68=' 'Saa:Header/Saa:Message/Saa:SecurityInfo/Saa:SWIFTNetSecurityInfo/Saa:FileDigestValue',
filename 'Saa:Header/Saa:Message/Saa:FileLogicalName',
cast(dbo.FIM_GetXMLCamt056UDF(64,1) as xml) 'Saa:Body'
from FimBank_TransDetails ftd where ftd.AutoId=64
for XML path ('DataPDU'),
root ('SaaBigGrinataPDU'))
Select @xmlDoc


but i don't want to see the XML path. Is there any way to do that?

Thanks in advance!
niladri.primalink
niladri.primalink
SSC-Enthusiastic
SSC-Enthusiastic (117 reputation)SSC-Enthusiastic (117 reputation)SSC-Enthusiastic (117 reputation)SSC-Enthusiastic (117 reputation)SSC-Enthusiastic (117 reputation)SSC-Enthusiastic (117 reputation)SSC-Enthusiastic (117 reputation)SSC-Enthusiastic (117 reputation)

Group: General Forum Members
Points: 117 Visits: 226
Thanks

It is now working. Only a small 's' was making my life in danger. Thanks buddy.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search