0

I have a Script which can convert MSG-IDs (MSG-ID placed on our DB) into XML files.

Here an Example for converting one MSID into XML

getDXML xxxxxMSGIDxxxxxx > filename.xml 

now I have more than 40 MSG-IDs and I want to convert them all at once with different names if possible

Here a part of it

<?xml version="1.0" encoding="UTF-8"?>
<message schemaLocation="http://postfinance.ch/deva/message BANCS_DEVA_Message.xsd">
    <MessageHeader>
        <MandantID>001001</MandantID>
        <MessageID>**201711221731-A_DEVA_ADHCORDNTF_AA-10500879**</MessageID>
        <Sender>BOMC</Sender>
        <SenderPlattform>T</SenderPlattform>
        <MessageType>00761</MessageType>
        <Receiver>DEVA</Receiver>
        <CommPattern>FF</CommPattern>
        <Prioritaet>normal</Prioritaet>
    </MessageHeader>
    <sendung>
        <ProcessingHeader>

closed as unclear what you're asking by roaima, G-Man, Archemar, Romeo Ninov, Stephen Rauch Nov 24 '17 at 16:42

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    We need to see an example of the file that includes one of these MessageIDs, along with the desired result. Otherwise all we might assume getDXML needed to do was to wrap its argument with <root> and </root>. – roaima Nov 23 '17 at 13:02
  • i did adjust my question above – ramadnay Nov 23 '17 at 13:24
  • 2
    @ramadnay, also post the desired output – RomanPerekhrest Nov 23 '17 at 13:38
  • XSLT is a very nice and unfairly forgotten technology. – peterh Nov 24 '17 at 5:06
  • @peterh maybe it's the awful documentation and dearth of examples for common solutions that it is missing. (Also wouldn't help here because we've not been given well-formed XML.) – roaima Nov 24 '17 at 8:07
1

First create the template

cat >template.notxml <<'X'
<?xml version="1.0" encoding="UTF-8"?>
<message schemaLocation="http://postfinance.ch/deva/message BANCS_DEVA_Message.xsd">
    <MessageHeader>
        <MandantID>001001</MandantID>
        <MessageID>#MESSAGEID#</MessageID>
        <Sender>BOMC</Sender>
        <SenderPlattform>T</SenderPlattform>
        <MessageType>00761</MessageType>
        <Receiver>DEVA</Receiver>
        <CommPattern>FF</CommPattern>
        <Prioritaet>normal</Prioritaet>
    </MessageHeader>
    <sendung>
        <ProcessingHeader>
X

Now create the files. I assume that you have your set of Message IDs in a list. In the absence of real detail I further assume that your Message IDs contain only letters, numbers, hyphens and underscores (A-Z, a-z, 0-9, -, _). Let's call this list ids.list.

while IFS= read -r messageid
do
    sed "s/#MESSAGEID#/$messageid/g" template.notxml > "$messageid.notxml"
done < ids.list
  • i think you missunderstood my Question, or i didnt explain it Good enough. What i Need ist extreme simple, with my script getDXML i can convert just one at the time. i Need a commend so that can happen --> getDxml xxxxxMSGIDxxxxx AND xxxxMSGIDxxxx > filename1.xml; filename2.xml, is that possibale in anyway ?? – ramadnay Nov 23 '17 at 15:02
  • @ramadnay if this answer doesn't address the question you had in your mind, please UPDATE YOUR QUESTION to explain more clearly what you are trying to achieve. Examples help tremendously because they reduce the amount of guesswork someone has to do. – roaima Nov 23 '17 at 15:53

Not the answer you're looking for? Browse other questions tagged or ask your own question.