GenericElement

com.phasmidsoftware.xmldoc.xml.GenericElement
See theGenericElement companion class

Attributes

Companion
class
Graph
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type

Members list

Type members

Inherited and Abstract types

type MirroredElemLabels <: Tuple

The names of the product elements.

The names of the product elements.

Attributes

Inherited from:
Mirror
type MirroredLabel <: String

The name of the type.

The name of the type.

Attributes

Inherited from:
Mirror

Value members

Concrete methods

def fromElem(elem: Elem, inheritedScope: NamespaceBinding = ...): GenericElement

As fromNode, but for callers that know (as scala.xml.XML.loadString callers always do, since it returns Elem specifically, not the more general Node) that the result must be a GenericElement, avoiding a cast at every call site.

As fromNode, but for callers that know (as scala.xml.XML.loadString callers always do, since it returns Elem specifically, not the more general Node) that the result must be a GenericElement, avoiding a cast at every call site.

Value parameters

elem

the element to convert.

Attributes

Returns

a GenericElement.

def fromNode(node: Node, inheritedScope: NamespaceBinding = ...): GenericContent

Method to convert a scala.xml.Node into a GenericContent, recursively.

Method to convert a scala.xml.Node into a GenericContent, recursively.

NOTE on namespaces: Elem.label is only the local name (e.g. "Story" for "idPkg:Story"), and an xmlns:prefix="uri" declaration is carried in Elem.scope, not in .attributes — so both have to be handled specially to avoid silently losing the "idPkg:" prefix (used throughout IDML's designmap.xml) or the namespace declaration itself. Whichever bindings in e.scope are not already visible in inheritedScope are re-materialized here as ordinary-looking xmlns[:prefix]="uri" attributes, so the output is self-contained.

Value parameters

inheritedScope

the namespace bindings already in scope from an enclosing element; defaults to none, for a top-level call.

node

the node to convert (typically an Elem, but any Node is accepted).

Attributes

Returns

a GenericContent: a GenericElement for an Elem, GenericCData for a CDATA section, otherwise GenericText.

def toXmlString(content: GenericContent): String

Method to render a GenericContent back into an XML string.

Method to render a GenericContent back into an XML string.

NOTE: this is not guaranteed to be byte-identical to whatever text originally produced the equivalent GenericContent (e.g. attribute-quoting style and entity-encoding choices are normalized), but it is semantically equivalent and round-trips losslessly through fromNode again (i.e. fromNode(parse(toXmlString(g))) == g).

Value parameters

content

the content to render.

Attributes

Returns

an XML string.

Implicits

Implicits

An Extractor[GenericElement], for use as an ordinary field type within an otherwise-specialist extractorN, wherever a specific, named field is deliberately left generic. Fails if the node isn't an element (e.g. it's a bare text node).

An Extractor[GenericElement], for use as an ordinary field type within an otherwise-specialist extractorN, wherever a specific, named field is deliberately left generic. Fails if the node isn't an element (e.g. it's a bare text node).

Attributes

implicit val extractorOpt: Extractor[Option[GenericElement]]

An Extractor[Option[GenericElement]], for a deliberately generic field that's optional.

An Extractor[Option[GenericElement]], for a deliberately generic field that's optional.

Attributes

A Renderer[GenericElement], the counterpart to extractor, delegating to toXmlString.

A Renderer[GenericElement], the counterpart to extractor, delegating to toXmlString.

Attributes

implicit val rendererOpt: Renderer[Option[GenericElement]]

A Renderer[Option[GenericElement]], the counterpart to extractorOpt.

A Renderer[Option[GenericElement]], the counterpart to extractorOpt.

Attributes