Revin cu o rezolvare ptr utilizatorii de chilkat , scuze daac e banala dar eu sunt mai nou pe chilkat
Adica am cautat un removeprefix si se pare ca nu exista , si pana la urma vad ca merge cu banala * , in toate situatiile
...GetChildContent("*:AccountingSupplierParty|*:Party|*:PartyLegalEntity|*:CompanyID")
Ro-factura 2024 - discutii
Forum rules
:: limbajul folosit in acest forum va fi unul civilizat, in limita subiectelor din topicurile deschise.
:: orice manifestare necivilizata (agresiune verbala, comportament neadecvat, reclama abuziva fara legatura cu forumul) va duce la stergerea contului de user.
:: pt. inscriere USER NOU la acest FORUM, folositi linkul https://profox.ro/forum-register/
:: limbajul folosit in acest forum va fi unul civilizat, in limita subiectelor din topicurile deschise.
:: orice manifestare necivilizata (agresiune verbala, comportament neadecvat, reclama abuziva fara legatura cu forumul) va duce la stergerea contului de user.
:: pt. inscriere USER NOU la acest FORUM, folositi linkul https://profox.ro/forum-register/
Re: Ro-factura 2024 - discutii
@sasort
Cva de genul acesta am si eu, doar ca nu ma leg de acele "urn:oasis:name..... pentru ca nu ma incurca deocamdata.
Trebuie insa sa modific procedura acum si sa o completez si cu acele cifre (incrementate).
Munca inutila si timp pierdut aiurea pentru ca un standard nu este standard!
Cand "produci" un standard general valabil, care sa fie folosit pentru interconectarea multor sisteme diferite trebuie sa ai reguli clare.
Cva de genul acesta am si eu, doar ca nu ma leg de acele "urn:oasis:name..... pentru ca nu ma incurca deocamdata.
Trebuie insa sa modific procedura acum si sa o completez si cu acele cifre (incrementate).
Munca inutila si timp pierdut aiurea pentru ca un standard nu este standard!
Cand "produci" un standard general valabil, care sa fie folosit pentru interconectarea multor sisteme diferite trebuie sa ai reguli clare.
Re: Ro-factura 2024 - discutii
cel mai bine merge cand xml ul este curatat de toate acele prefixuri,apoi citirea o fac cu aceasta metoda: viewtopic.php?p=1637#p1637
Re: Ro-factura 2024 - discutii
-eliminare prefix din xml; poate va ajuta:
**********************************************************************************************
Function CleanXMLPrefix( tcXmlString )
Create Cursor All_prefix_from_xml ( Prefix c(20), TextSupl c(254), Sirtag M )
lcXmlString = tcXmlString
cContorPrefixTag = Occurs( '<', lcXmlString )
For a = 1 to cContorPrefixTag
cSirTag = StrExtract( lcXmlString, '<', '>', a)
*<wstxns102:ItemClassificationCode listID="BG-158A 0%" listVersionID="STI" xmlns:wstxns102="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">125022</wstxns102:ItemClassificationCode>
* wstxns102:ItemClassificationCode listID="BG-158A 0%" listVersionID="STI" xmlns:wstxns102="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
If Left(Allt(cSirTag), 1) <> "/" &&& </wstxns102:ItemClassificationCode> elimin tagul de inchidere, preiau doar tagul de inceput fiind complet
cPrefix = StrExtract( cSirTag, '', ":") &&& wstxns102
cTextSupl = ""
* wstxns102:ItemClassificationCode listID="BG-158A 0%" listVersionID="STI" xmlns:wstxns102="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
For Parte = 1 To Occurs( '"', cSirTag)
*
afluSir = StrExtract( cSirTag, '"', '"', parte )
*
If Occurs( ':', afluSir)>=2 &&& "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
nPozitieInceput = Atc( afluSir, cSirTag ) - 1
cSirPinaLaTextSupl = SubStr( cSirTag, 1, nPozitieInceput ) &&& wstxns102:ItemClassificationCode listID="BG-158A 0%" listVersionID="STI" xmlns:wstxns102=
nSpatii = Occurs( ' ', cSirPinaLaTextSupl ) &&& spatii in sir
cTextSupl = StrExtract( cSirTag, ' ', '"', nSpatii) + '"'+afluSir+'"' &&& xmlns:wstxns102=
Exit
EndIf
*
EndFor
*
If Len(AllTrim(cPrefix))>0 AND Occurs( ' ', AllTrim(cPrefix) )=0
Select * From All_prefix_from_xml Where Prefix=cPrefix And TextSupl=cTextSupl Into Cursor Exista_prefix
If Reccount('Exista_prefix')=0
Insert Into All_prefix_from_xml ( Prefix , TextSupl , Sirtag );
Values ( cPrefix, cTextSupl, cSirTag )
EndIf
EndIf
EndIf
EndFor
Select All_prefix_from_xml
Scan
lcXmlString = StrTran( lcXmlString, AllTrim(All_prefix_from_xml.prefix)+":" , '')
If Len(AllTrim(All_prefix_from_xml.TextSupl))>0
lcXmlString = StrTran( lcXmlString, " "+AllTrim(All_prefix_from_xml.TextSupl), '')
EndIf
EndScan
*
Return lcXmlString
EndProc
**********************************************************************************************
Function CleanXMLPrefix( tcXmlString )
Create Cursor All_prefix_from_xml ( Prefix c(20), TextSupl c(254), Sirtag M )
lcXmlString = tcXmlString
cContorPrefixTag = Occurs( '<', lcXmlString )
For a = 1 to cContorPrefixTag
cSirTag = StrExtract( lcXmlString, '<', '>', a)
*<wstxns102:ItemClassificationCode listID="BG-158A 0%" listVersionID="STI" xmlns:wstxns102="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">125022</wstxns102:ItemClassificationCode>
* wstxns102:ItemClassificationCode listID="BG-158A 0%" listVersionID="STI" xmlns:wstxns102="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
If Left(Allt(cSirTag), 1) <> "/" &&& </wstxns102:ItemClassificationCode> elimin tagul de inchidere, preiau doar tagul de inceput fiind complet
cPrefix = StrExtract( cSirTag, '', ":") &&& wstxns102
cTextSupl = ""
* wstxns102:ItemClassificationCode listID="BG-158A 0%" listVersionID="STI" xmlns:wstxns102="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
For Parte = 1 To Occurs( '"', cSirTag)
*
afluSir = StrExtract( cSirTag, '"', '"', parte )
*
If Occurs( ':', afluSir)>=2 &&& "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
nPozitieInceput = Atc( afluSir, cSirTag ) - 1
cSirPinaLaTextSupl = SubStr( cSirTag, 1, nPozitieInceput ) &&& wstxns102:ItemClassificationCode listID="BG-158A 0%" listVersionID="STI" xmlns:wstxns102=
nSpatii = Occurs( ' ', cSirPinaLaTextSupl ) &&& spatii in sir
cTextSupl = StrExtract( cSirTag, ' ', '"', nSpatii) + '"'+afluSir+'"' &&& xmlns:wstxns102=
Exit
EndIf
*
EndFor
*
If Len(AllTrim(cPrefix))>0 AND Occurs( ' ', AllTrim(cPrefix) )=0
Select * From All_prefix_from_xml Where Prefix=cPrefix And TextSupl=cTextSupl Into Cursor Exista_prefix
If Reccount('Exista_prefix')=0
Insert Into All_prefix_from_xml ( Prefix , TextSupl , Sirtag );
Values ( cPrefix, cTextSupl, cSirTag )
EndIf
EndIf
EndIf
EndFor
Select All_prefix_from_xml
Scan
lcXmlString = StrTran( lcXmlString, AllTrim(All_prefix_from_xml.prefix)+":" , '')
If Len(AllTrim(All_prefix_from_xml.TextSupl))>0
lcXmlString = StrTran( lcXmlString, " "+AllTrim(All_prefix_from_xml.TextSupl), '')
EndIf
EndScan
*
Return lcXmlString
EndProc
Re: Ro-factura 2024 - discutii
- procedure de sus elimina tot ( si cele indexate - "wstxns102:" si cele gen "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" )
Re: Ro-factura 2024 - discutii
Alta varianta:
Function RemoveNamespaces
LParameters lcXML
Local loXml, loNewXML, loRoot, loNode, loNodes, lcResult, lcRootName
loXml = CreateObject("MSXML2.DOMDocument.6.0")
loXml.LoadXML(lcXML)
loXml.setProperty("SelectionLanguage", "XPath")
loNewXML = CreateObject("MSXML2.DOMDocument.6.0")
loNewXML.preserveWhiteSpace = .F.
loNewXML.AppendChild(loNewXML.createProcessingInstruction("xml", 'version="1.0"'))
* Get the root element name without namespace
lcRootName = IIf(At(":", loXml.documentElement.NodeName) > 0, SubStr(loXml.documentElement.NodeName, At(":", loXml.documentElement.NodeName) + 1), loXml.documentElement.NodeName)
* Create a new root element with the same name
loRoot = loNewXML.CreateElement(lcRootName)
loNewXML.AppendChild(loRoot)
* Copy nodes without namespaces
loNodes = loXml.documentElement.ChildNodes
For Each loNode In loNodes
AddNodeWithoutNamespace(loRoot, loNode)
EndFor
*loNewXML.formatting = 1 && Enable pretty print
*lcResult = loNewXML.XML
If Not File("prettyprint.xslt")
Text To lcSQL NoShow TextMerge
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xalan="http://xml.apache.org/xslt" version="1.0">
<xsl:output method="xml" encoding="UTF-8" indent="yes" xalan:indent-amount="4"/>
<!--Important! Remove existing whitespace in DOM elements.-->
<xsl:strip-space elements="*"/>
<!--Identity transformation (see http://www.w3.org/TR/xslt#copying).-->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
EndText
EndIf
* Apply XSLT for pretty print
loXSLT = CREATEOBJECT("MSXML2.FreeThreadedDOMDocument.6.0")
loXSLT.async = .F.
loXSLT.load("prettyprint.xslt")
loTransformedXML = CREATEOBJECT("MSXML2.DOMDocument.6.0")
loNewXML.transformNodeToObject(loXSLT, loTransformedXML)
lcResult = loTransformedXML.XML
Return lcResult
EndFunc
* __________________________________________________________________________________________________________
Procedure AddNodeWithoutNamespace
LParameters loParent, loNode
Local loNewNode, loChildNode, lcNodeName
If loNode.NodeType = 1 && Element node
* Remove prefix from node name
lcNodeName = IIf(At(":", loNode.NodeName) > 0, SubStr(loNode.NodeName, At(":", loNode.NodeName) + 1), loNode.NodeName)
loNewNode = loParent.ownerDocument.CreateNode(1, lcNodeName, "")
loParent.AppendChild(loNewNode)
For Each loChildNode In loNode.ChildNodes
AddNodeWithoutNamespace(loNewNode, loChildNode)
EndFor
Else
If loNode.NodeType = 3 && Text node
loNewNode = loParent.ownerDocument.createTextNode(loNode.nodeValue)
loParent.AppendChild(loNewNode)
EndIf
EndIf
EndProc
* __________________________________________________________________________________________________________
Function RemoveNamespaces
LParameters lcXML
Local loXml, loNewXML, loRoot, loNode, loNodes, lcResult, lcRootName
loXml = CreateObject("MSXML2.DOMDocument.6.0")
loXml.LoadXML(lcXML)
loXml.setProperty("SelectionLanguage", "XPath")
loNewXML = CreateObject("MSXML2.DOMDocument.6.0")
loNewXML.preserveWhiteSpace = .F.
loNewXML.AppendChild(loNewXML.createProcessingInstruction("xml", 'version="1.0"'))
* Get the root element name without namespace
lcRootName = IIf(At(":", loXml.documentElement.NodeName) > 0, SubStr(loXml.documentElement.NodeName, At(":", loXml.documentElement.NodeName) + 1), loXml.documentElement.NodeName)
* Create a new root element with the same name
loRoot = loNewXML.CreateElement(lcRootName)
loNewXML.AppendChild(loRoot)
* Copy nodes without namespaces
loNodes = loXml.documentElement.ChildNodes
For Each loNode In loNodes
AddNodeWithoutNamespace(loRoot, loNode)
EndFor
*loNewXML.formatting = 1 && Enable pretty print
*lcResult = loNewXML.XML
If Not File("prettyprint.xslt")
Text To lcSQL NoShow TextMerge
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xalan="http://xml.apache.org/xslt" version="1.0">
<xsl:output method="xml" encoding="UTF-8" indent="yes" xalan:indent-amount="4"/>
<!--Important! Remove existing whitespace in DOM elements.-->
<xsl:strip-space elements="*"/>
<!--Identity transformation (see http://www.w3.org/TR/xslt#copying).-->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
EndText
EndIf
* Apply XSLT for pretty print
loXSLT = CREATEOBJECT("MSXML2.FreeThreadedDOMDocument.6.0")
loXSLT.async = .F.
loXSLT.load("prettyprint.xslt")
loTransformedXML = CREATEOBJECT("MSXML2.DOMDocument.6.0")
loNewXML.transformNodeToObject(loXSLT, loTransformedXML)
lcResult = loTransformedXML.XML
Return lcResult
EndFunc
* __________________________________________________________________________________________________________
Procedure AddNodeWithoutNamespace
LParameters loParent, loNode
Local loNewNode, loChildNode, lcNodeName
If loNode.NodeType = 1 && Element node
* Remove prefix from node name
lcNodeName = IIf(At(":", loNode.NodeName) > 0, SubStr(loNode.NodeName, At(":", loNode.NodeName) + 1), loNode.NodeName)
loNewNode = loParent.ownerDocument.CreateNode(1, lcNodeName, "")
loParent.AppendChild(loNewNode)
For Each loChildNode In loNode.ChildNodes
AddNodeWithoutNamespace(loNewNode, loChildNode)
EndFor
Else
If loNode.NodeType = 3 && Text node
loNewNode = loParent.ownerDocument.createTextNode(loNode.nodeValue)
loParent.AppendChild(loNewNode)
EndIf
EndIf
EndProc
* __________________________________________________________________________________________________________
Re: Ro-factura 2024 - discutii
Salutare ,
Validatorul de pe ANAF merge si pentru CreditNote ? Mie mi-a dat erori
Validatorul de pe ANAF merge si pentru CreditNote ? Mie mi-a dat erori
Re: Ro-factura 2024 - discutii
salut
posibil sa se fi scos,nu mai exista nici la BT-3 in aplicatia anaf https://www.anaf.ro/CompletareFactura/f ... rale.xhtml
posibil sa se fi scos,nu mai exista nici la BT-3 in aplicatia anaf https://www.anaf.ro/CompletareFactura/f ... rale.xhtml
Re: Ro-factura 2024 - discutii
Se selecteaza FCN, identic ca la validarea din API
- Attachments
-
- image_2024-08-20_182740666.png (9.37 KiB) Viewed 203 times
Re: Ro-factura 2024 - discutii
Am reusit sa-mi fac timp pentru o functie generala care elimina ORICE prefix (cbc: , ns1: , xxx156: etc).
Mai bine mai tarziu decat niciodata ...
Procedura este simpla, strict pentru interpretare fact, cu urmatoare observatii:
- Elementele goale <element/> nu m-au interesat, pt. ca nu am ce valori sa iau din ele
- urn:oasis: .... nu m-au interesat
Mai bine mai tarziu decat niciodata ...
Code: Select all
FUNCTION delprefixtag
PARAMETERS lctextxmlfct
***mg: sterge TOATE prefixurile din XML ... de ex. cbc: , ns1: , wstxns100: caut prefixurile de genul </wstxns14:CompanyID>
xtextfct=ALLTRIM(lctextxmlfct)
xnrelem=OCCURS('</',xtextfct) && toate "inchiderile" de tag </...> , de aici iau prefixul, este mai sigur asa.
FOR ii=1 TO xnrelem
xtag=STREXTRACT(xtextfct,'</','>',ii,1)
xtag=GETWORDNUM(xtag,1,' ') && iau primul cuvant ... asta n-ar trebui, este doar de siguranta
IF ':'$xtag && daca am cbc: sau xxx715: sau ubl: .... etc
xprefix=STREXTRACT(xtag,'',':',1) + ':' && prefixul pe care urmeaza sa-l sterg ... de ex cbc: sau xx256:
xtextfct=STRTRAN(xtextfct,'<'+xprefix,'<')
xtextfct=STRTRAN(xtextfct,'</'+xprefix,'</')
ENDIF
ENDFOR
RETURN xtextfct
- Elementele goale <element/> nu m-au interesat, pt. ca nu am ce valori sa iau din ele
- urn:oasis: .... nu m-au interesat