• Introducing Dark Mode! Switch by clicking on the lightbulb icon next to Search or by clicking on Default style at the bottom left of the page!

Get parent node tag only if it exists

Sbau

Member
Hi everyone,

I'am struggling with something. I have a xml file where there are 2 invoices. For each invoice there is a SHAN tag. There is also a tag MSG0809_DS01_ID263 taht is in the 1st invoice, but not the second. It looks like this:

<R574256A>
<Numero_de_Facture_LBH_DOC_S6>
...
<DocVoucherInvoiceE_ID16>21201599</DocVoucherInvoiceE_ID16>
<DocumentOrderInvoiceE_ID189>11062505</DocumentOrderInvoiceE_ID189>
<OrderType_ID191>CV</OrderType_ID191>
...
<Client_Livre_LBH_SHAN_S8>
<AddressNumberShipTo_ID2>48612760</AddressNumberShipTo_ID2>
</Client_Livre_LBH_SHAN_S8>
</Numero_de_Facture_LBH_DOC_S6>
<Numero_de_Facture_LBH_DOC_S6>
...
<DocVoucherInvoiceE_ID16>21201603</DocVoucherInvoiceE_ID16>
<DocumentOrderInvoiceE_ID189>11081454</DocumentOrderInvoiceE_ID189>
<OrderType_ID191>CV</OrderType_ID191>
<MSG0809_DS01_ID263>REGUL POUR ERREUR FACTURATION DU 21/04</MSG0809_DS01_ID263>
...
<Client_Livre_LBH_SHAN_S8>
<AddressNumberShipTo_ID2>48923171</AddressNumberShipTo_ID2>
</Client_Livre_LBH_SHAN_S8>
</Numero_de_Facture_LBH_DOC_S6>
</R574256A>

I am interested in the MSG0809_DS01_ID263 tag, that exists only in the second invoice tag. This is just a text message that sometimes appear on an invoice or not.

In my rtf, I have a for each group on Client_Livre_LBH_SHAN_S8. Inside this group, I want to print the MSG0809_DS01_ID263. So I used the command : <?../MSG0809_DS01_ID263?> to get the tag from the parent node.

My problem is that when I run the rtf onto a pdf, the value of MSG0809_DS01_ID263 appears on BOTH invoices. My understanding is that the XPath command "../" gets every SIBLINGS of the current parent node - and since MSG0809_DS01_ID263 is not in the first invoice, the XPath process gets it in the second invoice.

Is there anyway I can force the program to get MSG0809_DS01_ID263 only from the parent of the current node, and only there?

Thank you very much for your help,

Samuel
 

Sbau

Member
Hello everyone,

I made some tests, so here are 2 simple rtf and xml files.

I am just trying to NOT display the MSG0809_DS01_ID263 in the "detail" part of the first invoice...

Any help would be greatly appreciated.

Thanks,
Samuel
 

Attachments

Dana BY

Member
Hi. I run you rtf in pdf and this is the text I see:
INVOICE BEGIN
Doc Number 21201599
Message :
SHIP TO BEGIN
Adress number : 48612760
Message
END SHIP TO
END INVOICE
--- -- -- --- --- ----
INVOICE BEGIN
Doc Number 21201603
Message : REGUL POUR ERREUR FACTURATION DU 21/04
SHIP TO BEGIN
Adress number : 48923171
Message REGUL POUR ERREUR FACTURATION DU 21/04
END SHIP TO
END INVOICE
--- -- -- --- --- ----

So, well, it doesn't show the message for the first invoice, I guess. Or do you need to delete the word "message" as well?
 

Sbau

Member
Hi,

Apparently, this a BIPublisher Issue that is fixed with version 12.2.

My tests were running on version 11.1.

Incredible...
 

jileto

Well Known Member
Hi,

Apparently, this a BIPublisher Issue that is fixed with version 12.2.

My tests were running on version 11.1.

Incredible...
I can recreate your issue. To fix it, use subtemplates to isolate node data. In your example, if you want to process data from node Numero_de_Facture_LBH_DOC_S6 only, then create a subtemplate to process only data from that node. It like subroutines for BIP.

That is what I did below. I created a subtemplate called Invoice to process just the data for the Numero_de_Facture_LBH_DOC_S6 node. Then I called that subtemplate in the Numero_de_Facture_LBH_DOC_S6 loop. Of course, if you don't want to display the empty "Message" labels, you can add conditions to suppress it if MSG0809_DS01_ID263 is null or empty.

<?for-each:Numero_de_Facture_LBH_DOC_S6?>
<?call:Invoice?>
<?end for-each?>
<?template:Invoice?>
INVOICE BEGIN
Doc Number <?DocVoucherInvoiceE_ID16?>
Message : <?MSG0809_DS01_ID263?>

<?for-each:Client_Livre_LBH_SHAN_S8?>
SHIP TO BEGIN
Adress number : <?AddressNumberShipTo_ID2?>
Message <?../MSG0809_DS01_ID263?>
END SHIP TO
<?end for-each?>
END INVOICE
--- -- -- --- --- ----
<?end template?>

I was using BIP Desktop 11.1.1.7
 
Last edited:
Top