I have a XML string as i/p to a flow from which i am creating a record. I am
using stringToDocument and documentToRecord built-in services for this
purpose. But in the proces i am losing all the name space declarations
present in the XML. Is there way to get into this record object all the name
space declarations?.

Did you resolve this issue? I’m having the same issue using the documentToXMLString built-in service and would be curious if you found a resolution. I’ve tried setting the namespaces in the optional nsDecls parameter, but had no luck.

Thanks for any help you can offer.

We have also detected lots of problems while using namespaces.

The only way to maintain the namespace declarations is “hardcoding” them in the nsDecls parameter (that means you need to know which namespaces will appear in design time rather than in execution time…). In addition, the use of this parameter only allows to place the namespaces definitions in the root tag (if the original document had some declarations in another tag, they will be moved).

Another option is changing the document definition by adding the namespaces declarations as atttributes (with the name @xmlns). Once populated in a service you can then execute documentToXMLString without providing the nsDecls parameter.

Unfortunatelly, all the solutions are just work-arounds as no dynamic handling of the namespaces is allowed.