Welcome! Log In Create A New Profile

Advanced

XML ( namespace )

Posted by Allard 
Allard
XML ( namespace )
August 25, 2015 11:07AM
Hi

I need to make and xml invoice file. So I have an xml that can be used, no xsd.

I use the second way to manage xml ( see code ):

sPath is string
xmlfact is xmlDocument ,description="UBL-Invoice"
xmlfact = XMLOpen("UBL-Invoice.xml")

I have the xml succesfully imported. And I can replace my data with the test data that is in the xml template.
So far all goes fine. However If I add extra invoice lines then a "prefix", an item that stand before the tagname is not added.

I have put a document in google docs so you can seen what I mean


link

After looking at it over and over again I read something about xmlespaces and it seems that the "prefixes" are namespaces that are declared in the template xml file.

OK My qusetion:

I guess windev cannot figger out the namespace from the templte xml. So I would have to add them manually. Is this possible?
And if I add the namespace in the declaration of the xml. and thus remove the tekst from the template xml. Will windev then use these prefixes ?

I hope this is a good explination of my problem. Iam just geting started with xml. I is possible to build the xml yourself but that is a lot more work and as the documentthat needs to be created is already quite complex that would be difficult to achief.

regards
Allard
Allard
Re: XML ( namespace )
August 26, 2015 12:20AM
Hi all who are interested,

I used the namespace to add schema location etc. These things where in the original template xml. It seems windev wants you to declare these yourself. After removing the lines windev recognized the prefix of the template xml.

I havenot solved all the problems I encoutered. But these are worth mentioning to anyone who wants to do some xml. The help on this topic is very pour!!

if you donnot add namespaces your self windev copies the xml templated and overwrites the content. If you profide namespaces this is not the case. It copies the template xml and doesnot overwrite it's content. New content is added. ( No errors in the newly added content).

This is strange behaviour. I have to figger out how to solve this.

If anyone of you has delt with this issue please respond this posting.

regards

Allard



Edited 1 time(s). Last edit at 08/26/2015 12:21AM by Allard.
Allard
Re: XML ( namespace )
August 26, 2015 10:34AM
Hi you all.

Hi you all. I have succesfully made the ubl invoicing ( Dutch version 1.1). However I have one issue left. I had to add the namespaces manually ( by code in windev, version 18 )
The order of these namespaces is where the final fault is. Does anyone know how to get the order as it should be.??


The order of My declaration:
<?xml version="1.0" encoding="UTF-8"?>
<Invoice SchemaLocation="urnyawning smileyasis:names:specification:ubl:schema:xsd:Invoice-2 [docs.oasis-open.org]; xmlns="urnyawning smileyasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns:cac="urnyawning smileyasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:cbc="urnyawning smileyasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:xsi="[www.w3.org];

The order in witch it should be:
<?xml version="1.0" encoding="UTF-8"?>
<Invoice xsi:schemaLocation="urnyawning smileyasis:names:specification:ubl:schema:xsd:Invoice-2 [docs.oasis-open.org]; xmlns:xsi="[www.w3.org]; xmlns:cbc="urnyawning smileyasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:cac="urnyawning smileyasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns="urnyawning smileyasis:names:specification:ubl:schema:xsd:Invoice-2">

link to a word doc. to see the code
My code for adding the namespaces:
xmlfact..Encoding = "UTF-8"
nNamespace1 is xmlNamespace
nNamespace2 is xmlNamespace
nNamespace3 is xmlNamespace
nNamespace4 is xmlNamespace
nNode is dynamic xmlNode
nNode = xmlfact.Invoice

nNamespace1..Name = "xsi"
nNamespace1..URI = "[www.w3.org];
nNamespace2..Name = "cbc"
nNamespace2..URI = "urnyawning smileyasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
nNamespace3..Name = "cac"
nNamespace3..URI = "urnyawning smileyasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
nNamespace4..URI = "urnyawning smileyasis:names:specification:ubl:schema:xsd:Invoice-2"
Add(nNode..NamespaceDeclared, nNamespace1)
nNodeconfused smileychemaLocation..Value = "urnyawning smileyasis:names:specification:ubl:schema:xsd:Invoice-2 [docs.oasis-open.org];
//nNodeconfused smileychemaLocation..Namespace = nNamespace1
Add(nNode..NamespaceDeclared, nNamespace2)
//nNodeconfused smileychemaLocation..Namespace = nNamespace2
Add(nNode..NamespaceDeclared, nNamespace3)
Add(nNode..NamespaceDeclared, nNamespace4)

If anyone is interested then I can post some stuff on how to generate an xml like the one I am talking about. Please let me know for if nobody is interrested it would be a bit of a waste of time to write an article on this.

Regards
Allard



Edited 1 time(s). Last edit at 08/26/2015 10:39AM by Allard.
Stefan Bentvelsen
Re: XML ( namespace )
August 29, 2015 07:07PM
Hi Allard,

