How to create a flow chart using mermaid that where children should be seperate for each parent, though it is same children - mermaid

Expected flowchart to be:
With below code, i could see the children getting clubbed togethere since the children is same. Is it possible to have different children for each parent, though the children are same ?
flowchart TB
access-denied --> content-viewport --> yield
404 --> content-viewport --> yield
feature-not-available --> content-viewport --> feature-not-available-component

No - this is not currently possible. However, if you give each "content-viewport" a unique ID you can achieve something similar:
flowchart TB
access-denied --> content-viewport1[content-viewport] --> yield1[yield]
404 --> content-viewport2[content-viewport] --> yield2[yield]
feature-not-available --> content-viewport3[content-viewport] --> feature-not-available-component
https://mermaid.live/edit#pako:eNp9kU1PwzAMhv9KlfOyrh90Ww8cEBw5wYl1Bzdx24g0qVK30zT1v5N2AgQa5JL49esnsXNhwkpkOau0PYkGHAWvD4UJ_AIhsO-5RKNQBpzfB8IaQkN8VHjqrKPo8Fs5Lr6zQi2jw7Idr7B0k95ExP8h4h-ICoEGh9xY4jCC0lBqvAlN_oDeJHBh284a72Yr1qJrQUk_j8t8acGowRYLlvujBPdesMJM3gcD2ZezESwnN-CKDZ0EwkcFtYOW5RXo3qsdmDdrv2OUiqx7vg58mftn5dOS-TJqCxJ9eGF07mZzrfr5eb6tStWzPjjt5Yao6_MwnNPrWlEzlGvfTtgrOX9lM-6zMIuzHcQJZtsE7pJEijLa76o4jSq53UQxsGmaPgDTWLHg

Related

Xpath - How to select a node but not its child nodes

I am trying to select a node but not any of its child nodes.
Example Input:
<Header attr1="Hello">
<child1> hello </child1>
<child2>world</child2>
</Header>
Expected Output: <Header attr1="Hello"> </Header>
Code:
Document xmlDoc = saxBuilder.build(inputStream);
Xpath x = XPath.newInstance("/Header");
eleMyElement = x.selectSingleNode(xmlDoc);
XMLOutputter output = new XMLOutputter();
output.outputString(eleMyElement) --> this is the output
I tried with /Header as XPath, it gives me the header along with child nodes.
You need to distinguish what is selected from what is displayed.
The XPath expression /Header selects one node only, the Header element. You say "it gives me", but what is "it"? Something is displaying the results of the XPath selection, and it is choosing to display the results by rendering the selected element with all its children. You need to look at the code that is displaying the result.
In this case you can simply do
eleMyElement.getContent().clear();
and all child nodes will be deleted.

how can I select the text in the parent node after the current tag in xsl?

I have the following xsl:
<titleGroup>
<title type="main" xml:lang="en">Synthesis of <i>N</i>‐Heterocyclic Carbenes and Their Complexes by
Chloronium Ion Abstraction from 2‐Chloroazolium Salts Using Electron‐Rich Phosphines
</title>
</titleGroup>
if I'm at the template that calls "i" how can I check the value "‐Heterocyclic Carbenes and Their Complexes by
Chloronium Ion Abstraction from 2‐Chloroazolium Salts Using Electron‐Rich Phosphines" in XSL I want the part which is after the current node only, not the part before?
From the context of i, the instruction:
<xsl:value-of select="following-sibling::text()[1]"/>
will return the value of the closest following sibling text node.

Odoo 8: Nested form view of Many2one field

