From db13efd9c0741adc207de5d10b9457a3fd38b696 Mon Sep 17 00:00:00 2001 From: Nelson Vides Date: Mon, 27 Jan 2025 15:23:34 +0100 Subject: [PATCH] Create child/0 type helper This can help avoid doing too often `[exml:element() | exml:cdata()]` in specs. --- include/exml.hrl | 2 +- src/exml.erl | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/exml.hrl b/include/exml.hrl index 34d8628..b3198fe 100644 --- a/include/exml.hrl +++ b/include/exml.hrl @@ -11,7 +11,7 @@ -record(xmlel, {name :: binary(), attrs = #{} :: exml:attrs(), - children = [] :: [exml:element() | exml:cdata()]}). + children = [] :: [exml:child()]}). %% Implementation of the exmlAssertEqual/2 macro is a modification of %% https://github.com/erszcz/rxml/commit/e8483408663f0bc2af7896e786c1cdea2e86e43d#diff-2cb5d18741df32f4ead70c21fdd221d1 diff --git a/src/exml.erl b/src/exml.erl index ac10ae4..3699d4c 100644 --- a/src/exml.erl +++ b/src/exml.erl @@ -31,6 +31,7 @@ -export_type([attrs/0, cdata/0, element/0, + child/0, item/0]). -type attrs() :: #{binary() => binary()}. @@ -44,6 +45,7 @@ %% -type element() :: #xmlel{}. -type item() :: element() | cdata() | exml_stream:start() | exml_stream:stop(). +-type child() :: element() | cdata(). -type prettify() :: pretty | not_pretty. %% Printing indentation rule, see `to_iolist/2'.