Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8475105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:48:18+00:00 2026-06-10T17:48:18+00:00

I need to create a DOT graph on the basis of the following XML

  • 0

I need to create a DOT graph on the basis of the following XML file.

<layout>
 <layout-structure>
    <layout-root id="layout-root">
        <layout-chunk id="header-text">
             <layout-leaf xref="lay-1.01" location="row-1" area-ref="content"/>
             <layout-leaf xref="lay-1.02" location="row-2" area-ref="content"/>
        </layout-chunk>
        <layout-leaf xref="lay-1.03" location="row-3" area-ref="content"/>
    </layout-root>
    <layout-root id="layout-root-two">
        <layout-chunk id="header-text-two">
         <layout-leaf xref="lay-1.04"/>
             <layout-leaf xref="lay-1.05"/>
        </layout-chunk>
    </layout-root>
 </layout-structure>
<realization>
    <text xref="lay-1.01 lay-1.04"/>
    <text xref="lay-1.02 lay-1.05"/>
    <graphics xref="lay-1.03"/>
</realization>
<layout>

For this purpose, I use the following query to produce the DOT markup for each layout-root element in the XML:

declare variable $newline := '&#10;';
declare variable $dotgraphics := '[shape="box", style="filled", color="#b3c6ed"]';

declare function local:ref($root) {
 string-join((
  for $chunk in $root/layout-chunk
  return (
  concat('  "', $root/@id, '" -- "', $chunk/@id, '";', $newline),
  local:ref($chunk)
  ),
 local:leaf($root)), "")
 };

declare function local:leaf($root) {
 for $leaf in $root/layout-leaf
 return concat('  "', $root/@id, '" -- "', $leaf/@xref, '";', $newline)
};

declare function local:gfx($doc) {
for $layout-leafs in $doc//layout-leaf
let $graphics := $doc/realization//graphics
where $graphics[contains(@xref, $layout-leafs/@xref)]
return concat('"', $graphics/@xref, '" ', $dotgraphics, ';', $newline)
};

let $doc := doc("layout-data.xml")/layout
for $root in $doc/layout-structure/*
return string-join(('graph "', $root/@id, '" { ', $newline,
local:gfx($doc),local:ref($root),'}', $newline), "")

The result of the query for both layout-root elements is shown below:

graph "layout-root" { 
"lay-1.03" [shape="box", style="filled", color="#b3c6ed"];
"layout-root" -- "header-text";
"header-text" -- "lay-1.01";
"header-text" -- "lay-1.02";
"layout-root" -- "lay-1.03";
}
graph "layout-root-two" { 
"lay-1.03" [shape="box", style="filled", color="#b3c6ed"];
"layout-root-two" -- "header-text-two";
"header-text-two" -- "lay-1.04";
"header-text-two" -- "lay-1.05";
}

As you can see, the query uses the following function to change the colour and shape of the DOT markup, if an element is of the type graphics.

declare function local:gfx($doc) {
for $layout-leafs in $doc//layout-leaf
let $graphics := $doc/realization//graphics
where $graphics[contains(@xref, $layout-leafs/@xref)]
return concat('"', $graphics/@xref, '" ', $dotgraphics, ';', $newline)
};

However, this does not produce the wanted outcome, because it returns the line "lay-1.03" [shape="box", style="filled", color="#b3c6ed"]; also for the second graph (named layout-root-two), although it should only appear in the first graph (named layout-root).

How should I modify the function, so that it checks for the graphics elements in case of each layout-root under layout-structure?

I have attempted to call the function using the variable $root, but this results in a static error.

The wanted outcome is displayed below:

graph "layout-root" { 
"lay-1.03" [shape="box", style="filled", color="#b3c6ed"];
"layout-root" -- "header-text";
"header-text" -- "lay-1.01";
"header-text" -- "lay-1.02";
"layout-root" -- "lay-1.03";
}
graph "layout-root-two" { 
"layout-root-two" -- "header-text-two";
"header-text-two" -- "lay-1.04";
"header-text-two" -- "lay-1.05";
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T17:48:20+00:00Added an answer on June 10, 2026 at 5:48 pm

    You need the realization, which is not in the sub-tree of $root. Try passing in just the graphics node:

    declare function local:gfx($root, $graphics) {
      for $layout-leafs in $root//layout-leaf
      where $graphics[contains(@xref, $layout-leafs/@xref)]
      return concat('"', $graphics/@xref, '" ', $dotgraphics, ';', $newline)
    };
    
    let $doc := doc("layout-data.xml")/layout,
        $graphics := $doc/realization//graphics
    for $root in $doc/layout-structure/*
    return string-join(('graph "', $root/@id, '" { ', $newline,
             local:gfx($root, $graphics),local:ref($root),'}', $newline), "")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to create a DOT graph on the basis of the following XML:
I need to create a graph that have the following properties: The X Axis
I need to create regular expression for the word not starting with dot and
I need create custom dialog and put JPanel into it. Is it possible?
i need create an email list sending to many emails. what is best solution
I need create clone repository. but I do not know where can I get
I need create a document word with Java. And I ask, how can I
i need create a variable with parent subclass. Example: Parent Class <?php class parentClass
I use MS SQL 2008 R2, I need create a Table with a CHECK
I have dynamically created WrapPanel (_wp) with several Borders. And I need create handler

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.