Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Jul 6, 2025

This PR adds support for local XML schema files to enable offline validation, addressing the use case where XML documents are used as configuration files and internet access may not be available.

Changes Made

The implementation modifies the get_schema() function to detect whether the schema location is a URL or a local file path:

  • URL detection: Uses starts_with("http://") or starts_with("https://") to identify remote schemas
  • Local file support: Reads schema files directly from disk using std::fs::read()
  • Error handling: Provides clear error messages for missing local schema files
  • Backward compatibility: Preserves all existing functionality for URL-based schemas

Example Usage

<!-- Remote schema (existing functionality) -->
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xsi:schemaLocation="http://example.com/ns https://example.com/schema.xsd">
  <content>...</content>
</root>

<!-- Local schema (new functionality) -->
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xsi:schemaLocation="http://example.com/ns ./local-schema.xsd">
  <content>...</content>
</root>

Features

  • ✅ Support for both absolute and relative file paths
  • ✅ Caching works for both local and remote schemas
  • ✅ Proper error messages for missing files
  • ✅ Full backward compatibility with existing URL-based schemas
  • ✅ No changes to CLI interface or usage

The implementation is minimal and surgical - only the schema loading logic was modified while preserving all existing behavior and performance characteristics.

Fixes #179.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copy link

semanticdiff-com bot commented Jul 6, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  src/main.rs  56% smaller

Co-authored-by: FranklinChen <134491+FranklinChen@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Local XML Schema Add support for local XML schema files Jul 6, 2025
@Copilot Copilot AI requested a review from FranklinChen July 6, 2025 22:51
Copilot finished work on behalf of FranklinChen July 6, 2025 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Local XML Schema
2 participants