Custom sheet attributes and values

Hi All,

New to dia and Gnome discourse, so apologies in advance if I upset someone.

I am learning to create custom sheets and shapes in dia. I am using version 0.97 on Debian 10.

I noticed in the sheet and shape tags there is an xmlns attribute which contains a link, either or
Both of these links are broken but if you remove them it breaks the shape the sheet or sometimes dia?

I have been scouring the docs and the web but I am unable to find a description of what valid attributes and values may contain.




Sorry I didn’t see this before, been (are…) having email problems

Unfortunately I’m not sure those addresses were ever “real” but as you’ve noticed Dia is a fairly heavy user of XML namespaces and will reject files without them

Looking at the code reading the files, <shape>:

  • <name> - The shapes name/ID
  • <icon> - A path to a PNG to use in the toolbox (relative to the shape file)
  • <connections> - A list of connection points
    • <point x=double y=double main> the x/y position on the shape, specifying main makes this the “main” CP (a shape can only have one main)
  • <can-parent> - marks the shape as parentable
  • <textbox x1=double y1=double x2=double y2=double resize={no} align={left,right}> - add an editable textbox to the shape (you can only have one!)
    • Resizable is the default, use resize="no" to disable
    • Default alignment it centre (but only left/right are valid align values - just omit for centre)dia_unit_get_symbol
    • The box is drawn from (x1, y1) to (x2, y2)
  • <aspectratio type={free,fixed,range} min=double max=double> - control the aspect constraints
    • Default type is free
    • min/max are used to set the range of values of range allows
  • <default-width>/<default-height> - set the default size of the shape
    • Interestingly these actually actually allow unit suffixes (one of cm,dm,ft,in,m,mm,pt,pi)
  • <svg> - finally the actual image to draw (note you need to namespace (svg:) elements and Dia only has fairly minimal SVG support)

(It’s somewhat expected that you export shapes from Dia rather than writing them by hand)

Sheet is much simpler:

  • <name> - the name of the sheet (note this is translatable via xml:lang)
  • <description> - a description of the sheet (also translatable)
  • <contents> - a list of objects
    • <object intdata=int chardata=string name=string> - you can think of this as synonymous to a shape
      • intdata doesn’t apply to shapes
      • chardata doesn’t apply to anything
      • name to march your shapes’s <name>
      • <description> - as on the overall sheet
      • <icon> - but this time relative to the sheet
        • This doesn’t really apply to shapes
      • <alias name=string> - marks this object as alternativly being called name
        • Really this doesn’t belong in a sheet - Dia is full of fun quirks like this
    • <br> - force the toolbox to wrap
      • Must say I’m not a big fan of this and makes things needlessly complex but c’est la vie

I agree that exporting the shapes from Dia looked like the norm, and I read and followed the docs no problem.

What started me down the “use a text editor” path was trying to add an editable text box?

I may have missed something, but I could not see how to add editable text or attributes using Dia to create the shape? That’s when I noticed the xmlns attributes. As there is more than one address I thought they must be being compared to a list somewhere but couldn’t find it. :thinking:

I’m playing with subshapes now to see if I can create a shape with a small image in the top left corner that remains the same same size regardless of the text box entry. :slight_smile:

Thanks for the help Zander.

Indeed <textbox> has to be added by hand

There is one address per type - Note a shape and sheet, whilst both XML, are quite different things

Happy Diagramming :slight_smile:

I’m reasonably sure I understand the difference between a sheet and a shape, the sheet being basically a list or shortcut to the available shapes, and a shape being the svg description to draw on the screen.

This tag, containing one network reference <sheet xmlns=""> is in a sheet.

This tag containing two network references <shape xmlns="" xmlns:svg=""> is in a shape.

What I noticed was both tags were network addresses. So I checked the addresses and found they were not valid. This made me curious, as I couldn’t figure out what reason there could be for having an invalid link that breaks the program if it is changed?

Dia works without a network connection, but the two address strings cannot be altered without breaking the program. I’m not concerned about them, just curious as to what they are for? :thinking:

I’ve tried Dia a couple of times before with varying degrees of success, but for some reason this time round I have really started to click with it, and it is a really cool tool, thanks guys.

I’m a fan of Python as well, so I’m quite keen on having a play with that as well. I was looking for a way to capture a click event so I could open a link in a new window rather than a new tab, so any hints on that would be great.

Have a great day and stay safe. :+1:

It’s an XML namespace not a ‘link’ per se. Ideally it would be a “real” address providing documentation but really it’s just an ID.

Removing/changing it is like changing the file extension of a document

For shapes your seeing the X in XML - it’s extensible - and we are using two namespaces at once (which can be confusing, but avoids Dia having to redefine SVG when SVG already exists). You could think of xmlns as being similar to Python’s import

I’ll be sure to enjoy the remaining 20 mins :slight_smile:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.