Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using the .Up() method does not really move up to the parent node #81

Closed
jarvisRam opened this issue Mar 18, 2021 · 0 comments
Closed

Comments

@jarvisRam
Copy link

Hi, I am building my XML block by block by returning a pretty XML from each block. While doing so, the .Up() does not seem to really take me up to the parent node when am moving up form a block that sits as a separate method.

This is where I start the XML,

public buildMessageWithoutDelay = (locationPrimaryCode: string, locationSubsidiaryCode: string,
                                     operationalTrainNumber: string, trainUID: string,
                                     scheduledStartDate: string, messageType: string) => {
    const currentTimeHour = this.currentTimeHour();
    return create().ele('TrainRunningInformationMessage').att('xmlns:ns0', 'http://www.era.europa.eu/schemes/TAFTSI/5.3')
      .att('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance').att('xsi:schemaLocation', 'http://www.era.europa.eu/schemes/TAFTSI/5.3 taf_cat_complete.xsd')
      .ele(TrainRunningInformationMessageHeader.messageHeader(operationalTrainNumber, trainUID, currentTimeHour)).root()
      .ele(this.messageStatus()).root()
      .doc();
  }

This here is the TrainRunningInformationMessageHeader.messageHeader(): Problem seems to occur when I move up from the TrainRunningInformationMessageHeader.messageReference()

public static messageHeader = (trainNumber: string, trainUid: string, hourDepartFromOrigin: number) => {
    const senderReference = TrainRunningInformationMessageHeader.calculateSenderReference(trainNumber, trainUid, hourDepartFromOrigin);
    const messageHeaderObj = fragment().ele('MessageHeader')
      .ele(TrainRunningInformationMessageHeader.messageReference()).up()
      .ele('SenderReference').txt(senderReference).up()
      .ele('Sender', {'ns0:CI_InstanceNumber': '01'}).txt('0070').up()
      .ele('Recipient', {'ns0:CI_InstanceNumber': '99'}).txt('9999').up()
      .doc();
    return messageHeaderObj.end({prettyPrint: true});
  }

This here is the TrainRunningInformationMessageHeader.messageReference():

public static messageReference = (messageDateTime: any = TrainRunningInformationMessageHeader.runDateTime) => {
    const messageReferenceObj = fragment().ele('MessageReference')
      .ele('MessageType').txt('4005').up()
      .ele('MessageTypeVersion').txt('5.3.1.GB').up()
      .ele('MessageIdentifier').txt('414d51204e52504230303920202020205e504839247eb882').up()
      .ele('MessageDateTime').txt(messageDateTime).up()
      .doc();
    return messageReferenceObj.end({prettyPrint: true});
  }

I get the output as below while I'd expect the closing of 'MessageHeader' to happen only after 'Recipient' while in my case the closure happens right after the external block ends even-though am using the .up() to move to the parent node

<?xml version="1.0"?>
<TrainRunningInformationMessage xmlns:ns0="http://www.era.europa.eu/schemes/TAFTSI/5.3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.era.europa.eu/schemes/TAFTSI/5.3 taf_cat_complete.xsd">
  <MessageHeader>
    <MessageReference>
      <MessageType>4005</MessageType>
      <MessageTypeVersion>5.3.1.GB</MessageTypeVersion>
      <MessageIdentifier>414d51204e52504230303920202020205e504839247eb882</MessageIdentifier>
      <MessageDateTime>2021-03-18T17:27:54.562</MessageDateTime>
    </MessageReference>
  </MessageHeader>
  <SenderReference>1B25LMJp-H5K</SenderReference>
  <Sender ns0:CI_InstanceNumber="01">0070</Sender>
  <Recipient ns0:CI_InstanceNumber="99">9999</Recipient>
  <MessageStatus>1</MessageStatus>
</TrainRunningInformationMessage>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant