Skip to content

Commit 5ff7982

Browse files
committed
Simplified README
1 parent 4e788ed commit 5ff7982

1 file changed

Lines changed: 21 additions & 264 deletions

File tree

README.md

Lines changed: 21 additions & 264 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# TypesXML
22

3-
Open source XML library written in TypeScript with extensible multi-schema validation framework
3+
XML library written in TypeScript with multi-schema validation framework
44

55
## Documentation
66

@@ -12,55 +12,26 @@ Open source XML library written in TypeScript with extensible multi-schema valid
1212

1313
## Licensing
1414

15-
TypesXML is available under a **dual licensing model**:
16-
17-
### 🆓 Open Source License (AGPL-3.0)
18-
19-
**Free for:**
20-
21-
-**Open source projects** (AGPL-compatible)
22-
-**Personal and educational use**
23-
-**Internal business tools** (with source sharing)
24-
-**Research and development**
25-
26-
**Requirements under AGPL:**
27-
28-
- 📝 **Share source code** of your application
29-
- 📝 **Use AGPL-compatible license** for your project
30-
- 📝 **Provide source to users** (including SaaS users)
31-
32-
### 💼 Commercial License
33-
34-
**Required for:**
35-
36-
-**Proprietary software** distribution
37-
-**SaaS applications** without source sharing
38-
-**Commercial products** embedding TypesXML
39-
-**Closed-source applications**
40-
41-
**Commercial license includes:**
42-
43-
-**No source sharing requirements**
44-
-**Professional support and SLA**
45-
-**Legal protection and indemnification**
46-
-**Priority access to new features**
47-
48-
**📞 Commercial Licensing:** [sales@maxprograms.com](mailto:sales@maxprograms.com)
49-
50-
**📄 License Details:** [AGPL-3.0](./LICENSE) | [Commercial License](./LICENSE-COMMERCIAL.md)
15+
TypesXML is available under two licenses: [AGPL-3.0](./LICENSE) for open source projects and a [Commercial License](./LICENSE-COMMERCIAL.md) for proprietary use. For commercial licensing inquiries, contact [sales@maxprograms.com](mailto:sales@maxprograms.com).
5116

5217
## Overview
5318

54-
TypesXML implements a complete XML 1.0/1.1 parser with an extensible Grammar framework that supports multiple schema validation approaches. The core architecture provides both SAX (event-driven) and DOM (tree-based) parsing with unified validation through the Grammar interface.
19+
TypesXML implements XML 1.0/1.1 parsing with an extensible Grammar framework supporting multiple schema validation approaches. The library provides both SAX (event-driven) and DOM (tree-based) parsing with validation through a unified Grammar interface.
5520

5621
### Grammar Framework
5722

58-
The Grammar interface provides a unified abstraction for schema validation that supports:
23+
The Grammar interface provides schema validation support for:
5924

6025
- **DTD Validation**: Complete Document Type Definition support with full validation
61-
- **XML Schema**: Extensible framework ready for XML Schema implementation
62-
- **RelaxNG**: Extensible framework ready for RelaxNG implementation
63-
- **No-Operation Mode**: Graceful processing without schema validation
26+
- **XML Schema**: Initial implementation with basic support for XSD validation
27+
28+
### Key Features
29+
30+
- **OASIS Catalog Support**: Full XML Catalog resolution for DTD and entity references
31+
- **Entity Resolution**: Built-in support for XML entities and catalog-based resolution
32+
- **Namespace Support**: XML namespace handling with QualifiedName system
33+
- **Encoding Support**: Various character encodings including UTF-8, UTF-16LE
34+
- **XML Writer**: Utilities for writing XML documents with proper formatting
6435

6536
### ContentHandler Interface
6637

@@ -92,47 +63,29 @@ The `DOMBuilder` class implements the `ContentHandler` interface and builds a DO
9263

9364
### Core XML Processing
9465

95-
- **Complete XML 1.0/1.1 Parser**: Full specification compliance with comprehensive error handling
66+
- **XML 1.0/1.1 Parser**: Full specification compliance with comprehensive error handling
9667
- **SAX Parser**: Event-driven parsing for memory-efficient processing of large documents
9768
- **DOM Builder**: Creates complete in-memory tree representation of XML documents
98-
- **Encoding Support**: Handles various character encodings including UTF-8, UTF-16LE
69+
- **OASIS Catalog Support**: Full XML Catalog resolution for DTD and entity references
9970
- **Entity Resolution**: Built-in support for XML entities and catalog-based resolution
10071
- **Namespace Support**: Full XML namespace handling with QualifiedName system
10172

10273
### Grammar-Based Validation Framework
10374

10475
- **Extensible Grammar Interface**: Unified abstraction supporting multiple schema types
10576
- **DTD Grammar**: Complete Document Type Definition implementation
77+
- **XML Schema Support**: Initial implementation with basic XSD validation capabilities
10678
- **Namespace-Aware Processing**: QualifiedName system for namespace-aware validation
10779
- **Validation Context**: Rich error reporting with line/column information
10880
- **Flexible Validation Modes**: Configurable strictness levels for different use cases
10981