I am in the process of refactoring a model (let's call it Parent), which stores a number of Many2one fields that reference records of the same model (Child). The Parent form view contains a notebook and each page displays details for a specific Child, currently described within the page in a repetitive fashion and with lots of related fields. I'm trying to avoid the repetition in the view, and get rid of the need for the related fields.
class Child(models.Model):
_name = "child"
# ...
class Parent(models.Model):
_name = "parent"
child_1 = fields.Many2one('child', 'Child 1')
child_1_age = fields.Float(related='child_1.age', string='Child Age')
# ...
child_2 = fields.Many2one('child', 'Child 2')
child_2_age = fields.Float(related='child_2.age', string='Child Age')
# ...
<!-- ... -->
<field name="model">parent</field>
<field name="type">form</field>
<field name="arch" type="xml">
<notebook colspan="8" col="8">
<page>
<!-- buttons, a bunch of related Child fields, etc -->
</page>
<page>
<!-- buttons, a bunch of related Child fields, etc -->
</page>
</notebook>
</field>
I have a special form view defined for the Child, but I don't know how to insert it in the notebook pages of the Parent view. Since it is possible to insert tree views in forms (like for One2many fields for example), I guess there has to be a way to do it with forms as well. An example how to achieve this effect would be greatly appreciated.
Please ignore any syntax errors, the above is just a simple visual representation to help better describe my case.
You can use the widget attribute in order to assign a widget to your relational field, for example
<field name="my_field" widget="my_widget"/>
To see an example as to how a widget works and is created take a look at the following example:
Go to addons/account/project/wizard/account_analytic_journal_report_view.xml and see the line that defines a many2many_tags widget.
This form widget is assigned on addons/web/static/src/js/view_form.js at around line 6396 that comments Registry of form fields ...
The many2many_tags string that we used is assigned a actual widget, that widget has a template, and that template is rendered in place of your field.
TL;DR Give a widget element to your field, define that widget, assign that widget to work on a template and create the template that contains your view.

Need a xpath : where parent having multiple child, but i required only parent value

In below code: parent "div" having three child "span", "script" and "span". but i required the value of Parent "div" which "N/A". "N/A" not comes under any attribute of div. Its just a value of parent "div".
<div class="ah-text-align-right ah-font-xsmall" style="">
<span id="_dcmanageinvestmentsportlet_WAR_ahdcmnginvportlet__FDROR_110hidden" style="display:none">
<script type="text/javascript">
<span class="ah-float-left">
N/A
</div>
For getting parent element you can use double dot .. after child element xpath.
For getting text of an element you can use xpath text() function, but depending on implementation of xpath in whatever environment and code you use, it might be unavailable. Note, that text of an element will return actual text node of this element as well as all text nodes of child elements.
For your case if you search a parent of a span with ah-float-left class, then xpath should be something like following:
//span[#class='ah-float-left']/..
For getting text of a parent, you'll need following:
//span[#class='ah-float-left']/../text()
Note: looking elements up by class name may return you a collection of elements which in turn will return you collection of parent elements and collection of parent nodes texts, which may not be desired. I would recommend lookup child element by id, since xhtml prescribes that elements ids are unique. Thus, an xpath for a parent div should better look like following:
//span[#id='_dcmanageinvestmentsportlet_WAR_ahdcmnginvportlet__FDROR_110hidden']/..

How to select node which has a parent with some attributes

How to select node which has a parent with some attributes.
Eg: what is Xpath to select all expiration_time elements.
In the following XML, I'm getting error if states elements has attributes, otherwise no probs.
Thanks
<lifecycle>
<states elem="0">
<expiration_time at="rib" zing="chack">08</expiration_time>
</states>
<states elem="1">
<expiration_time at="but">4:52</expiration_time>
</states>
<states elem="2">
<expiration_time at="ute">05:40:15</expiration_time>
</states>
<states elem="3">
<expiration_time>00:00:00</expiration_time>
</states>
</lifecycle>
states/expiration_time[../#elem = "0"]?
Use:
/*/*/expiration_time
This selects all expiration_time elements that are grand-children of the top-element of the XML document.
/*/*[#*]/expiration_time
This selects any expiration_time element whose parent has at least one attribute and is a child of the top element of the XML document.
/*/*[not(#*)]/expiration_time
This selects any expiration_time element whose parent has no attributes and is a child of the top element of the XML document.
/*/*[#elem = '2']/expiration_time
This selects any expiration_time element whose parent has an elem attribute with string value '2' and that is (the parent) a child of the top element of the XML document.
This will give you all nodes having atleast one attribute
//*[count(./#*) > 0]

Resources