PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → XML ( namespace )
XML ( namespace )
Débuté par guest, 25 aoû. 2015 11:07 - 6 réponses
Posté le 25 août 2015 - 11:07
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
Posté le 26 août 2015 - 00:20
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
Posté le 26 août 2015 - 10:34
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"?>


The order in witch it should be:
<?xml version="1.0" encoding="UTF-8"?>


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 = "http://www.w3.org/2001/XMLSchema-instance"
nNamespace2..Name = "cbc"
nNamespace2..URI = "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
nNamespace3..Name = "cac"
nNamespace3..URI = "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
nNamespace4..URI = "urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"
Add(nNode..NamespaceDeclared, nNamespace1)
nNode:SchemaLocation..Value = "urn:oasis:names:specification:ubl:schema:xsd:Invoice-2 http://docs.oasis-open.org/ubl/os-UBL-2.1/xsd/maindoc/UBL-Invoice-2.1.xsd"
//nNode:SchemaLocation..Namespace = nNamespace1
Add(nNode..NamespaceDeclared, nNamespace2)
//nNode:SchemaLocation..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
Posté le 29 août 2015 - 19:07
Hi Allard,

I'm interested ...
Posté le 29 août 2015 - 21:48
Hi Allard,

I'm also interested

Thanks in advance
Posté le 30 décembre 2024 - 17:47
a écrit :
Hi Allard,

I'm also interested.
I don't know how to get the prefixes like "cbc" before the nodes
Thanks in advance
Posté le 04 janvier 2025 - 10:04
zag is xmlNode,description = "InvoiceUbl211.Invoice"
Namespace1 is xmlNamespace
Namespace2 is xmlNamespace
Namespace3 is xmlNamespace
Namespace4 is xmlNamespace
Namespace5 is xmlNamespace
Namespace6 is xmlNamespace
Namespace7 is xmlNamespace
Namespace1.Name = "cec"
Namespace1.URI = "urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2"
Add(zag..NamespaceDeclared,Namespace1)
Namespace2.Reset()
Namespace2..Name = "cac"
Namespace2..URI = "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
Add(zag..NamespaceDeclared,Namespace2)
Namespace3.Reset()
Namespace3..Name = "cbc"
Namespace3..URI = "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
Add(zag..NamespaceDeclared,Namespace3)
Namespace4.Reset()
Namespace4..Name = "xsi"
Namespace4..URI = "http://www.w3.org/2001/XMLSchema-instance"
Add(zag..NamespaceDeclared,Namespace4)
Namespace5.Reset()
Namespace5..Name = "xsd"
Namespace5..URI = "http://www.w3.org/2001/XMLSchema"
Add(zag..NamespaceDeclared,Namespace5)
Namespace6.Reset()
Namespace6..Name = "sbt"
Namespace6..URI = "http://mfin.gov.rs/srbdt/srbdtext"
Add(zag..NamespaceDeclared,Namespace6)
Namespace7.Reset()
Namespace7..Name = ""
Namespace7..URI = "urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"
Add(zag..NamespaceDeclared,Namespace7)

-----------------------------------------------------------------------------------------------------
zag.id..Namespace = Namespace3
zag.ID = "invoice number"
zag.IssueDate..Namespace = Namespace3
zag.IssueDate = DateToString(Today(),"YYYY-MM-DD")
zag.DueDate..Namespace = Namespace3
zag.DueDate = DateToString("date","YYYY-MM-DD")
zag.InvoiceTypeCode..Namespace = Namespace3
zag.InvoiceTypeCode = 380