Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System.Xml.Schema.XmlSchemaException: Element 'http://www.w3.org/2000/09/xmldsig#:Signature' was not declared. #98

Closed
TonyHenrique opened this issue Jan 22, 2019 · 4 comments

Comments

@TonyHenrique
Copy link

TonyHenrique commented Jan 22, 2019

I am trying to generate C# classes for the evtAdmissao.xsd
from this
https://portal.esocial.gov.br/manuais/2019-01-18_esquemas_xsd_v02-05-00.zip

I used this command:

C:\temp\eSocial\Esquemas XSD v02.05.00>C:\temp\NFe4\XmlSchemaClassGenerator.2.0.197\XmlSchemaClassGenerator.Console.exe evtAdmissao.xsd -n "|xmldsig-core-schema.xsd=http://www.w3.org/2000/09/xmldsig#" -e -c -o eSocial

Unhandled Exception: System.Xml.Schema.XmlSchemaException: Element 'http://www.w3.org/2000/09/xmldsig#:Signature' was not declared.
   em System.Xml.Schema.XmlSchemaSet.InternalValidationCallback(Object sender, ValidationEventArgs e)
   em System.Xml.Schema.Compiler.CompileElement(XmlSchemaElement xe)
   em System.Xml.Schema.Compiler.CompileParticleElements(XmlSchemaComplexType complexType, XmlSchemaParticle particle)
   em System.Xml.Schema.Compiler.CompileParticleElements(XmlSchemaComplexType complexType, XmlSchemaParticle particle)
   em System.Xml.Schema.Compiler.CompileComplexTypeElements(XmlSchemaComplexType complexType)
   em System.Xml.Schema.Compiler.Compile()
   em System.Xml.Schema.Compiler.Execute(XmlSchemaSet schemaSet, SchemaInfo schemaCompiledInfo)
   em System.Xml.Schema.XmlSchemaSet.Compile()
   em XmlSchemaClassGenerator.Generator.Generate(XmlSchemaSet set)
   em XmlSchemaClassGenerator.Console.Program.Main(String[] args)

@mganss mganss closed this as completed in 7c6e29d Jan 23, 2019
@TonyHenrique
Copy link
Author

Is this some bug, or am I missing something on the command line?

Can you point me to the right command line to generate these classes?

@mganss
Copy link
Owner

mganss commented Jan 23, 2019

You need to also specify the xsd at http://www.w3.org/2000/09/xmldsig. Simply save it to the folder where your other xsd files are located, then specify it on the command line, e.g.

xscgen *.xsd -n http://www.w3.org/2000/09/xmldsig#=Dsig

Unfortunately, even with the xmldsig-core-schema.xsd it didn't work because there was a bug before 2.0.199 which probably originated from the fix for #54. I hope I have fixed this now once and for all 🤞

@TonyHenrique
Copy link
Author

TonyHenrique commented Jan 23, 2019

I downloaded the XSD at http://www.w3.org/2000/09/xmldsig, saved as xmldsig-core-schema.xsd on the same folder, then run

XmlSchemaClassGenerator.Console.exe *.xsd -n "http://www.w3.org/2000/09/xmldsig#=Dsig"

I get

Unhandled Exception: System.Xml.XmlException: For security reasons DTD is prohibited in this XML document. To enable DTD processing set the DtdProcessing property on XmlReaderSettings to Parse and pass the settings into XmlReader.Create method.
   em System.Xml.XmlTextReaderImpl.Throw(Exception e)
   em System.Xml.XmlTextReaderImpl.ParseDoctypeDecl()
   em System.Xml.XmlTextReaderImpl.ParseDocumentContent()
   em System.Xml.Schema.Parser.StartParsing(XmlReader reader, String targetNamespace)
   em System.Xml.Schema.Parser.Parse(XmlReader reader, String targetNamespace)
   em System.Xml.Schema.XmlSchemaSet.ParseSchema(String targetNamespace, XmlReader reader)
   em System.Xml.Schema.XmlSchemaSet.Add(String targetNamespace, String schemaUri)
   em XmlSchemaClassGenerator.Generator.Generate(IEnumerable`1 files)
   em XmlSchemaClassGenerator.Console.Program.Main(String[] args)

Can you please download this
https://portal.esocial.gov.br/manuais/2019-01-18_esquemas_xsd_v02-05-00.zip
and check if it works on your machine/version?
I would like the command line for example try to generate the classes for the evtAdmissao.xsd file.

@mganss
Copy link
Owner

mganss commented Jan 23, 2019

It works for me using these command line arguments. Please make sure you are using 2.0.199 (released today).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants