Skip to content
This repository has been archived by the owner on Jun 23, 2019. It is now read-only.

Diagram selection based on name instead of index. #8

Open
NicolasRouquette opened this issue Feb 4, 2019 · 6 comments
Open

Diagram selection based on name instead of index. #8

NicolasRouquette opened this issue Feb 4, 2019 · 6 comments
Assignees

Comments

@NicolasRouquette
Copy link

The current -d <index> argument parses an integer diagram index.
It isn't explained but the index starts from 1; which corresponds to the index of the diagram page in the UI.
I think it would be useful to have a diagram selection based on the diagram page name.

@kammoh
Copy link

kammoh commented Feb 4, 2019

I'd like to add that currently there seems to be no way to get the number of pages in the diagram or to traverse over them. It would be very nice to have this feature as well as it facilitates automatic flows e.g. in documentation generation.

@NicolasRouquette
Copy link
Author

@xnorme This could be done with a small XSLT script like this:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0">
<xsl:output method="text"/>

<xsl:template match="/mxfile">
  <xsl:for-each select="diagram">
    <xsl:value-of select="concat(@name,'&#xA;')"/>
  </xsl:for-each>
</xsl:template>

</xsl:stylesheet>

Save this as, e.g., diagrams.xsl.
Then you can get the list of diagram names by running an XSLT processor with this style sheet over the *.xml file.

For example, on linux, with the diagram from #9 (comment)

xsltproc diagrams.xsl example.xml

You get:

Page-1

@languitar
Copy link
Owner

I'd like to add that currently there seems to be no way to get the number of pages in the diagram or to traverse over them. It would be very nice to have this feature as well as it facilitates automatic flows e.g. in documentation generation.

drawio-batch, so far, was never intended for multi page documents and complex workflows. For my own needs I never use multi-page documents and the current selection is a contribution I received. I am not sure whether I want to provide document inspection, which would require a completely different workflow with multiple calls to drawio-batch and a mode that only outputs page information. However, selection based on page name and an optional mode to output multiple (or all) pages of a document sounds reasonable.

@kammoh
Copy link

kammoh commented Feb 8, 2019

Thank you @NicolasRouquette, that works like a charm!
I understand your point @languitar. The option for output of all pages in a document would be quite nice :)

@languitar languitar self-assigned this Feb 11, 2019
@NicolasRouquette
Copy link
Author

@xnorme FYI: I was testing this fix #9 (comment) and found that the index changed from 1-based to 0-based.

@languitar
Copy link
Owner

@xnorme FYI: I was testing this fix #9 (comment) and found that the index changed from 1-based to 0-based.

That might be an upstream change. I didn't do anything in that direction.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants