Rename file from content of an xml

More
2 years 2 months ago #23816 by downing
Hello Mike,

When importing the xml, a new case has now been added.

I have now tried to adjust the XLST so that it does not do the last "_" if the "Positions/PurchaseOrderPositionId" is empty.
Somehow I always get error messages.

Can you help me where to put the if/else?

pinv_<xsl:apply-templates select="ReceiverId"/>_<xsl:apply-templates select="SenderAddress/Id"/>_<xsl:apply-templates select="InvoiceNum"/>_<xsl:apply-templates select="Positions/PurchaseOrderPositionId"/>

<xsl:template match="PurchaseOrderPositionId">
<!-- Call the remove-special-chars template to clean the text content -->
<xsl:call-template name="remove-special-chars">
<xsl:with-param name="text" select="."/>
</xsl:call-template>
</xsl:template>

Thanks in advance
Thomas

Please Log in or Create an account to join the conversation.

More
2 years 2 months ago #23819 by Peter.Jonson
Am I correct in my assumption

That the file name looks like this:
pinv_1010_58044_INV24A004-30.pdf
But you want it to be PDF:pinv_1010_58044_INV24A004-30_.pdf?

Peter Jonson
ETL Developer

Please Log in or Create an account to join the conversation.

More
2 years 2 months ago #23820 by downing
Hello Peter,

Thanks for the quick reply.

I may not have the latest Atrribut available.

<xsl:apply-templates select="Positions/PurchaseOrderPositionId"/>

Then it does:
pinv_1010_500164_CAQS051524A-1_.pdf
instead of
pinv_1010_500164_CAQS051524A-1.pdf

Greetings
Thomas

Please Log in or Create an account to join the conversation.

More
2 years 2 months ago #23821 by Peter.Jonson
I think in this case it is easier to use calculation.

We will create for you an example.

Peter Jonson
ETL Developer

Please Log in or Create an account to join the conversation.

More
2 years 2 months ago #23822 by downing
Thx
Peter

Please Log in or Create an account to join the conversation.

More
2 years 2 months ago #23824 by Peter.Jonson
Please try this calculation

var FileName: String;
begin
 FileName := GetVariable('<xml-file>');
 FileName := ExtractFileName(FileName);
 FileName := ChangeFileExt(FileName,'');
 if (FileName[Length(FileName)]='_') then
  begin
   FileName:=Copy(FileName,0,Length(FileName)-1);
  end;
 FileName := FileName+'.pdf';
 SetVariable('<pdf-file>',FileName);
 Result:=True;
end;

Peter Jonson
ETL Developer

Please Log in or Create an account to join the conversation.

Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Read more
Marketing
Set of techniques which have for object the commercial strategy and in particular the market study.
Google
Accept
Decline
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline
Google Analytics
Accept
Decline
Functional
Tools used to give you more features when navigating on the website, this can include social sharing.
Advertisement
If you accept, the ads on the page will be adapted to your preferences.
Google Ad
Accept
Decline
Save