GenericContent
A fully generic representation of XML content: used for anything that doesn't have (or doesn't need) a specialist type. GenericElement carries a tag, its attributes, and its children — any of which may themselves be unmodeled elements, or text.
The "mixing" of specialist and generic content happens one level up, in whatever container type models a specific element (e.g. a Story's content might be Seq[Either[ParagraphStyleRange, GenericElement]]) — GenericElement itself doesn't know or care whether its parent is specialist or generic.
fromNode/toXmlString are hand-written rather than built from the Extractor/Renderer combinators (extractor1...extractor7, renderer1...renderer7): those all assume a fixed, known number of fields, each mapped by name to one specific attribute or child — a "capture whatever's left over" field, of unbounded/unnamed size, isn't something they can express (the parallel is a fixed-arity method versus a varargs method). That said, GenericElement still has ordinary Extractor[GenericElement]/Renderer[GenericElement] instances below, delegating to fromElem/toXmlString — these let GenericElement be used as a normal field type within an otherwise-specialist extractorN/rendererN, for a specific, named field that's deliberately left generic (as opposed to modeling an unbounded remainder, which these instances don't help with).
NOTE: scala.xml.Comment and scala.xml.EntityRef nodes are not treated specially and fall through to GenericText via their .text value, which loses their distinct node type (a comment would round-trip as plain escaped text, not a comment) — this is judged an acceptable gap because InDesign-generated IDML content does not appear to contain either. scala.xml.PCData (CDATA sections) and scala.xml.Text are handled properly.
Attributes
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes