[XML Records] XMLtoRecordList namespaces conversion problems
Question
xml-records
Service icon
Forge component by Afonso Carvalho

Hello,

The xml I want convert to a record list looks like this: 

<n1:Message xmlns:base="http://namespace.com/test" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://namespace.com/test2" xmlns:n1="http://namespace.com/test2" xsi:schemaLocation="http://namespace.com/test.xsd">
  <base:OrderId>04883999</base:OrderId>
  <base:Version>1</base:Version>
  <n1:Assignment>
    <n1:Code>87108758327</n1:Code>
    <n1:Tasks>
      <tns:Number>1</tns:Number>
      <tns:Description>Intake</tns:Description>
    </n1:Tasks>
  </n1:Assignment>
</n1:Message>


I'am having troubles converting the xml to a record list. 

1) Is it possible to convert this xml with multiple namespaces?

2) If so, how does the configuration of the XMLToRecordList look like?

3) Or do you suggest to delete the namespace prefixes (e.g. n1: or tns) before using the XMLToRecordList?


Kind regards,

Rik

mvp_badge
MVP
Solution

Hi,

It's possible to do this, but it's a bit awkward. I hardcoded an example of an XML with multiple namespaces into the demo espace:


Attached the OML for a code example (ReadXML action in the XmlToRecordList page), let me know if you have any questions.

XMLRecordsDemowithnamespacechanges.oml

Thanks

This works although the xml is actually much bigger so its getting complex and isn't well maintainable.

For later readers of this topic; use Record mode = "C" to get the nesting you want.

Thanks, this example helped me a lot!

mvp_badge
MVP

Nice. I completely forgot about RecordMode, I don't think I've ever had the need to use it. I'll update the FAQ since this is a common enough use case, and like you've discovered, it's not immediately obvious how you're supposed to implement this.

Hi,

Can  somebody explain to me how you got this filled ? 

I can't find anything in the project here above.

I've been searching for days to have multiple prefixes like this:

<Invoice xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"           xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"    xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2">    <cbc:CustomizationID>urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0</cbc:CustomizationID>

  <cbc:ProfileID>urn:fdc:peppol.eu:2017:poacc:billing:01:1.0</cbc:ProfileID>

    <cbc:ID>Snippet1</cbc:ID>

    <cbc:IssueDate>2017-11-13</cbc:IssueDate>

    <cbc:DueDate>2017-12-01</cbc:DueDate>

    <cbc:InvoiceTypeCode>380</cbc:InvoiceTypeCode>


Can Someone help me?

Error @ outsystems : 'cbc' is an undeclared prefix. Line 1, position 74. 

mvp_badge
MVP

Hello Dieusaert,

RikVDN's code snippet illustrates an example of multiple namespaces in the same XML file. How are you filling out your XMLConfig input structure? Would you be willing to share a code sample for everyone to look over?

Hello Afonso Carvalho,

It is a great example and i learned a lot from it, but i can't find where to put multiple prefixes in the config, also not in the example or i over looked it..

This is my config:

Now i get the error that cbc is not defined , true.. but where can i define cbc ? 

Here is an example of the xml i need to generate:

https://github.com/OpenPEPPOL/peppol-bis-invoice-3/blob/master/rules/examples/base-example.xml

Greetings

mvp_badge
MVP

I believe you need to use the Namespace input: "urn:oasis..." seems to be a value in your example, and not a namespace.


<Invoice xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"

xmlns:qdt="urn:oasis:names:specification:ubl:schema:xsd:QualifiedDataTypes-2"

xmlns:udt="urn:oasis:names:specification:ubl:schema:xsd:UnqualifiedDataTypes-2"

xmlns:ccts="urn:un:unece:uncefact:documentation:2"

xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2">

These are the namespaces i need to add.. 

On this moment only the last xmlns=""  is added

How can i add xmlns:cbc or xmlns:cac and so on? In the example above it is not explained where.. 

example in microsoft docs..

https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ms754539(v=vs.85)#:~:text=about%20XML%20namespaces.-,What%20Is%20an%20XML%20Namespace%3F,elements%20with%20the%20same%20name.

This line:

<RecordList xmlns:xxx="http://namespace.com/test" xmlns:n1="http://namespace.com/test2" xmlns:n2="http://namespace.com/test3" >

Where did you define this?

nobody?

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