Skip to content

Commit 4b6a104

Browse files
committed
Reformatted markdown files
1 parent 3615e51 commit 4b6a104

5 files changed

Lines changed: 101 additions & 34 deletions

File tree

AI_AGENT_GUIDELINES.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
## Performance & Memory Optimization
44

55
### Buffer Management
6+
67
- The SAXParser uses a minimum buffer size of 2048 bytes (`SAXParser.MIN_BUFFER_SIZE`)
78
- For large files, the parser reads incrementally and expands buffer as needed
89
- **AI Recommendation**: For very large XML files (>100MB), suggest custom ContentHandler over DOMBuilder to avoid memory issues
910

1011
### Memory Usage Patterns
12+
1113
```typescript
1214
// Memory-efficient for large files
1315
class LargeFileHandler implements ContentHandler {
@@ -19,24 +21,28 @@ const builder = new DOMBuilder(); // Stores entire DOM in memory
1921
```
2022

2123
### Performance Considerations
24+
2225
- File parsing is more efficient than string parsing (string parsing creates temp files)
2326
- Encoding detection adds small overhead - specify encoding when known
2427
- DTD parsing is optional and adds processing time
2528

2629
## XML Standards Compliance
2730

2831
### Supported XML Versions
32+
2933
- XML 1.0 (default)
3034
- XML 1.1 (when specified in declaration)
3135
- Character validation differs between versions
3236

3337
### What's NOT Supported
38+
3439
- **Schema Validation**: No XSD, RelaxNG validation yet
3540
- **Namespace Processing**: Limited namespace support
3641
- **External Entity Resolution**: Requires manual catalog setup
3742
- **Default Attribute Values**: Not automatically applied from DTD
3843

3944
### Well-formedness vs. Validity
45+
4046
```typescript
4147
// Library checks well-formedness, NOT validity
4248
parser.parseString('<root><unclosed>'); // Throws error - not well-formed
@@ -46,6 +52,7 @@ parser.parseString('<root><child/></root>'); // Parses fine - well-formed
4652
## Entity Resolution & Catalogs
4753

4854
### When to Use Catalogs
55+
4956
```typescript
5057
// Use when XML references external DTDs
5158
const catalog = new Catalog('catalog.xml');
@@ -56,19 +63,22 @@ builder.setCatalog(catalog);
5663
```
5764

5865
### Entity Types Supported
66+
5967
- Built-in entities (`&lt;`, `&gt;`, `&amp;`, `&apos;`, `&quot;`)
6068
- Character references (`&#65;`, `&#x41;`)
6169
- External entities via catalog resolution
6270

6371
## Error Handling & Edge Cases
6472

6573
### Common Error Scenarios
74+
6675
1. **Missing ContentHandler**: "ContentHandler not set"
6776
2. **Malformed XML**: "unclosed elements", "text found in prolog"
6877
3. **Encoding Issues**: Specify encoding explicitly when possible
6978
4. **File Access**: Check file existence before parsing
7079

