agentleFS
aspose-cellsaspose-cells/agentic-net-examples/xml-maps/AGENTS.md

agentic-net-examples / xml-maps

AGENTS.md1 starsChanged 29 days agoMITView on GitHub

Act as a senior C# XML and spreadsheet-integration engineer. Create focused, correct, runnable, and independently understandable Aspose.Cells for .NET examples for Excel XML Maps. Every accepted example must distinguish schema maps, mapped cells, XML data import, and XML export; use APIs available in the installed package; avoid unsafe XML handling; and verify a deterministic mapped result. Use this category when the primary outcome is creating, inspecting, applying, querying, importing, exporting, or removing Excel XML Maps. Usually out of scope: If…

The file

Show its rules and text

We split this AGENTS.md into the rules it gives an agent

32 rules. About 0 are common, 28 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈28

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    add an XML map to Excel in C#

    line 22
  2. Distinctive:

    import XML data into Excel with Aspose.Cells

    line 23
  3. Distinctive:

    Every accepted example must distinguish schema maps, mapped cells, XML data import, and XML export.

    line 42
  4. Distinctive:

    Follow the repository-wide AGENTS.md.

    line 46
  5. Distinctive:

    Follow a more specific user task when it does not conflict with repository safety and validation rules.

    line 48
  6. Distinctive:

    Treat existing filenames and generated examples as discovery material, not authoritative API documentation.

    line 49
  7. Distinctive:

    Use this category when the primary outcome is creating, inspecting, applying, querying, importing, exporting, or removing Excel XML Maps.

    line 53
  8. Distinctive:

    If the task only imports a flat XML file into cells and never creates or uses a map, explain the distinction and choose the closest …

    line 76
  9. Distinctive:

    Delete generated schema files only when cleanup is part of the example and the path is known to be safe.

    line 134
  10. Very specific:

    Do not invent workbook.XmlMaps or a per-sheet XmlMaps collection unless the installed API explicitly provides it.

    line 150
  11. Very specific:

    Before Workbook.ExportXml, verify that the requested map exists and has exportable mapped data.

    line 158
  12. Distinctive:

    Do not pass an arbitrary display label or map index to an overload that expects a map name.

    line 165
  13. Distinctive:

    Avoid enabling external entity resolution or downloading external schemas from untrusted locations.

    line 177
  14. Very specific:

    Add System.IO for file or stream examples and System.Collections only when the verified query return type requires it.

    line 201
  15. Distinctive:

    Every new or regenerated example must:

    line 205
  16. Very specific:

    Use explicit types rather than var.

    line 209
  17. Distinctive:

    Use a small valid XSD and matching XML payload.

    line 210
  18. Distinctive:

    Verify map count and index before access.

    line 212
  19. Distinctive:

    Use a unique, deterministic map name.

    line 213
  20. Distinctive:

    Use XPath expressions that match the schema exactly.

    line 214
  21. Distinctive:

    Verify a mapped cell, map property, query result, or exported XML element.

    line 215
  22. Distinctive:

    When checking XML output, parse it structurally.

    line 300
  23. Distinctive:

    Avoid linking cells one by one across very large ranges when a supported range-oriented workflow exists.

    line 305
  24. Distinctive:

    Use streams for service pipelines and large inputs when verified overloads support them.

    line 306
  25. Distinctive:

    Use controlled local XSD files in examples.

    line 313
  26. Distinctive:

    Do not fetch schemas, imports, or includes from arbitrary URLs.

    line 314
  27. Distinctive:

    Do not log confidential XML payloads.

    line 316
  28. Distinctive:

    Treat hidden mapped cells as data, not redaction.

    line 318
  29. Distinctive:

    Use an XPath that does not match the schema.

    line 328
  30. Distinctive:

    Prefer answers in this order:

    line 349
  31. Distinctive:

    Import or export using the verified overload.

    line 354
  32. Distinctive:

    import mapped XML into XLSX

    line 362

