How dvreeze/yaidom works
Main Components
• Core API & Domain Model: Representing the uniform XML query API, including elements, trees, and the various “query API” traits and classes (which are central in the “shared” module).
• Platform-Specific Implementations: Include separate components for the JVM and JavaScript implementations. The “jvm” folder contains conversion, parsing (using JAXP, StAX, SAX, and DOM), printing, and XPath evaluation modules (with additional support for Saxon). The “js” folder contains analogous JS implementations and demo apps.
• Conversion Layers: Separate these as they allow inter-conversion between different XML models (e.g., Scala XML, JsDom, Saxon-based nodes, etc.). Components like “convert”, “scalaxml”, and “simple” illustrate this approach.
Relationships and Interactions
• The Core API is the central hub that the platform-specific modules (JVM and JS) depend on and extend.
• The “shared” module provides common definitions (e.g., handling of names, namespaces, core types like EName, QName, etc.) that the implementations in the “jvm” and “js” modules build upon.
• Conversion components feed into both the input (parsing) and output (printing) pipelines, allowing conversion from one XML model to another.
• There is directional dependency from the higher-level query API and abstraction toward lower-level technical implementations (e.g., parser or printer classes), and also from the application/demo layers toward these processing engines.
• Notice the usage of external libraries (Saxon-HE) along with integration mechanisms to plug in more sophisticated XPath or transformation capabilities.
Architectural Patterns and Design Principles
• Modularity: The project is clearly segmented into modules based on platforms (JVM, JS) and shared concerns.
• Separation of Concerns: Each layer (the query API, parsing, printing, conversions) is well encapsulated.
• Abstraction & Extensibility: The uniform query API abstracts over several concrete implementations, allowing additional DOM implementations to be added.
• Use of well-known technologies: Leveraging the Scala Collections API, JAXP, and Saxon for XML processing.
• Test-Driven Design: The extensive test directories show a focus on validating consistency and correctness across multiple XML processing techniques.
Design Elements and Notations
• Use clear labels for each module or component.
• Brief annotations within or near the components to note any key features (e.g., “Immutable Default DOM”, “Saxon-based XPath”, “Supports Scala Collections”).