0

I am getting XML structure with missing parent node, so while passing this XML structure to XSLT i am getting error as "The markup in the document following the root element must be well-formed".

If i can add parent tag to the existing XML Structure, issue will be resolved. Can anyone help me here?

Below is the XML structure i am receiving:

<?xml version="1.0" encoding="UTF-8" ?>
<SARIETransferRq>
    <SARIETransferRqHeader>
        <CorporateID>Sample123</CorporateID>
        <CorpReferenceNumber>Sample123</CorpReferenceNumber>
    </SARIETransferRqHeader>
    <SARIETransferRqBody>
        <AccountNumber>0000111111111222222</AccountNumber>
        <DebitCurrency>SAR</DebitCurrency>
        <TransferAmount>12</TransferAmount>
        <TransferCurrency>SAR</TransferCurrency>
        <BeneficiaryName>SAMPLE NAME</BeneficiaryName>
        <BeneficiaryAccountNumber>Sample1231111111</BeneficiaryAccountNumber>
        <BeneficiaryAddress1>733r</BeneficiaryAddress1>
        <BeneficiaryAddress2>6Sample123y</BeneficiaryAddress2>
        <BeneficiaryAddress3>1Sample123ver</BeneficiaryAddress3>
        <BankBIC>AAAAAA</BankBIC>
        <PaymentDate>2021-02-24</PaymentDate>
        <Instructions1>qewerr</Instructions1>
        <Instructions2>luaba</Instructions2>
        <Instructions3>fadjiugu</Instructions3>
        <Instructions4>rifdij</Instructions4>
        <Description>sample description for service fee</Description>
        <AMLPurposeCode>BB</AMLPurposeCode>
    </SARIETransferRqBody>
</SARIETransferRq>
<Signature>
    <SignatureValue>sample</SignatureValue>
</Signature>

Desired Output:

<?xml version="1.0" encoding="UTF-8" ?>
<SampleRoot>
<SARIETransferRq>
    <SARIETransferRqHeader>
        <CorporateID>Sample123</CorporateID>
        <CorpReferenceNumber>Sample123</CorpReferenceNumber>
    </SARIETransferRqHeader>
    <SARIETransferRqBody>
        <AccountNumber>0000111111111222222</AccountNumber>
        <DebitCurrency>SAR</DebitCurrency>
        <TransferAmount>12</TransferAmount>
        <TransferCurrency>SAR</TransferCurrency>
        <BeneficiaryName>SAMPLE NAME</BeneficiaryName>
        <BeneficiaryAccountNumber>Sample1231111111</BeneficiaryAccountNumber>
        <BeneficiaryAddress1>733r</BeneficiaryAddress1>
        <BeneficiaryAddress2>6Sample123y</BeneficiaryAddress2>
        <BeneficiaryAddress3>1Sample123ver</BeneficiaryAddress3>
        <BankBIC>AAAAAA</BankBIC>
        <PaymentDate>2021-02-24</PaymentDate>
        <Instructions1>qewerr</Instructions1>
        <Instructions2>luaba</Instructions2>
        <Instructions3>fadjiugu</Instructions3>
        <Instructions4>rifdij</Instructions4>
        <Description>sample description for service fee</Description>
        <AMLPurposeCode>BB</AMLPurposeCode>
    </SARIETransferRqBody>
</SARIETransferRq>
<Signature>
    <SignatureValue>sample</SignatureValue>
</Signature>
</SampleRoot>

```````````````````````````````````````````````````````````
1
  • 1
    What technology are you using to process this message? You will probably have to turn it into valid XML before passing it to the XSLT. Commented Jun 20, 2022 at 5:13

2 Answers 2

1

Your file is not a well-formed XML document, so it can't be processed "as-is" by XSLT. However, it is a well-formed XML entity, so it can be incorporated by reference into a well-formed XML document (provided the XML parser resolves external entities, which not all do these days, because of questionable security concerns).

Create a file like this:

<!DOCTYPE SampleRoot [
<!ENTITY e SYSTEM "my.xml">
]>
<SampleRoot >&e;</SampleRoot>

where my.xml is your XML fragment, and pass this wrapper document as the input to the XSLT processor.

Sign up to request clarification or add additional context in comments.

Comments

0

You can't parse this in XSLT 1.0, I'm afraid. It needs to be well-formed XML.

You will need to use some other tool to strip off the first line, containing the XML declaration (which is optional, and doesn't say anything useful), and then enclose the result in SampleRoot tags.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.