11082
### Complete DTD Support
11183

112-
- **DTD Grammar Implementation**: Full parsing and validation of Document Type Definitions including:
113-
- Element declarations with content models (EMPTY, ANY, Mixed, Children)
114-
- Attribute list declarations with all attribute types
115-
- Entity declarations (parameter and general entities)
116-
- Notation declarations
117-
- Internal and external subset processing
118-
- **Content Model Processing**:
119-
- Complex content model parsing (sequences, choices, cardinality)
120-
- Mixed content detection and validation
121-
- Element children resolution and integrity checking
122-
- Complete validation of element sequences, choice groups, and cardinality constraints
123-
- **Default Attribute Processing**: Automatic setting of default attribute values from DTD declarations:
124-
- Direct default values: `attr CDATA "default-value"`
125-
- Fixed declarations: `attr CDATA #FIXED "fixed-value"`
126-
- Enumeration defaults: `format (html|dita) "dita"`
127-
- DITA Processing Ready: Automatically sets essential `@class` attributes for DITA workflows
128-
- **Flexible Processing**: DTD parsing and default attribute setting works in both validating and non-validating modes
129-
- **Catalog Support**: Full XML Catalog resolution for DTD and entity references
130-
- **Enterprise-Grade Error Handling**: Comprehensive validation with detailed error reporting for:
131-
- Missing required elements and attributes
132-
- Invalid element sequences and content models
133-
- Cardinality violations (wrong number of occurrences)
134-
- Undeclared elements and attributes
135-
- Invalid attribute values and types
84+
- **DTD Grammar Implementation**: Full parsing and validation of Document Type Definitions including element declarations, attribute lists, entities, and notations
85+
- **Content Model Processing**: Complex content model parsing with sequences, choices, and cardinality validation
86+
- **Default Attribute Processing**: Automatic setting of default attribute values from DTD declarations
87+
- **Internal and External Subset Processing**: Complete DTD merging with proper precedence handling
88+
- **Enterprise-Grade Error Handling**: Comprehensive validation with detailed error reporting
13689

13790
### Additional Features
13891

