# XML Schema Option Testing Summary

## Testing Results

### ✅ WORKING Options (tested individually)

1. **pedantic** - ✓ Works (no crashes)
2. **recover** - ✓ Works (no crashes)
3. **format** - ✓ Works (outputs formatted XML)
4. **maxampl** - ✓ Works (no crashes)
5. **xpath** - ✓ Works (outputs XPath results to stdout)

### ❌ CRASHING Options

1. **html** - ✗ Crashes (exit code 139)
   - Issue: HTML parser (`htmlCtxtReadFile`) expects different document structure
   - C code: Uses `HTMLparser.h` and different parsing path at line 1238 in xmllint.c

2. **dtd** - ✗ Crashes (exit code 139)
   - Issue: `--dtdvalid` auto-adds `XML_PARSE_DTDLOAD` flag (line 2609)
   - Then `xmlParseDTD()` (line 2072) can deadlock with external entities

### 📋 Options Remaining to Test

- noent, nsclean, nocdata, nodict, noblanks
- loaddtd, dtdattr, dropdtd, nodefdtd, nocompact
- sax, oldxml10, stream
- output_file, huge

## Root Cause Analysis

### HTML Option Crash

The HTML option uses a completely different parser:

- XML parser: `xmlReadFile()` or `xmlCreatePushParserCtxt()`
- HTML parser: `htmlCtxtReadFile()` or `htmlCreatePushParserCtxt()`

The HTML parser expects HTML-specific syntax and crashes when given XML documents.

### DTD Option Crash

The `--dtdvalid` option has this problematic flow:

1. Line 2609: `lint->parseOptions |= XML_PARSE_DTDLOAD;` (auto-added)
2. Line 2072: `dtd = xmlParseDTD(NULL, BAD_CAST lint->dtdvalid);`
3. `xmlParseDTD()` can deadlock when trying to load external entities with the DTDLOAD flag

### XPath Output Issue

Line 1637: `xmlOutputBufferWrite(buf, 1, "\n");` - Always writes to stdout, cannot be suppressed with --quiet

## Fix Recommendations

1. **HTML Option**:
   - Only enable when parsing actual HTML documents
   - Add validation to check if content is HTML before enabling

2. **DTD Option**:
   - Avoid using `--dtdvalid` with external DTD files
   - Use `--valid` for inline DTD validation instead
   - Or patch libxml2 to fix the deadlock in `xmlParseDTD()`

3. **XPath Option**:
   - Document that it outputs to stdout
   - Consider redirecting stdout to capture results in testing
