Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating an xml with a .prg (having issues)

Filip Brnic

Programmer
Dec 25, 2023
70
RS
Hello everyone, I've been stuck on this for some time, I didn't really create xmls through fox, and neither did i work with them that much, i understand the syntax and the rules that i should open and close the tag, so now I'm confused why my code is giving me errors. I've used an example code from one other programmer, but he isn't coming anytime soon so I've tried to create it myself since there is a new law in Serbia that requires this xml.
Long story short i need to create the XML with this exact schema, values are gonna differ because they are gonna go directly from our program, this is the link to that xml: https://eotpremnica.efaktura.gov.rs/extfile/sr/5452/eOtpremnica UBL pr 001.xml
Now here is my code:


I think i made a mistake in defining those prefixes in my code, but i don't really understand why it doesn't work,
Because when i checked the code from my programmer and tried to run his xml, it worked just fine

I hope someone knows where I've made a mistake, if you want you can just copy my code into a prg and try in yourself, the values aren't from any tables for now so it should work, but again opening it on a browser is where it gets funky

* I had to attach it as a txt file because i cant attach prgs.
 

Attachments

  • LOCAL gnErrFile, red.txt
    34 KB · Views: 15
Last edited:
from red='<cec:UBLEtension>'
to red='<cec:UBLExtension>'


from red='<cbc:Name>Klasa opasnosti</cbc:Value>'
to red='<cbc:Name>Klasa opasnosti</cbc:Name>'

from red='<cbc:ID>urn:fdc:peppol.eu.logistics:bih:despatch_advice_only:1</cbc:profileID>'
to red='<cbc:ID>urn:fdc:peppol.eu.logistics:bih:despatch_advice_only:1</cbc:ID>'

from red='<cac:attachment>'
to red='<cac:Attachment>'

from red='</cac:partyIdentifiaction>'
to red='</cac:partyIdentification>'

from red='<cbc:StreetName>KNEZA MILOSA</cbc:Name>'
to red='<cbc:StreetName>KNEZA MILOSA</cbc:StreetName>'

from red='</cacPostalAddress>'
to red='</cac:postalAddress>'

and more equals bugs
 
Code contains many bugs...

  • XML is Case Sensitive
  • Missing start/end elements
  • Missing prefixes
 

Attachments

  • filip3.txt
    11.4 KB · Views: 6
Hey @mJindrova ive rewrote my code and i've tried running it. i think something in the first line here is wrong, because it doesnt get past it on the browser.
This is the code, and the error i got is: error on line 1 at column 1: Start tag expected, '<' not found
Code:
red=chr(239)+chr(187)+chr(191)+'<?xml version="1.0" encoding="utf-8"?>'
=FWRITE(gnErrFile, '&red'+chr(13)+chr(10))
red='<DespatchAdvice xmlns:cec="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"'
=FWRITE(gnErrFile, '&red'+chr(13)+chr(10))
red='xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"'
=FWRITE(gnErrFile, '&red'+chr(13)+chr(10))
red='xmlns:sbt="http://mfin.gov.rs/srbdt/srbdtext" xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2">'
=FWRITE(gnErrFile, '&red'+chr(13)+chr(10))
red='<cbc:CustomizationID>urn:cen.eu:en16931:2017#compliant#urn:mfin.gov.rs:srbdt:2021</cbc:CustomizationID>'
=FWRITE(gnErrFile, '&red'+chr(13)+chr(10))
 
Hey @mJindrova ive rewrote my code and i've tried running it. i think something in the first line here is wrong, because it doesnt get past it on the browser.
This is the code, and the error i got is: error on line 1 at column 1: Start tag expected, '<' not found
Code:
red=chr(239)+chr(187)+chr(191)+'<?xml version="1.0" encoding="utf-8"?>'
=FWRITE(gnErrFile, '&red'+chr(13)+chr(10))
red='<DespatchAdvice xmlns:cec="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"'
=FWRITE(gnErrFile, '&red'+chr(13)+chr(10))
red='xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"'
=FWRITE(gnErrFile, '&red'+chr(13)+chr(10))
red='xmlns:sbt="http://mfin.gov.rs/srbdt/srbdtext" xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2">'
=FWRITE(gnErrFile, '&red'+chr(13)+chr(10))
red='<cbc:CustomizationID>urn:cen.eu:en16931:2017#compliant#urn:mfin.gov.rs:srbdt:2021</cbc:CustomizationID>'
=FWRITE(gnErrFile, '&red'+chr(13)+chr(10))
Ive fixed it and it works, i had an extra row above that was just FWRITE, i thank you from the bottom of my heart, thank you so much!!!!
 

Part and Inventory Search

Sponsor

Back
Top