Welcome to yEd Q&A!
Here you can ask questions and receive answers from other members of the community and yEd developers. And you can tell us your most wanted feature requests.


Open an XML file with data inside, not only elements

0 votes
Hi everyone,

I'm trying to open a xml file with yEd in the aim of visualising data.

It works but the graph consist in visualising XML's elements, not the data contained in.

For exemple:

<c id="de-130" level="item">
<unittitle label="Intitulé de l'unité documentaire">Eytan, Moshi. <emph render="italic">Convexité dans les ensembles ordonnés</emph>. Rap. /26/août 1969/M. Eytan</unittitle>
<unitdate label="Date de l'unité documentaire" normal="1969">1969</unitdate>
<genreform label="Typologie documentaire">rapport</genreform>
<subject label="Mot matière libre">ensemble convexe</subject>
<subject label="Mot matière libre">calcul</subject>
<subject label="Mot matière libre" source="liste-discipline">mathématiques</subject>
<persname label="Personne">Eytan, Moshi</persname>
<genreform source="liste-niveau">document</genreform>

Generated nodes are: "Controlaccess", "Genreform", "Subject" .... instead of: "rapport", "calcul" or "Eytan, Moshi", which are data I want to see.

However, the entire structure is perfect: all the edges are correct.

Can anyone help me?

Best regards,

Julien, French archivist
in Help by

1 Answer

0 votes

You need to write an XSLT stylesheet that transforms your XML into GraphML according to your requirements. You can use this stylesheet as a starting point:

  <xsl:output method="xml" indent="yes"/>
  <xsl:template match="/">
        xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://www.yworks.com/xml/schema/graphml/1.1/ygraphml.xsd">
      <key id="d0" for="node" yfiles.type="nodegraphics"/>
      <key id="d1" for="edge" yfiles.type="edgegraphics"/>
      <graph id="G" edgedefault="directed">
        <xsl:apply-templates select="//*" mode="create-nodes"/>
        <xsl:apply-templates select="/*//*" mode="create-edges"/>
  <xsl:template match="//*" mode="create-nodes">
    <xsl:element name="node">
      <xsl:attribute name="id">
        <xsl:value-of select="generate-id()"/>
      <data key="d0">
          <y:Fill color="#CCCCCC"/>
            <xsl:for-each select="@*">
              <xsl:value-of select="name()"/>
              <xsl:value-of select="."/>
  <xsl:template match="//*" mode="create-edges">
    <xsl:element name="edge">
      <xsl:attribute name="id">
        <xsl:value-of select="generate-id()"/>
      <xsl:attribute name="source">
        <xsl:value-of select="generate-id(parent::node())"/>
      <xsl:attribute name="target">
        <xsl:value-of select="generate-id()"/>


After importing your data, run "Tools" -> "Fit Node to Label" and "Layout" -> "Tree" -> "Directed".

by [yWorks] (160k points)
Thank you very much.

I tried with your XSLT stylesheet and there are some changes making me think it can provide a solution.
Now I have to learn XSLT!
Legal Disclosure | Privacy Policy