# XML Template Usage Guide ## 🎯 **How Templates Work** The XML template system preserves your document structure while replacing `` sections with data from your CSV file. ### **Processing Logic** 1. **PRESERVED**: All XML content except `` sections 2. **REMOVED**: All existing `` sections (if any) 3. **INSERTED**: New `` sections from CSV data before `` --- ## πŸ“‹ **Template Examples** ### **1. Minimal Template (No Existing Pack Content)** ```xml
``` **Result**: CSV data gets inserted before `` tag. ### **2. Template with Existing Pack Content** ```xml This section will be preserved ``` **Result**: Old `` sections are removed, new ones from CSV are inserted, but `` is preserved. --- ## πŸ”§ **Template Customization** ### **What You Can Customize** βœ… **Document attributes**: `document_id`, `VerForm`, `file_date_time`, etc. βœ… **Organisation information**: Company name, TIN, address, contacts βœ… **Additional XML sections**: Any custom elements outside `` βœ… **XML structure**: Different document layouts ### **What Gets Replaced** ❌ **All `` sections** - These are completely replaced with CSV data ❌ **Content inside ``** - `` and `` elements --- ## πŸ“Š **Generated Pack Content Structure** Each SET CIS from your CSV becomes a `` section: ```xml ``` --- ## πŸš€ **Best Practices** ### **1. Use Placeholder Values** ```xml ``` ### **2. Add Comments for Clarity** ```xml ``` ### **3. Include All Required Sections** ```xml ... ``` --- ## 🎯 **Common Use Cases** ### **1. Different Companies** Create templates for different organizations: ```bash python xml_generator.py data.csv template_company_a.xml -o output_a.xml python xml_generator.py data.csv template_company_b.xml -o output_b.xml ``` ### **2. Different Document Types** Use different templates for various document formats: ```bash python xml_generator.py data.csv template_invoice.xml -o invoice.xml python xml_generator.py data.csv template_shipment.xml -o shipment.xml ``` ### **3. Testing with Sample Data** Keep a template with sample data for testing: ```xml ``` --- ## ⚠️ **Important Notes** 1. **XML Validity**: Ensure your template is valid XML 2. **Encoding**: Use UTF-8 encoding for proper character handling 3. **CDATA Sections**: The tool automatically wraps content in `` 4. **Special Characters**: XML entities are automatically escaped 5. **Document Structure**: Must have `` and `` tags --- ## πŸ” **Testing Your Template** Use dry-run mode to verify your template works: ```bash python xml_generator.py --dry-run your_data.csv your_template.xml ``` Generate to stdout for quick inspection: ```bash python xml_generator.py your_data.csv your_template.xml ```