Principales respuestas
XML - Generar archivo xsd desde un xml

Pregunta
-
Estimados tengo este archivo en xml, a partir de cual quiero pasarlo a xsd usando la herramienta xsd.exe pero me salta este error: Una tabla anidada 'ID' que hereda su espacio de nombres no puede tener varias tablas primarias en espacios de nombres diferentes.
Cambie el tipo de codificacion a UNICODE y me salta este otro error; valor hexadecimal 0x00, es un caracter no valido. linea 2, posicion 1.
Les dejo el archivo XML, espero puedan ayudarme
PD: el XML es una estructura de un comprobante electronico de SUNAT - Peru
<?xml version="1.0" encoding="iso-8859-1" standalone="no"?> <Retention xmlns="urn:sunat:names:specification:ubl:peru:schema:xsd:Retention-1" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:ccts="urn:un:unece:uncefact:documentation:2" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2" xmlns:qdt="urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2" xmlns:sac="urn:sunat:names:specification:ubl:peru:schema:xsd:SunatAggregateComponents-1" xmlns:udt="urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSchemaModule:2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <ext:UBLExtensions> <ext:UBLExtension> <ext:ExtensionContent></ext:ExtensionContent> </ext:UBLExtension> </ext:UBLExtensions> <cbc:UBLVersionID>2.0</cbc:UBLVersionID> <cbc:CustomizationID>1.0</cbc:CustomizationID> <cac:Signature> <cbc:ID>IDSignKG</cbc:ID> <cac:SignatoryParty> <cac:PartyIdentification> <cbc:ID>20382567855</cbc:ID> </cac:PartyIdentification> <cac:PartyName> <cbc:Name><![CDATA[STARSOFT]]></cbc:Name> </cac:PartyName> </cac:SignatoryParty> <cac:DigitalSignatureAttachment> <cac:ExternalReference> <cbc:URI>#signatureKG</cbc:URI> </cac:ExternalReference> </cac:DigitalSignatureAttachment> </cac:Signature> <cbc:ID>R001-123</cbc:ID> <cbc:IssueDate>2016-03-21</cbc:IssueDate> <cac:AgentParty> <cac:PartyIdentification> <cbc:ID schemeID="6">20382567855</cbc:ID> </cac:PartyIdentification> <cac:PartyName> <cbc:Name><![CDATA[STARSOFT]]></cbc:Name> </cac:PartyName> <cac:PostalAddress> <cbc:ID>150136</cbc:ID> <cbc:StreetName><![CDATA[CALLE TIAHUANACO 146]]></cbc:StreetName> <cbc:CitySubdivisionName>URB. MARANGA</cbc:CitySubdivisionName> <cbc:CityName>LIMA</cbc:CityName> <cbc:CountrySubentity>LIMA</cbc:CountrySubentity> <cbc:District>SAN MIGUEL</cbc:District> <cac:Country> <cbc:IdentificationCode>PE</cbc:IdentificationCode> </cac:Country> </cac:PostalAddress> <cac:PartyLegalEntity> <cbc:RegistrationName><![CDATA[ENTERPRISE SOLUTIONS S.A.]]></cbc:RegistrationName> </cac:PartyLegalEntity> </cac:AgentParty> <cac:ReceiverParty> <cac:PartyIdentification> <cbc:ID schemeID="6">20101295673</cbc:ID> </cac:PartyIdentification> <cac:PartyName> <cbc:Name><![CDATA[FABRICACIONES ONUR SAC]]></cbc:Name> </cac:PartyName> <cac:PostalAddress> <cbc:ID>150101</cbc:ID> <cbc:StreetName><![CDATA[AV. ABANCAY 1023]]></cbc:StreetName> <cbc:CitySubdivisionName>CERCADO DE LIMA</cbc:CitySubdivisionName> <cbc:CityName>LIMA</cbc:CityName> <cbc:CountrySubentity>LIMA</cbc:CountrySubentity> <cbc:District>LIMA</cbc:District> <cac:Country> <cbc:IdentificationCode>PE</cbc:IdentificationCode> </cac:Country> </cac:PostalAddress> <cac:PartyLegalEntity> <cbc:RegistrationName><![CDATA[FABRICACIONES ONUR SAC]]></cbc:RegistrationName> </cac:PartyLegalEntity> </cac:ReceiverParty> <sac:SUNATRetentionSystemCode>01</sac:SUNATRetentionSystemCode> <sac:SUNATRetentionPercent>3.00</sac:SUNATRetentionPercent> <cbc:TotalInvoiceAmount currencyID="PEN">35.40</cbc:TotalInvoiceAmount> <sac:SUNATTotalPaid currencyID="PEN">1144.60</sac:SUNATTotalPaid> <sac:SUNATRetentionDocumentReference> <cbc:ID schemeID="01">F001-540</cbc:ID> <cbc:IssueDate>2016-03-21</cbc:IssueDate> <cbc:TotalInvoiceAmount currencyID="PEN">1180.00</cbc:TotalInvoiceAmount> <cac:Payment> <cbc:ID>1</cbc:ID> <cbc:PaidAmount currencyID="PEN">1180.00</cbc:PaidAmount> <cbc:PaidDate>2016-03-21</cbc:PaidDate> </cac:Payment> <sac:SUNATRetentionInformation> <sac:SUNATRetentionAmount currencyID="PEN">35.40</sac:SUNATRetentionAmount> <sac:SUNATRetentionDate>2016-03-21</sac:SUNATRetentionDate> <sac:SUNATNetTotalPaid currencyID="PEN">1144.60</sac:SUNATNetTotalPaid> <cac:ExchangeRate> <cbc:SourceCurrencyCode>PEN</cbc:SourceCurrencyCode> <cbc:TargetCurrencyCode>PEN</cbc:TargetCurrencyCode> <cbc:CalculationRate>1.00</cbc:CalculationRate> <cbc:Date>2016-03-21</cbc:Date> </cac:ExchangeRate> </sac:SUNATRetentionInformation> </sac:SUNATRetentionDocumentReference> </Retention>
- Cambiado webJose jueves, 28 de abril de 2016 23:42
Respuestas
-
Devuélvase a codificación UTF-8 y corra XSD.exe con el switch /classes a ver cómo le va.
Jose R. MCP
Code Samples- Propuesto como respuesta José De AlvaModerator miércoles, 18 de mayo de 2016 15:55
- Marcado como respuesta José De AlvaModerator jueves, 26 de mayo de 2016 14:52
Todas las respuestas
-
¿Está corriendo xsd.exe con el switch /dataset o con el switch /classes? Porque según leo este es un problema para generar datasets, pero con clases debería funcionar.
Jose R. MCP
Code Samples -
Hola Jose, lo que quiero hacer es crear un clase en C# a partir de ese XML para luego usarlo para crear otros archivos XML usando esa clase, esto se hace con xsd.exe, lo primero es pasar el XML a XSD y luego el XSD se puede pasar a una clase, pero al momento de pasar el XML a XSD me saltan esos errores.
- Editado JimyRaul viernes, 29 de abril de 2016 12:29
-
Devuélvase a codificación UTF-8 y corra XSD.exe con el switch /classes a ver cómo le va.
Jose R. MCP
Code Samples- Propuesto como respuesta José De AlvaModerator miércoles, 18 de mayo de 2016 15:55
- Marcado como respuesta José De AlvaModerator jueves, 26 de mayo de 2016 14:52