I'm interested ...
aelfassi
Re: XML ( namespace )
August 29, 2015 09:48PM
Hi Allard,

I'm also interested

Thanks in advance
BartVdE
Re: XML ( namespace )
December 31, 2024 02:35PM
Hi Allard,

I am trying to build a UBL2.1 xml using your suggestions.

However, I am not able to add a prefix before every node in the xml (like "cbc" for example)
Is it possible to share some code how you accomplish that?
Do you have an example of an UBL xml file (for invoice) that you have imported in Windev?

Thanks for you help and wishing you a fine 2025.

Best regards
Re: XML ( namespace )
January 03, 2025 11:03PM
Hi are you from Holland?

I can import all the invoices made by dutch software that posted an example on the website of GBnet. On GBnet there is an example from my application as well so others can try importing .

On gb net there is documentation as well. That man Gerhard is a great help . He made an effort on RGS : "Referentie Grootboek Schema" as well


I have added all kind of stuff to the code . For instance it will add the invoice party to the system but if already a customar then it checks if the data I have onthat customer is still the same as menstioned on the invoice . If not it will show the fields that have changed and asks if you want to update data etc. So I would have to see if I can strip out the xml import for you

I am planning on changeing this feature as it has to many things a user has to do. Maybe let it read from a dir and show it has found invoices then use has to only say yes please import them.


i will see what I can do for you ok
Re: XML ( namespace )
January 03, 2025 11:11PM
Oh sorry you want to create one not import one invoice . OK

Ill get you some code OK
Re: XML ( namespace )
January 03, 2025 11:29PM
Hmm this is quite a lot. If you send me a personal message I will be glad to send you the code

there are quit e view things that are set with special values .I took the settings gebnet uses

but for your confiniance here a bit on the CAC as youasked. Please use the namespace as I mentioned earlier then.

//First section of the invoice .Rememener ther are quit a view notes .This starting ones are easy As There is no N:M relation . For invoice rules there is as there can be many of them VAT and different percent used etc

Here some code:

IF fExeDir() <> "" THEN
//spath = fExeDir() + ["\"]+ Klanten.FirmaNaam + "_" + QRY_ubl_verkoopfactuur.Factuurnummer + ".xml"
sPath = fBuildPath( fExeDir(), "factuur\"+Klanten.FirmaNaam + "_" + QRY_ubl_verkoopfactuur.Factuurnummer + ".xml")
sPath_Pdf = fExeDir() + ["\"]+ Klanten.FirmaNaam + "_" + QRY_ubl_verkoopfactuur.Factuurnummer + ".pdf"
END


xmlfact.Invoice.'cbc:UBLVersionID' = "2.1"
xmlfact.Invoice.'cbc:CustomizationID' = " urn:www.cenbii.eu:transaction:biitrns010:ver2.0:extended:urn:www.peppol.eu:bis:peppol4a:ver2.0:extended:urn:www.simplerinvoicing.org:si:si-ubl:ver1.1.x "
xmlfact.Invoice.'cbctongue sticking out smileyrofileID' = "urn:www.cenbii.eu:profile:bii04:ver2.0"
xmlfact.Invoice.'cbc:ID' = QRY_ubl_verkoopfactuur.Factuurnummer
xmlfact.Invoice.'cbc:IssueDate' = DateToString(QRY_ubl_verkoopfactuur.Factuurdatum,"YYYY-MM-DD")
xmlfact.Invoice.'cbcgrinning smileyueDate' = DateToString(QRY_ubl_verkoopfactuur.Vervaldatum,"YYYY-MM-DD")
xmlfact.Invoice.'cbc:InvoiceTypeCode' = "380"
xmlfact.Invoice.'cbc:InvoiceTypeCode':listID = "UNCL1001"
xmlfact.Invoice.'cbc:InvoiceTypeCode':listAgencyID = "6"
xmlfact.Invoice.'cbc:Note' = QRY_ubl_verkoopfactuur.Omschrijving
xmlfact.Invoice.'cbc:TaxPointDate' = DateToString(QRY_ubl_verkoopfactuur.Factuurdatum,"YYYY-MM-DD")
xmlfact.Invoice.'cbcgrinning smileyocumentCurrencyCode' = "EUR"
xmlfact.Invoice.'cbcgrinning smileyocumentCurrencyCode':listID = "ISO 4217 Alpha"
xmlfact.Invoice.'cbcgrinning smileyocumentCurrencyCode':listAgencyID = "6"
xmlfact.Invoice.'cbc:AccountingCost' = QRY_ubl_verkoopfactuur.referentie
xmlfact.Invoice.'cac:InvoicePeriod'.'cbcconfused smileytartDate' = DateToString(QRY_ubl_verkoopfactuur.Factuurdatum,"YYYY-MM-DD")
xmlfact.Invoice.'cac:InvoicePeriod'.'cbc:EndDate' = DateToString(QRY_ubl_verkoopfactuur.Factuurdatum,"YYYY-MM-DD")
IF QRY_ubl_verkoopfactuur.Ordernummer <> 0 THEN
xmlfact.Invoice.'cac:OrderReference'.'cbc:ID' = QRY_ubl_verkoopfactuur.Ordernummer
END
// billing reverence zou hier nog kunnen komen. Dat is bij een credit factuur de referentie naar het origineel
// project referentie </cac:AdditionalDocumentReference>
IF HReadFirst(Bedrijf,BedrijfID) THEN
xmlfact.Invoice.'cac:AccountingSupplierParty'.'cactongue sticking out smileyarty'.'cactongue sticking out smileyartyName'.'cbc:Name' = Bedrijf.Naam
xmlfact.Invoice.'cac:AccountingSupplierParty'.'cactongue sticking out smileyarty'.'cactongue sticking out smileyostalAddress'.'cbcconfused smileytreetName' = Bedrijf.Adres
xmlfact.Invoice.'cac:AccountingSupplierParty'.'cactongue sticking out smileyarty'.'cactongue sticking out smileyostalAddress'.'cbc:BuildingNumber' = Bedrijf.huisnummer
xmlfact.Invoice.'cac:AccountingSupplierParty'.'cactongue sticking out smileyarty'.'cactongue sticking out smileyostalAddress'.'cbc:CityName' = Bedrijf.Woonplaats
xmlfact.Invoice.'cac:AccountingSupplierParty'.'cactongue sticking out smileyarty'.'cactongue sticking out smileyostalAddress'.'cbctongue sticking out smileyostalZone' = Bedrijf.Postcode

xmlfact.Invoice.'cac:AccountingSupplierParty'.'cactongue sticking out smileyarty'.'cactongue sticking out smileyostalAddress'.'cac:Country'.'cbc:IdentificationCode' = "NL"
xmlfact.Invoice.'cac:AccountingSupplierParty'.'cactongue sticking out smileyarty'.'cactongue sticking out smileyostalAddress'.'cac:Country'.'cbc:IdentificationCode':listID = "ISO3166-1:Alpha2"
xmlfact.Invoice.'cac:AccountingSupplierParty'.'cactongue sticking out smileyarty'.'cactongue sticking out smileyostalAddress'.'cac:Country'.'cbc:IdentificationCode':listAgencyID = "6"

xmlfact.Invoice.'cac:AccountingSupplierParty'.'cactongue sticking out smileyarty'.'cactongue sticking out smileyartyTaxScheme'.'cbc:CompanyID' = Bedrijf.BTW_nummer
xmlfact.Invoice.'cac:AccountingSupplierParty'.'cactongue sticking out smileyarty'.'cactongue sticking out smileyartyTaxScheme'.'cbc:CompanyID':schemeID = "NL:VAT"
xmlfact.Invoice.'cac:AccountingSupplierParty'.'cactongue sticking out smileyarty'.'cactongue sticking out smileyartyTaxScheme'.'cbc:CompanyID':schemeAgencyID = "ZZZ"

xmlfact.Invoice.'cac:AccountingSupplierParty'.'cactongue sticking out smileyarty'.'cactongue sticking out smileyartyTaxScheme'.'cac:TaxScheme'.'cbc:ID' = "VAT"
xmlfact.Invoice.'cac:AccountingSupplierParty'.'cactongue sticking out smileyarty'.'cactongue sticking out smileyartyTaxScheme'.'cac:TaxScheme'.'cbc:ID':schemeID = "UN/ECE 5153"
xmlfact.Invoice.'cac:AccountingSupplierParty'.'cactongue sticking out smileyarty'.'cactongue sticking out smileyartyTaxScheme'.'cac:TaxScheme'.'cbc:ID':schemeAgencyID = "6"

xmlfact.invoice.'cac:AccountingSupplierParty'.'cactongue sticking out smileyarty'.'cactongue sticking out smileyartyLegalEntity'.'cbc:CompanyID' = Bedrijf.kvknummer
xmlfact.Invoice.'cac:AccountingSupplierParty'.'cactongue sticking out smileyarty'.'cactongue sticking out smileyartyLegalEntity'.'cbc:CompanyID':schemeID = "NL:KVK"
xmlfact.Invoice.'cac:AccountingSupplierParty'.'cactongue sticking out smileyarty'.'cactongue sticking out smileyartyLegalEntity'.'cbc:CompanyID':schemeAgencyID = "ZZZ"

xmlfact.Invoice.'cac:AccountingSupplierParty'.'cactongue sticking out smileyarty'.'cac:Contact'.'cbc:Telephone' = Bedrijf.Telefoon
xmlfact.Invoice.'cac:AccountingSupplierParty'.'cactongue sticking out smileyarty'.'cac:Contact'.'cbc:ElectronicMail' = Bedrijf.Emailadres

END

I know this is a mess . Please send me a PM then I can give you all in a readable format. Any one else want this code Please send me a pm . I will give it to you as well.

regards
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: