Thanks All for such a quick response ________________________________ From: [email protected] <[email protected]> on behalf of William Sawyer <[email protected]> Sent: Friday, November 21, 2014 10:30 AM To: MarkLogic Developer Discussion Subject: Re: [MarkLogic Dev General] Namespaces are getting removed
It you want an alternative in memory update library Ryan Dew's has worked great for me. https://github.com/ryanjdew/XQuery-XML-Memory-Operations On Thu, Nov 20, 2014 at 9:57 PM, Michael Blakeley <[email protected]<mailto:[email protected]>> wrote: It can be dangerous to use fn:name in that context. Try fn:node-name instead. The fn:name function returns a string, which can do strange things depending on the namespace declarations in context. But fn:node-name returns a QName. Consider this code: declare namespace t="cat" ; let $a := <t:a/> return <environment xmlns:t="dog"> { element { name($a) } { () }, element { node-name($a) } { () } } </environment>/* => <t:a xmlns:t="dog"/> <t:a xmlns:t="cat"/> Using fn:name ends up changing the namespace because the prefix changed. Using node-name preserves the original namespace. Another way to handle this sort of problem is to use the (deprecated) namespace axis. declare namespace t="cat" ; let $a := <t:a xmlns:b="goat"/> return <environment xmlns:t="dog"> { element { node-name($a) } { $a/namespace::* } } </environment>/* => <t:a xmlns:t="cat" xmlns:b="goat"/> This preserves the declaration for b=goat, even though it was never used. -- Mike > On 20 Nov 2014, at 20:48 , > <[email protected]<mailto:[email protected]>> > <[email protected]<mailto:[email protected]>> wrote: > > Hi Pragya, > > Long back ago i also faced similar issue with the in-mem-update library. > After investigating i found a minor issue in the library. > > > It was due to this code snippet inside _process (..) method. > > element{ QName(namespace-uri($node), local-name($node)) }{ ....... > > ..... > } > > This code snippet is twice (IF and ELSE block ) in the same method. Replace > the above code snippet with below given code. > > element{fn:name($node)} { > ..... > > } > > > > > Thanks, > Abhinav Kumar Mishra > From: > [email protected]<mailto:[email protected]> > > [[email protected]<mailto:[email protected]>] > on behalf of Kapoor, Pragya > [[email protected]<mailto:[email protected]>] > Sent: Friday, November 21, 2014 10:04 AM > To: MarkLogic Developer Discussion > Subject: [MarkLogic Dev General] Namespaces are getting removed > > Hi, > > I am using men:node* function to update in-memory xml. > The code is removing the namespaces of all elements of the in-memory xml. > > Code: > xquery version "1.0-ml"; > import module namespace mem = "http://xqdev.com/in-mem-update" > at "/rest-apis/utils/mem.xqy"; > > declare variable $transId := 'test'; > let $amd := xdmp:invoke-function( > function() { > (fn:doc('/processing/test/amdDocs/test.xml')) > } , > <options xmlns="xdmp:eval"> > <database>{xdmp:database("Ingestion")}</database> > </options> > ) > let $doc := fn:doc('/docs/test.xml') > let $elements := $amd//*[@ID] > let $doc := > for $element in $elements > let $docElements := $doc//*[@ID = $element/@ID] > return > if($element/@ID = $docElements/@ID) then > (xdmp:set($doc,mem:node-replace($docElements, $element) ), > $doc) > else > let $amdParent := $element/.. > let $docParent := $doc//*[@Code = $amdParent/@Code] > return > (xdmp:set($doc, mem:node-insert-child($docParent, $element)), > $doc) > let $validDocs := $doc[fn:last()] > return $validDocs > > Data: > let $amd := <MAG:Document xmlns:NAV100PP="NAV100PP" xmlns:SE100="SE100" > xmlns:CSD100CP="CSD100CP" > xmlns:CAR100CP="CAR100CP" > xmlns:PET100="PET100" > xmlns:IM100CP="IM100CP" > xmlns:OP100="OP100" > xmlns:OF100PP="OF100PP" > xmlns:VAL100CP="VAL100CP" > xmlns:MIC100="MIC100" > xmlns:CEM100="CEM100" > xmlns:TH100CP="TH100CP" > xmlns:MRA="MRA" > xmlns:ECOLL100PP="ECOLL100PP" > xmlns:NAV100CP="NAV100CP" > xmlns:AF100="AF100" > xmlns:AD100="AD100" > xmlns:EOD100-4="EOD100-4" > xmlns:AP100="AP100" > xmlns:OF100CP="OF100CP" > xmlns:THRW100PP="THRW100PP" > xmlns:EOD100-3="EOD100-3" > xmlns:CEM100PP="CEM100PP" > xmlns:TH100="TH100" > xmlns:OES100PP="OES100PP" > xmlns:MSLA="MSLA" > xmlns:ECOLL100CP="ECOLL100CP" > xmlns:IME100PP="IME100PP" > xmlns:AF100PP="AF100PP" > xmlns:AD100PP="AD100PP" > xmlns:AT100PP="AT100PP" > xmlns:HIC100="HIC100" > xmlns:TAX100PP="TAX100PP" > xmlns:ROC100="ROC100" > xmlns:SUB100PP="SUB100PP" > xmlns:THRW100CP="THRW100CP" > xmlns:IR101="IR101" > xmlns:CEM100CP="CEM100CP" > xmlns:SIN100="SIN100" > xmlns:OES100CP="OES100CP" > xmlns:IME100CP="IME100CP" > xmlns:AF100CP="AF100CP" > xmlns:AD100CP="AD100CP" > xmlns:AT100CP="AT100CP" > xmlns:ANX100-1="ANX100-1" > xmlns:TAX100CP="TAX100CP" > xmlns:ROC100PP="ROC100PP" > xmlns:SUB100CP="SUB100CP" > xmlns:CTT100="CTT100" > xmlns:ATE100="ATE100" > xmlns:DD100="DD100" > xmlns:CRC100PP="CRC100PP" > xmlns:IME100="IME100" > xmlns:AL100="AL100" > xmlns:PA100="PA100" > xmlns:ANX100-3="ANX100-3" > xmlns:TAX100="TAX100" > xmlns:ROC100CP="ROC100CP" > xmlns:CPRE100="CPRE100" > xmlns:OCTH100PP="OCTH100PP" > xmlns:AET100PP="AET100PP" > xmlns:DD100PP="DD100PP" > xmlns:DN100PP="DN100PP" > xmlns:CRC100CP="CRC100CP" > xmlns:KM100="KM100" > xmlns:AL100PP="AL100PP" > xmlns:PA100PP="PA100PP" > xmlns:EOD100-2="EOD100-2" > xmlns:FTH100PP="FTH100PP" > xmlns:REP100PP="REP100PP" > xmlns:CA100="CA100" > xmlns:SIO100PP="SIO100PP" > xmlns:OCTH100CP="OCTH100CP" > xmlns:CPRE100PP="CPRE100PP" > xmlns:AET100CP="AET100CP" > xmlns:DD100CP="DD100CP" > xmlns:DN100CP="DN100CP" > xmlns:UPC100="UPC100" > xmlns:KM100PP="KM100PP" > xmlns:AL100CP="AL100CP" > xmlns:PA100CP="PA100CP" > xmlns:EHP100PP="EHP100PP" > xmlns:TER100="TER100" > xmlns:FTH100CP="FTH100CP" > xmlns:REP100CP="REP100CP" > xmlns:ST100="ST100" > xmlns:SIO100CP="SIO100CP" > xmlns:CPRE100CP="CPRE100CP" > xmlns:RD100PP="RD100PP" > xmlns:PN100="PN100" > xmlns:KM100CP="KM100CP" > xmlns:NA100="NA100" > xmlns:MB100PP="MB100PP" > xmlns:EHP100CP="EHP100CP" > xmlns:TER100PP="TER100PP" > xmlns:REP100="REP100" > xmlns:CD100PP="CD100PP" > xmlns:MSFTA="MSFTA" > xmlns:ROU100PP="ROU100PP" > xmlns:RD100CP="RD100CP" > xmlns:GOV100="GOV100" > xmlns:CSD100="CSD100" > xmlns:CC100PP="CC100PP" > xmlns:NA100PP="NA100PP" > xmlns:MB100="MB100" > xmlns:FMT100PP="FMT100PP" > xmlns:TER100CP="TER100CP" > xmlns:AET100="AET100" > xmlns:CD100CP="CD100CP" > xmlns:DA100PP="DA100PP" > xmlns:GMRA="GMRA" > xmlns:ROU100CP="ROU100CP" > xmlns:RD100="RD100" > xmlns:SE100PP="SE100PP" > xmlns:ATE_A100="ATE_A100" > xmlns:CC100CP="CC100CP" > xmlns:NA100CP="NA100CP" > xmlns:MB100CP="MB100CP" > xmlns:ANX100-2="ANX100-2" > xmlns:FMT100CP="FMT100CP" > xmlns:TC100="TC100" > xmlns:CD100="CD100" > xmlns:DA100CP="DA100CP" > xmlns:NAV100="NAV100" > xmlns:SE100CP="SE100CP" > xmlns:CSD100PP="CSD100PP" > xmlns:CAR100PP="CAR100PP" > xmlns:IM100PP="IM100PP" > xmlns:CC100="CC100" > xmlns:MISC100="MISC100" > xmlns:OF100="OF100" > xmlns:VAL100PP="VAL100PP" > xmlns:TEM100="TEM100" > xmlns:OTP100="OTP100" > xmlns:TH100PP="TH100PP" > xmlns:MAG="ISDA"> > <MAG:MetaInfo> > <MAG:CollectionNo>4043</MAG:CollectionNo> > <!-- Amendment document --> > <MAG:DocumentType>AGRT-AMD-DOC</MAG:DocumentType> > <MAG:AgreementDate>2015-03-27</MAG:AgreementDate> > <MAG:DocumentState>BAU</MAG:DocumentState> > <MAG:PdfPageRange>24-32</MAG:PdfPageRange> > </MAG:MetaInfo> > <MAG:Body> > <MAG:PartiesMisc> > <CP100:PartyDetails xmlns:CP100="CP100" Code="CP100"> > > <CP100CP:Counterparties xmlns:CP100CP="CP100CP" Code="CP100CP"> > <CP100CP:Counterparty ID='123'> > <CP100CP:Name PageNo="3" LineNo="21">INNODATA SERVICES, INC.</CP100CP:Name> > <CP100CP:Lei PageNo="3" LineNo="21">eeeee</CP100CP:Lei> > <CP100CP:EntityType PageNo="3" LineNo="21">CORPORATION</CP100CP:EntityType> > <CP100CP:JurisdictionOrganisation PageNo="3" > LineNo="21">Florida</CP100CP:JurisdictionOrganisation> > <CP100CP:AgentName PageNo="3" LineNo="11">mmmmm</CP100CP:AgentName> > <CP100CP:PartyStatus PageNo="3" LineNo="21">Terminated</CP100CP:PartyStatus> > <CP100CP:DF2Questionnaire> > </CP100CP:DF2Questionnaire> > <CP100CP:EMIRQuestionnaire> > </CP100CP:EMIRQuestionnaire> > </CP100CP:Counterparty> > > </CP100CP:Counterparties> > </CP100:PartyDetails> > </MAG:PartiesMisc> > <GOV100:GoverningLaw ID='2' Code="GOV100"> > <!-- Changed --> > <GOV100:Governing_Law PageNo="11" > LineNo="14">Alabama</GOV100:Governing_Law> > > </GOV100:GoverningLaw> > </MAG:Body> > </MAG:Document> > let $doc := <MAG:Document xmlns:NAV100PP="NAV100PP" xmlns:SE100="SE100" > xmlns:CSD100CP="CSD100CP" > xmlns:CAR100CP="CAR100CP" > xmlns:PET100="PET100" > xmlns:IM100CP="IM100CP" > xmlns:OP100="OP100" > xmlns:OF100PP="OF100PP" > xmlns:VAL100CP="VAL100CP" > xmlns:MIC100="MIC100" > xmlns:CEM100="CEM100" > xmlns:TH100CP="TH100CP" > xmlns:MRA="MRA" > xmlns:ECOLL100PP="ECOLL100PP" > xmlns:NAV100CP="NAV100CP" > xmlns:AF100="AF100" > xmlns:AD100="AD100" > xmlns:EOD100-4="EOD100-4" > xmlns:AP100="AP100" > xmlns:OF100CP="OF100CP" > xmlns:THRW100PP="THRW100PP" > xmlns:EOD100-3="EOD100-3" > xmlns:CEM100PP="CEM100PP" > xmlns:TH100="TH100" > xmlns:OES100PP="OES100PP" > xmlns:MSLA="MSLA" > xmlns:ECOLL100CP="ECOLL100CP" > xmlns:IME100PP="IME100PP" > xmlns:AF100PP="AF100PP" > xmlns:AD100PP="AD100PP" > xmlns:AT100PP="AT100PP" > xmlns:HIC100="HIC100" > xmlns:TAX100PP="TAX100PP" > xmlns:ROC100="ROC100" > xmlns:SUB100PP="SUB100PP" > xmlns:THRW100CP="THRW100CP" > xmlns:IR101="IR101" > xmlns:CEM100CP="CEM100CP" > xmlns:SIN100="SIN100" > xmlns:OES100CP="OES100CP" > xmlns:IME100CP="IME100CP" > xmlns:AF100CP="AF100CP" > xmlns:AD100CP="AD100CP" > xmlns:AT100CP="AT100CP" > xmlns:ANX100-1="ANX100-1" > xmlns:TAX100CP="TAX100CP" > xmlns:ROC100PP="ROC100PP" > xmlns:SUB100CP="SUB100CP" > xmlns:CTT100="CTT100" > xmlns:ATE100="ATE100" > xmlns:DD100="DD100" > xmlns:CRC100PP="CRC100PP" > xmlns:IME100="IME100" > xmlns:AL100="AL100" > xmlns:PA100="PA100" > xmlns:ANX100-3="ANX100-3" > xmlns:TAX100="TAX100" > xmlns:ROC100CP="ROC100CP" > xmlns:CPRE100="CPRE100" > xmlns:OCTH100PP="OCTH100PP" > xmlns:AET100PP="AET100PP" > xmlns:DD100PP="DD100PP" > xmlns:DN100PP="DN100PP" > xmlns:CRC100CP="CRC100CP" > xmlns:KM100="KM100" > xmlns:AL100PP="AL100PP" > xmlns:PA100PP="PA100PP" > xmlns:EOD100-2="EOD100-2" > xmlns:FTH100PP="FTH100PP" > xmlns:REP100PP="REP100PP" > xmlns:CA100="CA100" > xmlns:SIO100PP="SIO100PP" > xmlns:OCTH100CP="OCTH100CP" > xmlns:CPRE100PP="CPRE100PP" > xmlns:AET100CP="AET100CP" > xmlns:DD100CP="DD100CP" > xmlns:DN100CP="DN100CP" > xmlns:UPC100="UPC100" > xmlns:KM100PP="KM100PP" > xmlns:AL100CP="AL100CP" > xmlns:PA100CP="PA100CP" > xmlns:EHP100PP="EHP100PP" > xmlns:TER100="TER100" > xmlns:FTH100CP="FTH100CP" > xmlns:REP100CP="REP100CP" > xmlns:ST100="ST100" > xmlns:SIO100CP="SIO100CP" > xmlns:CPRE100CP="CPRE100CP" > xmlns:RD100PP="RD100PP" > xmlns:PN100="PN100" > xmlns:KM100CP="KM100CP" > xmlns:NA100="NA100" > xmlns:MB100PP="MB100PP" > xmlns:EHP100CP="EHP100CP" > xmlns:TER100PP="TER100PP" > xmlns:REP100="REP100" > xmlns:CD100PP="CD100PP" > xmlns:MSFTA="MSFTA" > xmlns:ROU100PP="ROU100PP" > xmlns:RD100CP="RD100CP" > xmlns:GOV100="GOV100" > xmlns:CSD100="CSD100" > xmlns:CC100PP="CC100PP" > xmlns:NA100PP="NA100PP" > xmlns:MB100="MB100" > xmlns:FMT100PP="FMT100PP" > xmlns:TER100CP="TER100CP" > xmlns:AET100="AET100" > xmlns:CD100CP="CD100CP" > xmlns:DA100PP="DA100PP" > xmlns:GMRA="GMRA" > xmlns:ROU100CP="ROU100CP" > xmlns:RD100="RD100" > xmlns:SE100PP="SE100PP" > xmlns:ATE_A100="ATE_A100" > xmlns:CC100CP="CC100CP" > xmlns:NA100CP="NA100CP" > xmlns:MB100CP="MB100CP" > xmlns:ANX100-2="ANX100-2" > xmlns:FMT100CP="FMT100CP" > xmlns:TC100="TC100" > xmlns:CD100="CD100" > xmlns:DA100CP="DA100CP" > xmlns:NAV100="NAV100" > xmlns:SE100CP="SE100CP" > xmlns:CSD100PP="CSD100PP" > xmlns:CAR100PP="CAR100PP" > xmlns:IM100PP="IM100PP" > xmlns:CC100="CC100" > xmlns:MISC100="MISC100" > xmlns:OF100="OF100" > xmlns:VAL100PP="VAL100PP" > xmlns:TEM100="TEM100" > xmlns:OTP100="OTP100" > xmlns:TH100PP="TH100PP" > xmlns:MAG="ISDA"> > <MAG:MetaInfo> > <MAG:CollectionNo>4043</MAG:CollectionNo> > <!-- Amendment document --> > <MAG:DocumentType>AGRT-AMD-DOC</MAG:DocumentType> > <MAG:AgreementDate>2015-03-27</MAG:AgreementDate> > <MAG:DocumentState>BAU</MAG:DocumentState> > <MAG:PdfPageRange>24-32</MAG:PdfPageRange> > </MAG:MetaInfo> > <MAG:Body> > <MAG:PartiesMisc> > <CP100:PartyDetails xmlns:CP100="CP100" Code="CP100"> > > <CP100CP:Counterparties xmlns:CP100CP="CP100CP" Code="CP100CP"> > <CP100CP:Counterparty ID = '123'> > <CP100CP:Name PageNo="3" LineNo="21">INNODATA aa</CP100CP:Name> > <CP100CP:Lei PageNo="3" LineNo="21">eeeee1</CP100CP:Lei> > <CP100CP:EntityType PageNo="3" LineNo="21">CORPORATION</CP100CP:EntityType> > <CP100CP:JurisdictionOrganisation PageNo="3" > LineNo="21">Florida</CP100CP:JurisdictionOrganisation> > <CP100CP:AgentName PageNo="3" LineNo="11">mmmmm</CP100CP:AgentName> > <CP100CP:PartyStatus PageNo="3" LineNo="21">Terminated</CP100CP:PartyStatus> > <CP100CP:DF2Questionnaire> > </CP100CP:DF2Questionnaire> > <CP100CP:EMIRQuestionnaire> > </CP100CP:EMIRQuestionnaire> > </CP100CP:Counterparty> > > </CP100CP:Counterparties> > </CP100:PartyDetails> > </MAG:PartiesMisc> > <GOV100:GoverningLaw ID='2' Code="GOV100"> > <!-- Changed --> > <GOV100:Governing_Law PageNo="11" LineNo="14">New > York</GOV100:Governing_Law> > > </GOV100:GoverningLaw> > </MAG:Body> > </MAG:Document> > > Please help > > Thanks > Pragya > "This e-mail and any attachments transmitted with it are for the sole use of > the intended recipient(s) and may contain confidential , proprietary or > privileged information. If you are not the intended recipient, please contact > the sender by reply e-mail and destroy all copies of the original message. > Any unauthorized review, use, disclosure, dissemination, forwarding, printing > or copying of this e-mail or any action taken in reliance on this e-mail is > strictly prohibited and may be unlawful." > This e-mail and any files transmitted with it are for the sole use of the > intended recipient(s) and may contain confidential and privileged > information. If you are not the intended recipient(s), please reply to the > sender and destroy all copies of the original message. Any unauthorized > review, use, disclosure, dissemination, forwarding, printing or copying of > this email, and/or any action taken in reliance on the contents of this > e-mail is strictly prohibited and may be unlawful. Where permitted by > applicable law, this e-mail and other e-mail communications sent to and from > Cognizant e-mail addresses may be monitored. > _______________________________________________ > General mailing list > [email protected]<mailto:[email protected]> > http://developer.marklogic.com/mailman/listinfo/general _______________________________________________ General mailing list [email protected]<mailto:[email protected]> http://developer.marklogic.com/mailman/listinfo/general "This e-mail and any attachments transmitted with it are for the sole use of the intended recipient(s) and may contain confidential , proprietary or privileged information. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this e-mail or any action taken in reliance on this e-mail is strictly prohibited and may be unlawful."
_______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
