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 http://www.daa.com.au/~james/dia-shape-ns or http://www.lysator.liu.se/~alla/dia/dia-sheet-ns.
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.

Cheers

Buzz

1 Like

Hello!

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.

1 Like

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:

1 Like

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="http://www.lysator.liu.se/~alla/dia/dia-sheet-ns"> is in a sheet.

This tag containing two network references <shape xmlns="http://www.daa.com.au/~james/dia-shape-ns" xmlns:svg="http://ww.w3.org/2000/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.