Click or drag to resize

SatValidateXml Method

Validate an XML file against SAT specifications.

Namespace: FirmaSAT
Assembly: diFirmaSatNet (in diFirmaSatNet.dll) Version: 10.70.0.38178 (10.70.0.0)
Syntax
public static int ValidateXml(
	string xmlFile,
	XmlOption xmlOpt = XmlOption.Default
)

Parameters

xmlFile  String
Name of input XML file to be processed (or a string containing XML data)
xmlOpt  XmlOption  (Optional)
Option for strict or loose XML restrictions (optional, default=Strict)

Return Value

Int32
0 if successful or non-zero error code
Remarks
This just validates the XML structure, not the signature.
Example
C#
int n = Sat.ValidateXml("cfdv40-ejemplo.xml");
Console.WriteLine("Sat.ValidateXml returns {0}", n);
// Sat.ValidateXml returns 0

int n = Sat.ValidateXml("cfdv40-iedu-badcurp.xml");
Console.WriteLine("Sat.ValidateXml returns {0}", n);
// Sat.ValidateXml returns -28
Console.WriteLine(General.ErrorLookup(n));
// XML restriction is violated/XML restriccion es violada (XML_FACET_ERROR)
Console.WriteLine(General.LastError());
// Bad attribute/atributo mal [iedu:instEducativas/@CURP] (line 30): 
// 'JUAN01010101GTOHMD0' is too long/es demasiado largo, maximum length/longitud maxima=18
C#
// Input has valid XML form but an invalid facet error against SAT specifications
// Using the "Loose" option validates that the XML form is still correct.
int n = Sat.ValidateXml("cfdv40-iedu-badcurp.xml", XmlOption.Loose);
Console.WriteLine("Sat.ValidateXml(Loose) returns {0}", n);
// Sat.ValidateXml(Loose) returns 0
See Also