[XML Records] Add namespace to XML element
Question
Forge component by Afonso Carvalho
Service Studio Version
11.11.4 (Build 43813)

I need to create an XML with a structure like this:


<?xml version=""1.0"" encoding=""UTF-8""?>

<saml2:Assertion xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion" >

      <Issuer>blablalbla/Issuer>

      <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#"> <ds:SignedInfo>  ...........

</saml2:Assertion>


I have managed to create the XML document itself (using the XMLRecords and XML extensions), but I can't find any server action to add the namespace to a specific XML element (like "saml2" for the Assertion element and "ds" for the Signature element in the above example). 

Any clues how to to get this done?


Regards.

John.

mvp_badge
MVP
Solution

Hello John,

Multiple namespaces are a tricky usecase because they require specific structures and naming aliases in the XMLRecords inputs. I believe the last question in the component FAQ (My XML has multiple namespaces and the fields aren't mapping correctly to my output structure) has a quick outline of what you'll need to implement for this, as well as the thread João mentions. The example in the thread is to interpret XML into a Record List, and as I understand it, your requirement is the same, only backwards.

As I mention in the FAQ, this can get cumbersome depending on how many namespaces you want to support, as well as the complexity of your XML structure. If you find that you require too many aliases, it may be worth it to consider if you should implement some sort of postprocessing instead. For instance, by searching the output of the XMLRecords generation, and replacing "<Assertion" with "<saml2:Assertion".

Let us know if you have any questions.

mvp_badge
MVP

Hi John,


There's already a support ticket with what it seems to be the same issue here.

Can you check if the solution in that issue solves your problem?


Kind Regards,
João

mvp_badge
MVP
Solution

Hello John,

Multiple namespaces are a tricky usecase because they require specific structures and naming aliases in the XMLRecords inputs. I believe the last question in the component FAQ (My XML has multiple namespaces and the fields aren't mapping correctly to my output structure) has a quick outline of what you'll need to implement for this, as well as the thread João mentions. The example in the thread is to interpret XML into a Record List, and as I understand it, your requirement is the same, only backwards.

As I mention in the FAQ, this can get cumbersome depending on how many namespaces you want to support, as well as the complexity of your XML structure. If you find that you require too many aliases, it may be worth it to consider if you should implement some sort of postprocessing instead. For instance, by searching the output of the XMLRecords generation, and replacing "<Assertion" with "<saml2:Assertion".

Let us know if you have any questions.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.