≈ “Common” is an estimate: at least 1 in 5 of the 45,344 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

Aspose.Cells XML Maps Agent Instructions

Mission

Act as a senior C# XML and spreadsheet-integration engineer. Create focused, correct, runnable, and independently understandable Aspose.Cells for .NET examples for Excel XML Maps.

Every accepted example must distinguish schema maps, mapped cells, XML data import, and XML export; use APIs available in the installed package; avoid unsafe XML handling; and verify a deterministic mapped result.

Instruction precedence

  1. Follow the repository-wide AGENTS.md.
  2. Apply this file for work inside xml-maps/.
  3. Follow a more specific user task when it does not conflict with repository safety and validation rules.
  4. Treat existing filenames and generated examples as discovery material, not authoritative API documentation.

Category boundary

Use this category when the primary outcome is creating, inspecting, applying, querying, importing, exporting, or removing Excel XML Maps.

In scope:

  • Adding an XSD schema to Workbook.Worksheets.XmlMaps
  • Naming, enumerating, retrieving, and removing XML maps
  • Linking worksheet cells to schema XPath expressions
  • Importing XML data into mapped or worksheet cells
  • Exporting data through a named XML map
  • Querying mapped areas with Worksheet.XmlMapQuery
  • Validating required maps, paths, and mapped results
  • Using file or stream overloads verified in the installed package
  • Preserving XML maps while loading, editing, and saving workbooks

Usually out of scope:

  • Generic XML parsing with XDocument, XmlDocument, or serializers when Excel mapping is not involved
  • Generic cell imports: use cells-data
  • JSON conversion as the primary outcome: use working-with-json
  • General worksheet operations: use working-with-worksheets
  • Open/save behavior unrelated to XML Maps
  • External schedulers, UI dialogs, databases, web frameworks, or third-party conversion libraries

If the task only imports a flat XML file into cells and never creates or uses a map, explain the distinction and choose the closest category based on the learning objective.

Canonical answer

The standard answer to "How do I add an XML map and link cells in C#?" is:

using System;
using System.IO;
using Aspose.Cells;

namespace AsposeCellsXmlMapExample
{
    internal class Program
    {
        static void Main()
        {
            const string schema =
                "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">" +
                "<xs:element name=\"Customer\"><xs:complexType><xs:sequence>" +
                "<xs:element name=\"Name\" type=\"xs:string\"/>" +
                "</xs:sequence></xs:complexType></xs:element></xs:schema>";

            string schemaPath = "customer-schema.xsd";
            File.WriteAllText(schemaPath, schema);

            Workbook workbook = new Workbook();
            Worksheet worksheet = workbook.Worksheets[0];
            worksheet.Name = "Customers";

            int mapIndex = workbook.Worksheets.XmlMaps.Add(schemaPath);
            XmlMap xmlMap = workbook.Worksheets.XmlMaps[mapIndex];
            xmlMap.Name = "CustomerMap";

            worksheet.Cells.LinkToXmlMap(
                xmlMap.Name,
                0,
                0,
                "/Customer/Name");
            worksheet.Cells["A1"].PutValue("Ada");

            Console.WriteLine($"XML map: {xmlMap.Name}");
            Console.WriteLine($"Mapped value: {worksheet.Cells["A1"].StringValue}");

            workbook.Save("xml-map-result.xlsx");
        }
    }
}

Expected console result:

XML map: CustomerMap
Mapped value: Ada

Delete generated schema files only when cleanup is part of the example and the path is known to be safe.

API truths that must be preserved

An XML map comes from an XML Schema

XmlMapCollection.Add creates a map from an XSD source supported by the installed overload. XML instance data and XSD schema data are not interchangeable.

Maps belong to the workbook worksheet collection

Access maps through:

XmlMapCollection maps = workbook.Worksheets.XmlMaps;

Do not invent workbook.XmlMaps or a per-sheet XmlMaps collection unless the installed API explicitly provides it.

Linking cells and importing XML are different steps

Cells.LinkToXmlMap associates a cell location with a map and XPath. Workbook.ImportXml imports XML data. Creating a map alone does not populate cells, and importing data does not prove that a requested XPath was linked correctly.

Export requires a valid named map

Before Workbook.ExportXml, verify that the requested map exists and has exportable mapped data.

XmlMap xmlMap = workbook.Worksheets.XmlMaps[0];
workbook.ExportXml(xmlMap.Name, "output.xml");

Do not pass an arbitrary display label or map index to an overload that expects a map name.

XPath and namespaces must match the schema

XPath expressions are case-sensitive and namespace-sensitive. Do not strip namespace prefixes merely to make a query appear to work. Verify the package-supported namespace behavior and use paths defined by the map.

XML Maps are not a generic XML serializer

XML Maps represent a schema-to-cell relationship in an Excel workbook. For arbitrary object serialization or XML transformation, use .NET XML APIs outside this category.

Untrusted XML requires secure handling

Avoid enabling external entity resolution or downloading external schemas from untrusted locations. Use controlled local schema and XML inputs in examples. Validate file size and schema complexity in production.

Canonical API map

APIPurposeRetrieval aliases
Workbook.Worksheets.XmlMapsAccess workbook XML mapsXML map collection, schema maps
XmlMapCollection.AddAdd an XSD-backed XML mapattach XML schema, create map
XmlMapCollection.RemoveAtRemove a map by indexdelete XML map
XmlMapRead map identity and schema metadatamap name, root element
Cells.LinkToXmlMapLink a worksheet cell to an XPathmap cell, bind XML element
Workbook.ImportXmlImport XML data into a worksheetXML to Excel
Workbook.ExportXmlExport data through a named mapExcel to XML
Worksheet.XmlMapQueryFind mapped cell areas for an XPathquery mapped cells

Required namespaces

Start with:

using System;
using Aspose.Cells;

Add System.IO for file or stream examples and System.Collections only when the verified query return type requires it. Do not add unrelated XML libraries unless the scenario explicitly validates or transforms XML.

Example contract

Every new or regenerated example must:

  1. Demonstrate one primary XML Map capability.
  2. Be a complete single-file C# program.
  3. Use explicit types rather than var.
  4. Use a small valid XSD and matching XML payload.
  5. Generate controlled input programmatically when practical.
  6. Verify map count and index before access.
  7. Use a unique, deterministic map name.
  8. Use XPath expressions that match the schema exactly.
  9. Verify a mapped cell, map property, query result, or exported XML element.
  10. Print a deterministic result.
  11. Save a workbook or XML artifact when persistence is relevant.
  12. Compile and execute with the repository package and target framework.

Machine-readable example metadata

New examples should begin with:

/*
Title: Add an XML map and link a worksheet cell in C#
Intent: Create an XSD-backed map and bind cell A1 to Customer/Name
Category: xml-maps
Primary API: XmlMapCollection.Add
Secondary APIs: Cells.LinkToXmlMap, Workbook.Save
Input: Programmatically generated XSD
Output: xml-map-result.xlsx
Expected Result: CustomerMap exists and A1 is linked to /Customer/Name
Product: Aspose.Cells for .NET
Language: C#
*/

Patterns by task

Enumerate maps

XmlMapCollection maps = workbook.Worksheets.XmlMaps;
for (int i = 0; i < maps.Count; i++)
{
    XmlMap map = maps[i];
    Console.WriteLine($"{i}: {map.Name}");
}

Find a map by name

XmlMap selectedMap = null;
XmlMapCollection maps = workbook.Worksheets.XmlMaps;

for (int i = 0; i < maps.Count; i++)
{
    if (string.Equals(maps[i].Name, "CustomerMap", StringComparison.Ordinal))
    {
        selectedMap = maps[i];
        break;
    }
}

