flxzt/rnote · error
failed to parse width attribute of XoppPage for node with id
Error message
failed to parse width attribute of XoppPage for node with id {:?}, could not find attribute What it means
While parsing a Xournal++ (.xopp) XML document, the <page> element lacked a required 'width' attribute. XoppPage::load_from_xml treats width as mandatory and returns an error when roxmltree's attribute lookup returns None.
Solutions
- Open the .xopp file in Xournal++ and re-save it to regenerate valid attributes
- Add the missing width attribute to the <page> element (e.g. width="793.7007874015748")
- Regenerate the file from its source tool with proper page dimensions
- Validate the XML against the xopp format before loading
Example fix
// before <page> <background .../> </page> // after <page width="793.7007874015748" height="1122.5196850393701"> <background .../> </page>
Defensive patterns
Strategy: validation
Validate before calling
fn page_has_dimensions(node: &roxmltree::Node) -> bool {
node.attribute("width").is_some() && node.attribute("height").is_some()
} Try / catch
match xopp_page.load_from_xml(page_node) {
Err(e) if e.to_string().contains("width attribute") => {
// supply default page width and continue or report
}
other => other,
} Prevention
- Validate xopp XML attributes before import
- Re-save suspect files in Xournal++
- Never hand-edit .xopp XML without both width and height present
When it happens
Trigger: Calling load_from_xml on a <page> node without a 'width' attribute, e.g. loading a .xopp file whose page element is hand-edited, generated by a non-conforming tool, or truncated.
Common situations: Importing a .xopp file produced by third-party generators or older/modified Xournal++ versions; corrupted XML where attributes were dropped; template files edited manually.
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 height attribute of XoppPage with node id
- failed to parse `type` attribute of XoppBackground with…
- Failed to parse `domain` attribute in XoppBackground with…
- Failed to parse `filename` attribute in XoppBackground with…
- Err while parsing `style` attribute of XoppBackground
AI-assisted analysis of flxzt/rnote@bbc5354502 (2026-09-08).
Data as JSON: /api/errors/ce487ea7524d95f5.
Report an issue: GitHub.
Appendix: source
Thrown at crates/rnote-engine/src/fileformats/xoppformat.rs:153
/// A Xopp Page.
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
pub struct XoppPage {
/// The width of the page.
pub width: f64,
/// The height of the page.
pub height: f64,
/// The Background of the page.
pub background: XoppBackground,
/// The layers of the page.
pub layers: Vec<XoppLayer>,
}
impl XmlLoadable for XoppPage {
fn load_from_xml(&mut self, node: Node) -> anyhow::Result<()> {
self.width = node
.attribute("width")
.ok_or_else(|| {
anyhow::anyhow!(
"failed to parse width attribute of XoppPage for node with id {:?}, could not find attribute",
node.id()
)
})?
.parse::<f64>()?;
self.height = node
.attribute("height")
.ok_or_else(|| {
anyhow::anyhow!(
"failed to parse height attribute of XoppPage with node id {:?}, could not find attribute",
node.id()
)
})?
.parse::<f64>()?;
for child in node.children() {
match child.node_type() {View on GitHub (pinned to bbc5354502)