@@ -146,73 +99,6 @@ The `DOMBuilder` class implements the `ContentHandler` interface and builds a DO
14699
npm install typesxml
147100
```
148101

149-
## Testing
150-
151-
TypesXML includes a comprehensive test suite that validates against the **W3C XML Test Suite** - the official standard for XML parser compliance.
152-
153-
### Quick Start Testing
154-
155-
```bash
156-
# Setup test suite (first time only)
157-
npm run test:setup
158-
159-
# Run comprehensive W3C XML Test Suite
160-
npm test
161-
162-
# Run XML canonicalizer tests
163-
npm run test:canonicalizer
164-
```
165-
166-
### Comprehensive Test Features
167-
168-
🎯 **Complete W3C Coverage**
169-
170-
- Tests against 500+ official W3C XML test files
171-
- Validates parsing, canonicalization, and error detection
172-
- Covers valid, invalid, and not-well-formed documents
173-
174-
📊 **Advanced Reporting**
175-
176-
- Real-time progress indicators with ETA
177-
- Detailed statistics by test category
178-
- Performance benchmarks and timing analysis
179-
- Error categorization and analysis
180-
- Saves comprehensive JSON reports
181-
182-
🚀 **Smart Execution**
183-
184-
- Automatic test environment validation
185-
- Efficient batch processing for large test sets
186-
- Graceful handling of missing test files
187-
188-
### Test Categories
189-
190-
- **Valid Documents**: Should parse successfully and match canonical output
191-
- **Invalid Documents**: Well-formed but fail DTD validation
192-
- **Not-Well-Formed**: Should be rejected during parsing
193-
194-
### Sample Output
195-
196-
```text
197-
╔══════════════════════════════════════════════════════════════╗
198-
║ TypesXML W3C Comprehensive Test Suite ║
199-
╚══════════════════════════════════════════════════════════════╝
200-
201-
📊 OVERALL STATISTICS
202-
Total Test Files: 531
203-
Tests Passed: 492
204-
Tests Failed: 39
205-
Success Rate: 92.65%
206-
Execution Time: 8.45 seconds
207-
208-
🏆 XML COMPLIANCE SUMMARY
209-
📋 Valid Document Processing: 96.2%
210-
🚫 Invalid Document Rejection: 89.1%
211-
🌟 EXCELLENT: High compliance with XML standards
212-
```
213-
214-
For detailed testing documentation, see [`tests/README.md`](./tests/README.md).
215-
216102
## Example
217103

218104
### Basic Usage
@@ -255,132 +141,3 @@ export class Test {
255141

256142
new Test();
257143
```
258-
259-
### Grammar-Based DTD Validation
260-
261-
```TypeScript
262-
import { DOMBuilder } from "./DOMBuilder";
263-
import { SAXParser } from "./SAXParser";
264-
import { DTDParser } from "./dtd/DTDParser";
265-
import { DTDGrammar } from "./dtd/DTDGrammar";
266-
import { Catalog } from "./Catalog";
267-
import { XMLWriter } from "./XMLWriter";
268-
import { Indenter } from "./Indenter";
269-
270-
// Example with Grammar framework and DTD validation
271-
const ditaXml = `<?xml version="1.0"?>
272-
<!DOCTYPE concept PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
273-
<concept id="example">
274-
<title>Example Topic</title>
275-
<conbody>
276-
<p>This paragraph will get default @class attributes automatically.</p>
277-
</conbody>
278-
</concept>`;
279-
280-
try {
281-
const parser = new SAXParser();
282-
const builder = new DOMBuilder();
283-
284-
// Set up DTD grammar for validation
285-
const dtdParser = new DTDParser();
286-
287-
// Optional: Set up catalog for DTD resolution
288-
const catalog = new Catalog('/path/to/catalog.xml');
289-
builder.setCatalog(catalog);
290-
dtdParser.setCatalog(catalog);
291-
292-
// Parse DTD and create grammar
293-
const dtdGrammar: DTDGrammar = dtdParser.parseDTD('concept.dtd');
294-
295-
// Configure parser with grammar
296-
parser.setGrammar(dtdGrammar);
297-
parser.setValidating(true); // Enable strict validation
298-
parser.setIncludeDefaultAttributes(true); // Include default attributes
299-
parser.setContentHandler(builder);
300-
301-
// Parse the document with validation
302-
parser.parseString(ditaXml);
303-
const doc = builder.getDocument();
304-
305-
// Check if default attributes were added (depends on DTD availability)
306-
const root = doc?.getRoot();
307-
const classAttr = root?.getAttribute('class');
308-
if (classAttr) {
309-
console.log(`Root @class: ${classAttr.getValue()}`);
310-
// Output when DTD is available: "- topic/topic concept/concept "
311-
} else {
312-
console.log('No @class attribute found (DTD not available)');
313-
}
314-
315-
// Prettify the document with proper indentation
316-
const indenter = new Indenter(2); // 2 spaces per level
317-
if (root) {
318-
indenter.indent(root);
319-
}
320-
321-
// Write the processed and prettified document
322-
XMLWriter.writeDocument(doc!, 'output.xml');
323-
324-
} catch (error: any) {
325-
if (error.message.includes('validation')) {
326-
console.log('DTD Validation Error:', error.message);
327-
// Handle validation errors appropriately
328-
} else {
329-
console.log('Parsing Error:', error.message);
330-
}
331-
}
332-
```
333-
334-
### Flexible Validation Modes
335-
336-
```TypeScript
337-
import { SAXParser, DOMBuilder, DTDParser, NoOpGrammar } from 'typesxml';
338-
339-
// Example: Strict validation that rejects invalid documents
340-
const invalidXml = `<?xml version="1.0"?>
341-
<!DOCTYPE book [
342-
<!ELEMENT book (title, author+, chapter*)>
343-
<!ELEMENT title (#PCDATA)>
344-
<!ELEMENT author (#PCDATA)>
345-
]>
346-
<book>
347-
<title>Book Title</title>
348-
<!-- Missing required author+ elements - will cause validation error -->
349-
</book>`;
350-
351-
const parser = new SAXParser();
352-
const builder = new DOMBuilder();
353-
354-
// Parse internal DTD and create grammar
355-
const dtdParser = new DTDParser();
356-
const internalDTD = `
357-
<!ELEMENT book (title, author+, chapter*)>
358-
<!ELEMENT title (#PCDATA)>
359-
<!ELEMENT author (#PCDATA)>
360-
<!ELEMENT chapter (title, content)>
361-
<!ELEMENT content (#PCDATA)>
362-
`;
363-
const dtdGrammar = dtdParser.parseInternalSubset(internalDTD);
364-
365-
// Configure parser with strict validation
366-
parser.setGrammar(dtdGrammar);
367-
parser.setValidating(true); // Enable strict validation
368-
parser.setContentHandler(builder);
369-
370-
try {
371-
parser.parseString(invalidXml);
372-
console.log('Document is valid');
373-
} catch (error) {
374-
console.log('Validation failed:', error.message);
375-
// Output: "Content model validation failed for element 'book': Required content particle '(title,author+,chapter*)' not satisfied"
376-
}
377-
378-
// Alternative: Use NoOpGrammar for processing without validation
379-
const noOpGrammar = new NoOpGrammar();
380-
parser.setGrammar(noOpGrammar);
381-
parser.setValidating(false);
382-
383-
// This will parse successfully without validation
384-
parser.parseString(invalidXml);
385-
console.log('Document parsed without validation');
386-
```

0 commit comments

Comments
 (0)