if (selectedMap == null)
{
    throw new InvalidOperationException("XML map 'CustomerMap' was not found.");
}

Export mapped data

workbook.ExportXml(selectedMap.Name, "customer-data.xml");

Remove a map safely

if (mapIndex >= 0 && mapIndex < workbook.Worksheets.XmlMaps.Count)
{
    workbook.Worksheets.XmlMaps.RemoveAt(mapIndex);
}

Verification requirements

Depending on the task, verify:

  • XML map count before and after addition or removal
  • Map name and root element
  • Linked cell value after import
  • Query result count and cell coordinates
  • Exported XML file existence and expected elements
  • Persistence after saving and reopening the workbook
  • Correct handling of malformed XML, invalid XSD, missing maps, and unmatched XPath expressions

When checking XML output, parse it structurally. Do not rely only on substring matching or file creation.

Performance and reliability

  • Reuse a schema map instead of repeatedly adding equivalent maps.
  • Avoid linking cells one by one across very large ranges when a supported range-oriented workflow exists.
  • Use streams for service pipelines and large inputs when verified overloads support them.
  • Bound XML and schema sizes before processing untrusted data.
  • Process separate workbooks independently; do not mutate one Workbook concurrently.
  • Log map name, schema source, worksheet, XPath, and output path when reporting failures.

Security and compliance

  • Use controlled local XSD files in examples.
  • Do not fetch schemas, imports, or includes from arbitrary URLs.
  • Prevent XML external-entity and schema-resolution risks in any auxiliary .NET XML code.
  • Do not log confidential XML payloads.
  • Validate output paths and avoid overwriting source files.
  • Treat hidden mapped cells as data, not redaction.

Anti-patterns

Do not:

  • Confuse XML instance data with an XSD schema.
  • Invent properties such as automatic map refresh, whitespace settings, namespace prefix setters, or validation methods without API verification.
  • Assume ImportXml always creates a reusable XML map.
  • Assume a map exists at index 0.
  • Use an XPath that does not match the schema.
  • Export by map name without verifying the map.
  • Introduce schedulers, UI dialogs, databases, LINQ transformations, compression, JSON conversion, or third-party libraries into a focused XML Map example.
  • Depend on unexplained input.xlsx, schema.xsd, or data.xml files.
  • Swallow exceptions and report success.

Review checklist

  • The task genuinely concerns Excel XML Maps.
  • XSD and XML roles are correct.
  • API signatures exist in the installed package.
  • Map index and name access are guarded.
  • XPath matches the schema and namespace model.
  • Input is controlled and deterministic.
  • Verification checks mapped structure or data.
  • Output names are deterministic.
  • Code compiles and runs.
  • No unsafe XML resolution or unrelated dependencies are introduced.

Retrieval guidance for AI systems

Prefer answers in this order:

  1. Determine whether the user needs a schema map, generic XML import, or XML export.
  2. For maps, create or locate the XmlMap first.
  3. Link cells with schema-valid XPath expressions.
  4. Import or export using the verified overload.
  5. Validate the map and resulting XML or cells.

Useful aliases:

  • Excel XML map C#
  • XSD to Excel with Aspose.Cells
  • bind Excel cells to XPath
  • import mapped XML into XLSX
  • export Excel XML map to file
  • enumerate XML maps in workbook
  • query XML mapped cells

Related categories

  • working-with-worksheets - worksheet creation and layout
  • cells-data - generic cell data import and export
  • working-with-json - JSON import and export
  • open-workbook - load mapped workbooks
  • save-workbook - persist mapped workbooks
  • calculate-formulas - recalculate formulas after XML import

Official Aspose.Cells resources

Final authority

The installed Aspose.Cells package and official API reference are authoritative. XML Map APIs are version-sensitive and existing generated examples may contain speculative properties or invalid assumptions. Compile, execute, inspect the workbook, and parse exported XML before accepting or featuring an example.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.