7180
### Graceful Degradation
81+
7282
```typescript
7383
// AI should recommend this pattern
7484
try {
@@ -86,23 +96,27 @@ try {
8696
## Use Case Decision Matrix
8797

8898
### When to Recommend SAXParser + DOMBuilder
99+
89100
- **File size**: < 50MB
90101
- **Need**: DOM manipulation, XPath-like queries
91102
- **Memory**: Sufficient RAM available
92103

93104
### When to Recommend SAXParser + Custom Handler
105+
94106
- **File size**: > 50MB or streaming data
95107
- **Need**: Extract specific data, transform on-the-fly
96108
- **Memory**: Limited RAM or performance critical
97109

98110
### When to Recommend XMLWriter
111+
99112
- **Creating XML**: Always prefer over string concatenation
100113
- **Encoding**: Automatic BOM handling for UTF-16LE
101114
- **File output**: Better than manual file writing
102115

103116
## Integration Patterns
104117

105118
### With Node.js Streams
119+
106120
```typescript
107121
// AI should suggest this for large files
108122
class StreamingXMLProcessor {
@@ -113,6 +127,7 @@ class StreamingXMLProcessor {
113127
```
114128

115129
### With Express.js
130+
116131
```typescript
117132
// Validate XML in middleware
118133
app.use('/api/xml', (req, res, next) => {
@@ -126,6 +141,7 @@ app.use('/api/xml', (req, res, next) => {
126141
```
127142

128143
### With TypeScript Strict Mode
144+
129145
```typescript
130146
// Always check for undefined/null with strict mode
131147
const doc = builder.getDocument();
@@ -138,6 +154,7 @@ if (!root) return; // Required check
138154
## DTD and Grammar Features
139155

140156
### Current DTD Support
157+
141158
- Element declarations (`<!ELEMENT>`)
142159
- Attribute list declarations (`<!ATTLIST>`)
143160
- Entity declarations (`<!ENTITY>`)
@@ -146,6 +163,7 @@ if (!root) return; // Required check
146163
- External DTD references
147164

148165
### DTD Limitations
166+
149167
- No validation against DTD rules
150168
- Parameter entities supported but limited
151169
- Conditional sections supported
@@ -154,39 +172,45 @@ if (!root) return; // Required check
154172
## Namespace Handling
155173

156174
### Current Support
175+
157176
```typescript
158177
// Basic namespace detection
159178
element.getNamespace(); // Returns prefix before ':'
160179
element.getName(); // Returns full name including prefix
161180
```
162181

163182
### Limitations
183+
164184
- No namespace URI resolution
165185
- No namespace context management
166186
- No namespace validation
167187

168188
## AI Agent Recommendations
169189

170190
### Code Quality Checks
191+
171192
1. **Always check return values** for undefined/null
172193
2. **Use try-catch** around all parsing operations
173194
3. **Specify encoding** when known to avoid detection overhead
174195
4. **Choose appropriate ContentHandler** based on use case
175196
5. **Use XMLWriter** for XML generation, not string concatenation
176197

177198
### Performance Optimization
199+
178200
1. **File size assessment**: Recommend streaming for large files
179201
2. **Memory profiling**: Suggest custom handlers for memory-constrained environments
180202
3. **Encoding specification**: Reduce parsing overhead
181203
4. **Incremental processing**: Break large operations into chunks
182204

183205
### Error Prevention
206+
184207
1. **Input validation**: Check file existence, encoding validity
185208
2. **Resource cleanup**: Ensure FileReader.closeFile() is called
186209
3. **Error propagation**: Provide meaningful error messages
187210
4. **Fallback strategies**: Handle common failure scenarios
188211

189212
### Best Practices Enforcement
213+
190214
1. **Null safety**: Enforce null checks in TypeScript strict mode
191215
2. **Resource management**: Proper file handle cleanup
192216
3. **Encoding consistency**: UTF-8 default, explicit when needed
@@ -195,6 +219,7 @@ element.getName(); // Returns full name including prefix
195219
## Common Anti-patterns to Avoid
196220

197221
### Memory Leaks
222+
198223
```typescript
199224
// BAD: Parser instance reuse without cleanup
200225
const parser = new SAXParser();
@@ -208,6 +233,7 @@ for (const file of files) {
208233
```
209234

210235
### Unsafe Type Assumptions
236+
211237
```typescript
212238
// BAD: Assuming non-null returns
213239
const root = doc.getRoot().getName(); // May throw
@@ -220,6 +246,7 @@ if (root) {
220246
```
221247

222248
### String Concatenation for XML
249+
223250
```typescript
224251
// BAD: Manual XML construction
225252
let xml = '<?xml version="1.0"?><root>';
@@ -232,4 +259,4 @@ const root = new XMLElement('root');
232259
// ... proper construction
233260
```
234261

235-
This guide should help AI agents provide more accurate, safe, and efficient recommendations when working with the TypesXML library.
262+
This guide should help AI agents provide more accurate, safe, and efficient recommendations when working with the TypesXML library.

LICENSE-COMMERCIAL

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,53 +7,60 @@ Copyright (c) 2023-2025 Maxprograms
77
This commercial license allows you to use TypesXML in proprietary applications
88
without the copyleft requirements of the AGPL-3.0 license.
99

10-
### Permitted Uses:
10+
### Permitted Uses
11+
1112
- Use in proprietary software applications
1213
- Distribution as part of commercial products
1314
- SaaS offerings without source code disclosure
1415
- Embedding in closed-source applications
1516
- No requirement to share source code modifications
1617

17-
### Commercial License Includes:
18+
### Commercial License Includes
19+
1820
- Perpetual license for the licensed version
1921
- Professional technical support
2022
- Access to commercial-only features (when available)
2123
- Legal indemnification coverage
2224
- Service level agreements (SLA)
2325

24-
### License Grant:
26+
### License Grant
27+
2528
Subject to the terms and conditions of this license and payment of applicable
2629
license fees, Maxprograms grants you a non-exclusive, non-transferable license
2730
to use TypesXML in your commercial applications.
2831

29-
### Restrictions:
32+
### Restrictions
33+
3034
- License is non-transferable without written consent
3135
- No sublicensing or redistribution of TypesXML itself
3236
- Must comply with export control laws
3337
- Cannot reverse engineer or create derivative works of the license system
3438

35-
### Support and Updates:
39+
### Support and Updates
40+
3641
Commercial license includes:
42+
3743
- Email support during business hours
3844
- Bug fixes and security updates
3945
- Access to new releases during support period
4046
- Priority support queue
4147

42-
### Termination:
48+
### Termination
49+
4350
This license terminates automatically if you violate any terms. Upon termination,
4451
you must cease all use and destroy all copies of TypesXML.
4552

4653
---
4754

4855
For licensing inquiries and pricing information:
4956

50-
**Email:** sales@maxprograms.com
51-
**Website:** https://maxprograms.com
57+
**Email:** <sales@maxprograms.com>
58+
**Website:** <https://maxprograms.com>
5259

5360
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
5461
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
5562
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
5663
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
5764
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
5865
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
59-
SOFTWARE.
66+
SOFTWARE.

LICENSING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,4 @@ For organizations that cannot comply with AGPL-3.0 requirements, we offer commer
106106
- **Copyright:** © 2023-2025 Maxprograms
107107
- **Open Source License:** [GNU AGPL-3.0](./LICENSE)
108108
- **Commercial License:** [Commercial Terms](./LICENSE-COMMERCIAL)
109-
- **Trademark:** TypesXML is a trademark of Maxprograms
109+
- **Trademark:** TypesXML is a trademark of Maxprograms

README.md

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,29 @@ TypesXML is available under a **dual licensing model**:
1717
### 🆓 Open Source License (AGPL-3.0)
1818

1919
**Free for:**
20+
2021
-**Open source projects** (AGPL-compatible)
2122
-**Personal and educational use**
2223
-**Internal business tools** (with source sharing)
2324
-**Research and development**
2425

2526
**Requirements under AGPL:**
27+
2628
- 📝 **Share source code** of your application
2729
- 📝 **Use AGPL-compatible license** for your project
2830
- 📝 **Provide source to users** (including SaaS users)
2931

3032
### 💼 Commercial License
3133

3234
**Required for:**
35+
3336
-**Proprietary software** distribution
3437
-**SaaS applications** without source sharing
3538
-**Commercial products** embedding TypesXML
3639
-**Closed-source applications**
3740

3841
**Commercial license includes:**
42+
3943
-**No source sharing requirements**
4044
-**Professional support and SLA**
4145
-**Legal protection and indemnification**
@@ -49,39 +53,39 @@ TypesXML is available under a **dual licensing model**:
4953

5054
Implements a SAX parser that exposes these methods from the `ContentHandler` interface:
5155

52-
* initialize(): void;
53-
* setCatalog(catalog: Catalog): void;
54-
* startDocument(): void;
55-
* endDocument(): void;
56-
* xmlDeclaration(version: string, encoding: string, standalone: string): void;
57-
* startElement(name: string, atts: Array\<XMLAttribute>): void;
58-
* endElement(name: string): void;
59-
* internalSubset(declaration: string): void;
60-
* characters(ch: string): void;
61-
* ignorableWhitespace(ch: string): void;
62-
* comment(ch: string): void;
63-
* processingInstruction(target: string, data: string): void;
64-
* startCDATA(): void;
65-
* endCDATA(): void;
66-
* startDTD(name: string, publicId: string, systemId: string): void;
67-
* endDTD(): void;
68-
* skippedEntity(name: string): void;
56+
- initialize(): void;
57+
- setCatalog(catalog: Catalog): void;
58+
- startDocument(): void;
59+
- endDocument(): void;
60+
- xmlDeclaration(version: string, encoding: string, standalone: string): void;
61+
- startElement(name: string, atts: Array\<XMLAttribute>): void;
62+
- endElement(name: string): void;
63+
- internalSubset(declaration: string): void;
64+
- characters(ch: string): void;
65+
- ignorableWhitespace(ch: string): void;
66+
- comment(ch: string): void;
67+
- processingInstruction(target: string, data: string): void;
68+
- startCDATA(): void;
69+
- endCDATA(): void;
70+
- startDTD(name: string, publicId: string, systemId: string): void;
71+
- endDTD(): void;
72+
- skippedEntity(name: string): void;
6973

7074
Class `DOMBuilder` implements the `ContentHandler` interface and builds a DOM tree from an XML document.
7175

7276
## Features currently in development
7377

74-
* Parsing of DTDs and internal subsets from <!DOCTYPE>
78+
- Parsing of DTDs and internal subsets from <!DOCTYPE>
7579

7680
## Limitations
7781

78-
* Validation not supported yet
79-
* Default values for attributes are not set when parsing an element
82+
- Validation not supported yet
83+
- Default values for attributes are not set when parsing an element
8084

8185
## On the Roadmap
8286

83-
* Support for XML Schemas
84-
* Support for RelaxNG
87+
- Support for XML Schemas
88+
- Support for RelaxNG
8589

8690
## Installation
8791

0 commit comments

Comments
 (0)