我正在尝试使用F#生成基于这个复杂的XSD架构的XML(
http://www.nfe.fazenda.gov.br/portal/exibirArquivo.aspx?conteudo=BALgvpK9Jvo=)
但我收到了编译错误:
FS0503成员或对象构造函数' Dest'取0参数不是 可从此代码位置访问。方法的所有可访问版本 '目的地'拿一个参数。
module xsd1
open FSharp.Data
open System.Xml.Linq
type nfe = XmlProvider<Schema="nfe_v4.00.xsd", ResolutionFolder="c:/temp/nfe">
let GenerateNFe () =
let ide = Unchecked.defaultof<nfe.Ide>
let emit = Unchecked.defaultof<nfe.Emit>
let mydest = nfe.Dest(cnpj=None,
cpf=(Some "12345678901"),
idEstrangeiro=None,
xNome=(Some "TONY"),
enderDest=None,
indleDest="",
ie=None,
isuf=None,
im=None,
email=(Some "tonyvca@oldmail.com")
)
let i = nfe.InfNFe(
versao="4.00",
id="NFe123 F#",
ide=ide,
emit=emit,
avulsa=None,
dest=(Some mydest),
retirada=None,
entrega=None,
autXmLs=Unchecked.defaultof<nfe.AutXml[]>,
dets=Unchecked.defaultof<nfe.Det[]>,
total=Unchecked.defaultof<nfe.Total>,
transp=Unchecked.defaultof<nfe.Transp>,
cobr=None,
pag=Unchecked.defaultof<nfe.Pag>,
infAdic=None,
exporta=None,
compra=None,
cana=None
)
i
如何填写dest&#34;属性&#34; ?
我也无法改变它
let ChangeDest (n: nfe) =
let novodest = nfe.Dest(cnpj=None,
cpf=Some "9999999999",
idEstrangeiro=None,
xNome=Some "NEW TONY",
enderDest=None,
indleDest=None,
ie=None,
isuf=None,
im=None,
email=Some "tonyvca@freemail.com"
)
let newdocument = { n with InfNFe.dest = novodest }
newdocument
为了方便起见,我附上了一个带有XSD和F#代码的示例项目 https://drive.google.com/open?id=1IbMpmOKfh4B-gKj4CCXTuDXlQxyUN1Wr
这不起作用:
let mydest = new nfe.Dest(cnpj=None, cpf=(Some "11111111111"), idEstrangeiro=None, xNome=(Some "TONY"), enderDest=None, indleDest="indledest", ie=None, isuf=None, im=None, email=(Some "tonyvca@hotmail.com") )
但这有效:
let mydest = new nfe.Dest(None, (Some "11111111111"), None, (Some "TONY"), None, "indledest", ie=None, isuf=None, im=None, email=(Some "tonyvca@hotmail.com") )
如果删除命名参数,直到 indleDest 部分,它可以工作,你可以看看并帮助我如何使它工作将所有命名参数写入?
答案 0 :(得分:0)
我发现了问题:
由于字体问题和参数名称缺少自动完成,我输入的是indleDest(INDLEDEST),但正确的是indIeDest(INDIEDEST),现在它编译得很好! :d
let mydest = nfe.Dest(cnpj=None,
cpf=(Some "81679580515"),
idEstrangeiro=None,
xNome=(Some "TONY"),
enderDest=None,
indIeDest="",
ie=None,
isuf=None,
im=None,
email=(Some "tonyvca@hotmail.com")
)