Untitled
user_3456920
plain_text
2 years ago
6.9 kB
13
Indexable
private void genererActifXml(DataTable table) {
try
{
XNamespace lfNamespace = "http://www.impots.finances.gov.tn/liasse";
XNamespace xsdNamespace = "http://www.w3.org/2001/XMLSchema";
XNamespace vcNamespace = "http://www.w3.org/2007/XMLSchema-versioning";
XDocument xmlDoc = new XDocument(
new XElement(xsdNamespace + "shema",
new XAttribute(XNamespace.Xmlns + "If", lfNamespace),
new XAttribute (XNamespace.Xmlns + "xsd",xsdNamespace),
new XAttribute(XNamespace.Xmlns+ "vc",vcNamespace),
new XAttribute("elementFormDefault", "qualified"),
new XAttribute("attributeFormDefault", "unqualified"),
new XAttribute("minVersion", "1.1"),
new XElement(xsdNamespace +"include", new XAttribute("schemaLocation", "Typescommuns.xsd")),
new XElement(xsdNamespace +"include", new XAttribute("schemaLocation", "Entete.xsd")),
new XElement(xsdNamespace +"element", new XAttribute("name","F6001"),
new XElement(xsdNamespace +"annotation", new XElement("documentation", "Bilan-Actif")),
new XElement(xsdNamespace +"complexType",
new XElement(xsdNamespace + "all",
new XElement(xsdNamespace +"Sequence",
new XElement(xsdNamespace +"element", new XAttribute("name", "Entete"), new XAttribute("type", "TEntete")),
new XElement(xsdNamespace +"element", new XAttribute("name", "Detail"),
new XElement(xsdNamespace +"complexType",
//pour le Montant Brut
from row in table.AsEnumerable()
select new XElement(xsdNamespace+ "element",
new XAttribute("name", row["BaliseMtBrut"]),
new XElement(xsdNamespace+ "annotation",
new XElement(xsdNamespace+"documentation", row["MontantBrut"])
),
new XElement(xsdNamespace+ "complexType",
new XElement(xsdNamespace+ "simpleContent",
new XElement(xsdNamespace+ "xsdextension",
new XAttribute("base", "lfT_NombrePositif15"),
new XElement(xsdNamespace + "attribute",
new XAttribute("name", "Libelle"),
new XAttribute("type", "xsd:string"),
new XAttribute("default", row["DesBilanActif"]+"(Brut)")
)
)
)
)
),
//pour les Amortissement
from row in table.AsEnumerable()
select new XElement(xsdNamespace+ "element",
new XAttribute("name",row["BaliseMtAmortissement"]),
new XElement("annotation",
new XElement(xsdNamespace+"documentation",row["MtAmortissement"])
),
new XElement(xsdNamespace+ "complexType",
new XElement(xsdNamespace+ "simpleContent",
new XElement(xsdNamespace+ "xsdextension",
new XAttribute("base", "lfT_NombrePositif15"),
new XElement("attribute",
new XAttribute("name","Libelle"),
new XAttribute("type","xsdstring"),
new XAttribute("default",row["DesBilanActif"]+"(Amortissement/Provision)")
)
)
)
)
),
//Pour les Montants Net
from row in table.AsEnumerable()
select new XElement(xsdNamespace+ "element",
new XAttribute("name", row["BaliseMtNet"]),
new XElement("annotation",
new XElement(xsdNamespace+"documentation", row["MontantNetMoins"])
),
new XElement(xsdNamespace+ "complexType",
new XElement(xsdNamespace+ "simpleContent",
new XElement(xsdNamespace+ "xsdextension",
new XAttribute("base","lfT_NombrePositif15"),
new XElement(xsdNamespace+ "attribute",
new XAttribute("name","Libelle"),
new XAttribute("type","xsd:string"),
new XAttribute("default",row["DesBilanActif"]+"(Net-1)")
)
)
)
)
)
)
)
)
)
)
)
)
);
xmlDoc.Save("output.xml");
}
catch (Exception ex) {
MessageBox.Show(ex.ToString());
}
}Editor is loading...
Leave a Comment