Hi,
in a given XML, I have a node that contains the number 2, but this may also be any other number up to 99.
For later usage, I need to add a leading zero to all single digit numbers. Is this possible with a Metadata expression?
I currently use [Metadata.Integer:Dataset="Xml",Model="XML",Path="/daten/kopf_und_posten_daten/positionen/position/FortlaufendeBelegPosition"] to get the number, but have not beed able to add a the 0.
Maybe someone can help or tell if this is even possible.
Thanks and have a nice weekend
Nico
Metadata: Add a leading zero to a single digit number
-
- Member
- Posts: 93
- Joined: Fri Jul 08, 2011 10:31 am
- Location: The Netherlands
Re: Metadata: Add a leading zero to a single digit number
Hi Nico,
This works for me (on another xml):
For you it would be this (not tested):
Note that it uses a Matadata.Text instead of Metadata.Integer
Robert
This works for me (on another xml):
Code: Select all
[Metadata.Text:Dataset="BatchJdf",Model="XML",Path="substring(concat('0' , //dn:GeneralID[@IDUsage='batchQuantity']/@IDValue), 4 - string-length(//dn:GeneralID[@IDUsage='batchQuantity']/@IDValue))"]
Code: Select all
[Metadata.Text:Dataset="BatchJdf",Model="XML",Path="substring(concat('0' , /daten/kopf_und_posten_daten/positionen/position/FortlaufendeBelegPosition), 4 - string-length(/daten/kopf_und_posten_daten/positionen/position/FortlaufendeBelegPosition))"]
Robert
- magnussandstrom
- Advanced member
- Posts: 365
- Joined: Thu Jul 30, 2020 6:34 pm
- Location: Sweden
- Contact:
Re: Metadata: Add a leading zero to a single digit number
Hi Nico,
If you don't have the scripting module you could do this:
Set job Private data:
Then use the app Private Data Magician to add a leading zero for 1-9:
Now you can use the private data field FortlaufendeBelegPosition and the single digits will have a leading zero.
Maybe not the prettiest solution but it works.
If you don't have the scripting module you could do this:
Set job Private data:
Code: Select all
FortlaufendeBelegPosition=[Metadata.Integer:Dataset="Xml",Model="XML",Path="/daten/kopf_und_posten_daten/positionen/position/FortlaufendeBelegPosition"]
Now you can use the private data field FortlaufendeBelegPosition and the single digits will have a leading zero.
Maybe not the prettiest solution but it works.
Re: Metadata: Add a leading zero to a single digit number
Thanks to both of you. I will try these