Rename file from content of an xml

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

I don't quite understand it.

I have different XML which may or may not have the tag "Positions/PurchaseOrderPositionId".

If I have the tag it should:

pinv_1010_500164_CAQS051524A-1_12TAG34.pdf
if not
pinv_1010_500164_CAQS051524A-1.pdf

But now it does:
pinv_1010_500164_CAQS051524A-1_.pdf

I don't quite understand what he is doing here:
if (FileName[Length(FileName)]='_')

Thanks for your support
Thomas

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

More
2 years 2 months ago #23826 by admin
Let me double check

Mike
ETL Architect

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

More
2 years 2 months ago #23827 by admin
Underscores are rather difficult to work with in unicode word because there are several of them which look exactly the same
en.wikipedia.org/wiki/Underscore

Anyway I have found a way of dealing with missing tags just by using xslt

All you need to is to delete underscores and insert one tag 

 

 

Mike
ETL Architect

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

More
2 years 2 months ago #23828 by admin
I have attached package and XSLT for your convenience.

Mike
ETL Architect
Attachments:

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

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

Works great.
Thanks for your solution.

Now they have come up with a new requirement.

I changed "Positions/PurchaseOrderPositionId" to "PurchaseOrderNum" because they want the info from the head now.
pinv_<xsl:apply-templates select="ReceiverId"/><xsl:apply-templates select="SenderAddress/Id"/><xsl:apply-templates select="InvoiceNum"/><xsl:apply-templates select="PurchaseOrderNum"/>.pdf

However, there may now be several PurchaseOrderNum in the header.
But the first one is sufficient for us.
Can I tell the xlst that it should only take the first PurchaseOrderNum?

Thank you and sorry
Thomas
The following user(s) said Thank You: admin

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

More
2 years 2 months ago #23831 by admin
This can done by adding a number EG: PurchaseOrderNum[1]

Mike
ETL Architect

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