flxzt/rnote · error
failed to parse `x` attribute in XoppText with node id
Error message
failed to parse `x` attribute in XoppText with node id {:?}, could not find attribute What it means
Thrown by XoppText::load_from_xml when a `<text>` element has no `x` attribute. The x coordinate is parsed as f64 and is required to position the text on the page, so its absence aborts parsing with this error naming the node id.
Solutions
- Add an x attribute to the <text> element, e.g. x="100.0".
- Regenerate the file ensuring font, size, x, y, and color are all present on every <text> element.
- Re-save the file in Xournal++ and import the normalized copy.
Example fix
// before (file XML) <text font="Sans" size="12" y="20">Hello</text> // after (file XML) <text font="Sans" size="12" x="100" y="20">Hello</text>
Defensive patterns
Strategy: validation
Validate before calling
fn text_has_x(xml: &str) -> Result<(), String> {
for (i, chunk) in xml.split("<text").skip(1).enumerate() {
let head = chunk.split('>').next().unwrap_or("");
if !head.contains("x=") {
return Err(format!("text #{i} missing `x` attribute"));
}
}
Ok(())
} Type guard
fn has_numeric_attr(attrs: &[(&str, &str)], name: &str) -> bool {
attrs.iter().any(|(k, v)| *k == name && v.parse::<f64>().is_ok())
} Try / catch
match import_xopp(path) {
Err(e) if e.to_string().contains("`x` attribute in XoppText") => {
eprintln!("Text element missing x coordinate; add it or re-save in Xournal++: {e:#}");
}
Err(e) => eprintln!("import failed: {e:#}"),
Ok(doc) => { /* proceed */ }
} Prevention
- Always emit x and y coordinates on text elements in generated files
- Validate required coordinates before import attempts
- Keep generated XML close to Xournal++'s own output format
When it happens
Trigger: Importing a .xopp file whose <text> element lacks the `x` position attribute — generated by external tools, hand-edited, or corrupted/truncated files.
Common situations: Programmatic xopp generation omitting coordinates; manual XML editing; partial file writes losing attributes.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- failed to parse `tool` attribute in XoppStroke with node id
- failed to parse `color` attribute in XoppStroke with node id
- failed to parse `width` attribute in XoppStroke with node id
- failed to parse `font` attribute in XoppText with node id
- failed to parse `size` attribute in XoppText with node id
AI-assisted analysis of flxzt/rnote@bbc5354502 (2026-09-08).
Data as JSON: /api/errors/b2443f565662e323.
Report an issue: GitHub.
Appendix: source
Thrown at crates/rnote-engine/src/fileformats/xoppformat.rs:887
node.id()
)
})?
.to_string();
self.size = node
.attribute("size")
.ok_or_else(|| {
anyhow::anyhow!(
"failed to parse `size` attribute in XoppText with node id {:?}, could not find attribute",
node.id()
)
})?
.parse::<f64>()?;
self.x = node
.attribute("x")
.ok_or_else(|| {
anyhow::anyhow!(
"failed to parse `x` attribute in XoppText with node id {:?}, could not find attribute",
node.id()
)
})?
.parse::<f64>()?;
self.y = node
.attribute("y")
.ok_or_else(|| {
anyhow::anyhow!(
"failed to parse `y` attribute in XoppText with node id {:?}, could not find attribute",
node.id()
)
})?
.parse::<f64>()?;
self.color =
XoppColor::from_strokecolor_attr_value(node.attribute("color").ok_or_else(|| {View on GitHub (pinned to bbc5354502)