XML AST, codecs, named catalogs, and store path model
Repo dubinsky/xml, read from GitHub 1 min ago. dubinsky has not joined Take My Repo.
dubinsky/xml is a public repo on GitHub by dubinsky. XML AST, codecs, named catalogs, and store path model. It declares the Apache-2.0 license on GitHub. It is written mainly in Scala, has 0 stars and last changed on 2026-11-10. Nobody has reviewed it on Take My Repo yet, which says nothing about its quality. Read from GitHub on 2026-11-22.
In the maintainer's words. Shown from GitHub; Take My Repo does not keep a copy.
Dialect-aware XML for Scala 3: parse, write, transform, and bind documents.
Maven coordinates: org.podval:org.podval.xml:0.8.0
implementation 'org.podval:org.podval.xml:0.8.0'
zio-blocks-schema comes in transitively (XmlCodec).
XmlParser loads from a string or classpath resource into Xml.
parseXml, parseXmlDocument, parseHtml, parse, and parseResource return Xml.Element and need no given.
Convert with element.to[TO] (element.to[ZioBlocksHtml.Element] after import ZioBlocksHtml.given).
element.to[Xml.Element] from another tree needs import Xml.given.
parseHtml uses TagSoup (HTML only: no namespaces, names are lower-cased; not for TEI).
xi:include is not expanded (xi:include/@href stays a page ref).
parseXml returns the document element; parseXmlDocument keeps the declaration, doctype, and comments/PIs before and
after the root so a document can round-trip through the writer.
SAX does not report the XML declaration, so parseXmlDocument stores the canonical XmlDeclaration (<?xml version="1.0" encoding="UTF-8"?>,
standalone omitted) on every successful parse, and that is what PrettyPrint writes back.
Every authored *.xml file PrettyPrint would rewrite already has that declaration, so this stays.
Parse/decode I/O is Either[XmlError, _]; XmlError wraps the cause.
loadCatalog / loadResources throw (programmer catalogs); attemptCatalog / attemptResources stay in Either.
Unknown By ids and unmatched catalog keys throw.
Construction is private trait XmlAstDsl, mixed only into object Xml.
XmlAst is rebuild and to[TO].
The DSL was inspired by ZIO Blocks HTML (zio-blocks-html 0.0.56: tag functions,
:= / +=, ToModifier flattening, .when, inlineJs / externalJs).
import org.podval.xml.dsl.{*, given} (or Xml.div) builds the same tree as parsed markup.
div(className := "toc", h3("Table of Contents"), ul(items))
script(typeAttr := "module").inlineJs(code)
element("urlset", xmlns := ns, urls)
I tried ScalaTags for generation, and they work, but ScalaTags has no parser,
so generating HTML wrappers for XML parsed from files is not pleasant (issue 102).
ScalaTags converts that tree (element.to[ScalaTags.Element] after import ScalaTags.given).
A second HTML AST (including zio-blocks-html as a construction-only tree) has the same problem.
This DSL builds Xml.Element.
Another AST is element.to[TO].
Convert another AST with element.to[TO] (HTML: element.to[ZioBlocksHtml.Element] after import ZioBlocksHtml.given;
ScalaTags: element.to[ScalaTags.Element] after import ScalaTags.given).
HtmlXmlWriterConfig.render writes Xml.Element.
A ZioBlocksHtml.Element is element.to[Xml.Element] first (import Xml.given).
XmlCodec is a ZIO Schema Deriver that binds Scala records to XML documents (unwrapped sibling sequences, attributes
on leaf records).
An unannotated primitive is an attribute named after the field.
Identity fields are Xml.Element (child tag = field name); import XmlCodec.given (or import org.podval.xml.given)
for Schema[Xml.Element].
Decode and encode take Xml.Element.
A foreign tree is element.to[Xml.Element] before decode (ScalaXml.converted when NodeSeq.to would shadow it), and
codec.encode(value).to[TO] after encode.
Leftover parent content is an error unless @Modifier.config(XmlCodec.IgnoreUnknown, "").
@Modifier.config(XmlCodec.Include, "") on Seq[String] gathers xi:include/@href.
@Modifier.transient skips a field on decode and encode; the default is used.
@Modifier.encodeTransient decodes the field and omits it on encode.
An unknown @Modifier.config key fails derivation.
Binding hints are @Modifier.config (XmlCodec.Attribute, XmlCodec.Element, XmlCodec.Text, XmlCodec.NamespaceUri,
XmlCodec.NamespacePrefix).
Name / Language / Language.Spec have Schema givens (Names has XmlCodec only); catalog DTOs use Seq[Name].
Those children are <name>: derivation registers Name.codec before it snapshots overrides, so the field needs no
@Modifier.config(XmlCodec.Element, "name").
A record’s tag defaults to its class name with a trailing Dto removed and the first character lower-cased (ChapterDto
is chapter).
Two leading capitals are left as written.
@Modifier.config(XmlCodec.Element, "week") on the class overrides that default.
A parent XmlCodec.derived inlines that tag and does not take the child codec.
XmlCodec.derived(element = "wrapper") names that derivation, and wins over the class annotation.
XmlCodec.derived[A, K](tagField, tag) is the tagged form.
Pass that codec, or a hand-written codec, when inlining would drop it.
Those overrides apply only to that derivation.
Schema[Xml.Element] does not carry the tree.
XmlParser.loadCatalog(from, resourceName, codec, wrapperName) when the file and root tag differ; loadResources
decodes one document per name.xml.
transform / gather / elements / rewrite, attributes, and CSS classes are members of Xml.Element.
Emit inserts finished nodes; Keep and Replace are walked again.
A foreign tree converts with to[Xml.Element] before those operations.
They skip <code> subtrees by default (stopAtCode = true); pass false to walk into them (publisher IR).
rewrite can keep one element, replace it with a node list, or emit finished nodes.
getById returns Option; childNamed is the first childrenNamed match.
isNamed("p") matches local name p, including a prefixed tei:p.
isNamed("tei:p") matches that qualified name only.
childElements is the element children.
flatMapNodes and convertElements are extensions on Seq[XmlNode] (import XmlNode.flatMapNodes, or
import org.podval.xml.dsl.*, which exports them).
They need no XmlAst given.
@Modifier.rename("chapter") renames a child or attribute that already has the right kind.
@Modifier.config(XmlCodec.Element, "comment") forces a primitive into an element.
NumberedSpanDto stays on the field, via rename, because one type is several tags.
A catalog is a wrapper element whose children are one record type (XmlCodec.decodeCatalog).
XmlParser.loadCatalog reads that file from the classpath and throws on a missing resource or a decode error (attemptCatalog
returns Either).
Catalog helpers pin Xml.
loadCatalog(from, codec) takes the name from XmlParser.className(from.getClass) (trailing $ stripped: Terms$ →
Terms):
resource: from.getClass.getResource(name + ".xml") — next to that class, not a library-wide path
wrapper: element named name (local name / qName)
So object Foo looks for Foo.xml with root <Foo>.
Child tags come from the codec (Term.codec → <term>, Names.codec → <names>).
Comments and whitespace between children are ignored; leftover character content is an error.
Pass a name when the Scala object is not named after the file (loadCatalog(from, name, codec)).
loadCatalog is parseResource plus decodeCatalog.
Use decodeCatalog(root, name) when the tree is already in hand.
Term (org.podval.metadata) is an id, child <name> elements, and optional selector.
Absent selector is false.
Catalogs author selector="yes".
Ids keep dots and spaces (nav.menu, day of the week).
Ends are trimmed.
They are not slugified.
A term with no <name> is an error.
plural, few, many, and two are attributes of <name>, in lexicon case.
one is the name itself.
There is no one attribute.
hasName / forName match n and text only.
A grammatical attribute sits on the first <name> of that language spec.
A later synonym of the same spec may omit it, and may not set it.
Blank text in a present attribute is an error.
This library has no Terms.xml.
object Terms uses loadCatalog(this, Term.codec) (Terms.xml / <Terms>).
The first English name of a selector term equals its id.
That check is requireSelectorEnglish on decode and in the TermCatalog constructor.
Selector(id) is Selector(id, Names(id)).
getById and By(selectorId) use the id.
By("книга") throws.
TermCatalog.forName returns Option[Term] and only sees selector terms (книга finds book), so a message may reuse
an axis translation.
Two selector terms with the same n fail.
Duplicate ids fail.
TermCatalog.merge is that check.
word, heading, pluralWord, pluralHeading, and cardinal on TermCatalog return strings.
heading and pluralHeading use Language.sentenceCase (first character only, for languages that have case; Hebrew
and Yiddish are unchanged; the rest of the string is not lowercased).
cardinal uses Language.pluralCategory.
A missing form throws when cardinal is called.
It is not checked at load.
org.podval.store adds TermCatalog.selector(id), which requires a selector term and returns Selector(id, names).
By(selector, stores) and By.Numbered(selector, min, max) do not use a catalog.
By.Numbered(selectorId, min, max, name2number, number2names) looks the id up, then passes custom names.
A nested package does not see a parent-package given; keep the given on the object and export it (export of given
from a package is not allowed):
package org.example
import org.podval.metadata.{Term, TermCatalog}
import org.podval.xml.XmlParser
object Terms:
given catalog: TermCatalog = TermCatalog(XmlParser.loadCatalog(this, Term.codec))
package tanach:
export org.example.Terms.given
Tests can skip XML:
import org.podval.metadata.{Language, Name, Names, Term, TermCatalog}
given TermCatalog = TermCatalog(Seq(
Term("book", Names(Seq(Name("book", Language.English.toSpec))), selector = true),
Term("part", Names(Seq(Name("part", Language.English.toSpec))), selector = true)
))
Names is final case class Names(names: Seq[Name]).
Names(name: String) builds Name(name, Language.Spec.empty).
There is no apply(Name).
Names(id) is not an English name and throws from requireSelectorEnglish.
Names.Loader[Key] loads <names> children and binds them to valuesSeq with HasName.mapByName (each <names> must
uniquely match a key’s .name; every key must match).
Default file is the loader’s class name: object Language → Language.xml / <Language>.
Pass resourceNameOverride for a different file.
toNames is lazy so a catalog can mention values of the same loader.
HasNames.ByLoader is the per-value hook (Language.English.names).
One artifact (org.podval:org.podval.xml).
It will not be split into separate Gradle or Maven modules; consumers depend on this coordinate and import the packages
they need.
org.podval.xml
owned AST Xml, plus XmlAst adapters for ZIO Blocks XML, Scala XML, ZIO Blocks HTML, and
ScalaTags.
Construction DSL (org.podval.xml.dsl) builds Xml only.
SAX parser (CDATA preserved), builder, and writer take Xml.
Another tree is element.to[TO].
XmlCodec is the Schema-derived document binder.
org.podval.metadata
multilingual Name / Names / HasNames / Language catalogs (HasName is the default-name
key).
Term is an id plus Names.
selector marks a store axis.
TermCatalog looks terms up by id.
org.podval.store
in-memory named tree; resolve / attempt / resolveOption / getPaths (Path.toUrl is the
encoded English-name URL from the node you called, with selector hops; resolve may omit a hop
when the name is unique).
Numbered URL names stay digits; extra names in number2names still round-trip.
Selector is an id plus names.
The string overloads of By and By.Numbered need given TermCatalog and look up selectorId
through TermCatalog.selector.
An unknown id fails.
forName still matches a selector name in any language.
This library does not expand xi:include.
JDK SAX is XInclude-unaware.
Publisher store/collection indexes treat xi:include/@href as a child page reference.
Xerces nested xml:base is still wrong (https://issues.apache.org/jira/browse/XERCESJ-1102); see CHANGELOG.
Scala 3.10, JDK 25 (-java-output-version:25).
./gradlew build ./gradlew test
Publish to Maven Central (local, USER_MANAGED):
./gradlew nmcpZipAggregation ./gradlew publishAggregationToCentralPortal
Then release the deployment at https://central.sonatype.com/publishing/deployments .
Scala XML does provide a pretty-printer, but it doesn’t do what I need it to do, especially when formatting TEI
documents.
For instance, it inserts a break between </e1> and <e2> in <e1>…</e1><e2>…</e2> and between </e1> and text
in <e1>…</e1>text, thus separating notes from what they are notes on and punctuation from its content by spaces.
Attempts to modify the behavior of the Scala XML pretty-printer (or at least to fix what looks like an obvious bug in
its Print.merge) were not successful, so I started looking for alternatives.
Compact, Streaming Pretty-Printing of Hierarchical Data looked promising, but it looks like to fine-tune behavior of the pretty-printer, I’d have to rework the code each time: as with ScalaTags, Li Haoyi’s focus seems to be performance, but I need flexibility to get the format I want without rewriting the whole algorithm for each experiment…
I remembered a paper by Phil Wadler on pretty-printing: A prettier printer, and almost started implementing it in Scala, but it turns out that there is an implementation already: Typelevel Paiges. With its declarative approach, I was able to tweak the output to my liking :)
A declaration is written only when that prefix is not already bound to the same URI.
A name with no URI does not gain a synthesized xmlns="".
An empty element is <e></e> unless its local name is in selfClose, or selfCloseEmpty is set.
HtmlXmlWriterConfig leaves selfCloseEmpty off, so an empty script stays <script></script> and br stays <br/>.
zio-blocks-schema-xml does not: it is only for the ZioBlocksXml adapter.
Each AST given is on its object, not in the package.
Bring one in with import ZioBlocksXml.given, import ZioBlocksHtml.given, import ScalaXml.given, or
import ScalaTags.given.
import Xml.given is for element.to[Xml.Element] from another tree.
The parser, writer, and builder take Xml only.
Parse and render of Xml.Element need no given.
Walk, attribute, and class operations on the owned Xml.Element are members and need no given.
import org.podval.xml.dsl.given summons Xml.
ZIO Blocks XML, ZIO Blocks HTML, Scala XML, and ScalaTags need an extra dependency, not pulled in by default.
parseHtml needs TagSoup (also not on the POM):
implementation "dev.zio:zio-blocks-schema-xml_3:0.0.56" implementation "dev.zio:zio-blocks-html_3:0.0.56" implementation 'org.scala-lang.modules:scala-xml_3:2.5.0' implementation 'com.lihaoyi:scalatags_3:0.13.1' implementation 'org.ccil.cowan.tagsoup:tagsoup:1.2.1'
dubinsky/xml is a public repo on GitHub by dubinsky. XML AST, codecs, named catalogs, and store path model.
It declares the Apache-2.0 license on GitHub.
Its maker has not tagged a system, so it is unknown here. Its README says what it needs.
Open "Take it" on its page: Take My Repo writes an install plan for your machine and hands it to your AI agent (Claude Code, Codex or Cursor), which asks you before each step. Take My Repo has not tested it on any machine.
Its last change on GitHub was on 2026-11-10. GitHub counts 1 open issue and pull requests. Take My Repo does not judge from that whether it is maintained.
Nobody has reviewed it on Take My Repo yet, which says nothing about its quality.
Gradle plugin for multi-backend Scala and sbt test frameworks
Raspberry Pi GPIO access
Gradle plugin to deploy a service described in a knative Service YAML file to Google Cloud Run from the local machine or from CI like GitHub Actions - or to run it in the local Docker.