npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@galaxy-tool-util/tool-xml

v1.13.1

Published

XML tool-source layer for Galaxy tools — macro expansion (port of galaxy.util.xml_macros) and XML parsing into ParsedTool

Downloads

538

Readme

@galaxy-tool-util/tool-xml

XML tool-source layer for Galaxy tools. Holds the XML-specific parsing weight (an XML parser dependency) out of the browser-safe @galaxy-tool-util/schema package.

Currently ships a port of Galaxy's macro expander, lib/galaxy/util/xml_macros.py: the XML-only, pre-parse transform that expands <macros> — <token> substitution (including nested tokens and cycle detection), <xml>/<macro> templates via <expand>, <import> of external macro files, named/unnamed yield, and macro token parameters — mutating an XmlElement tree in place.

import { loadTool, canonicalize } from "@galaxy-tool-util/tool-xml";

const expanded = loadTool("tool.xml"); // reads + expands macros

parseXmlToTree(text) parses XML into a mutable XmlElement tree; expandMacros(root, importResolver) expands it (filesystem-agnostic); loadTool(path) is the filesystem-backed convenience that resolves <import> paths relative to the tool file. canonicalize(el) reduces a tree to a whitespace-normalized shape for structural comparison.

Behavior is verified against golden macro-expansion fixtures synced from Galaxy (test/fixtures/macro-expansion/cases/), compared structurally rather than byte-for-byte so the port need not reproduce Galaxy's XML serializer.

On top of the expander, XmlToolSource ports the parse accessors from Galaxy's galaxy.tool_util.parser.xml.XmlToolSource that don't need the input-parameter tree — the tool metadata (id, version, name, description, profile, license, edam operations/topics, xrefs, citations, help, command) and the <outputs> tree (parseOutputs() → the ToolOutput union: data / collection / expression outputs, with discover_datasets):

import { loadXmlToolSource } from "@galaxy-tool-util/tool-xml";

const src = loadXmlToolSource("tool.xml");
src.parseId(); // "cat1"
src.parseCitations(); // [{ type: "doi", content: "..." }]
src.parseOutputs(); // [{ type: "data", name: "out1", format: "bam", ... }]

Extraction is raw — the model-level validation Galaxy's pydantic models run when the ParsedTool is assembled is not applied yet. parseCitations passes doi:-prefixed or malformed citations through rather than normalizing/dropping them (DOI/BibTeX shape checks, profile-gated skips), and parseOutputs does not enforce the collection-structure invariants (e.g. both type and type_source set) that Galaxy raises on.

Assembling these (plus inputs, behind the InputSource seam) into a full ParsedTool, with that validation, is the remaining work; see the repository's tool-parsing issue.