Distinct combination of value for a specific path - xquery

I've a XML tree where each node has one child. As show here.
Is there a way to find the distinct combination of values related to a specific path?
For example if consider the tree in the previous example, I would like to find all the different combinations of tag based on their values:
INPUT: /A/C/D
<A value="5.4"><C value="1.7"><D value="0.4"></D></C></A>
<A value="5.1"><C value="1.4"><D value="0.2"></D></C></A>
<A value="5.1"><C value="1.4"><D value="0.4"></D></C></A>
<A value="5.0"><C value="1.4"><D value="0.2"></D></C></A>
<A value="5.0"><C value="1.5"><D value="0.2"></D></C></A>
<A value="4.9"><C value="1.5"><D value="0.1"></D></C></A>
<A value="4.6"><C value="1.5"><D value="0.2"></D></C></A>
<A value="4.6"><C value="1.4"><D value="0.3"></D></C></A>
<A value="4.4"><C value="1.4"><D value="0.2"></D></C></A>
INPUT: /C/D
<C value="1.4"><D value="0.2"></D></C>
<C value="1.4"><D value="0.3"></D></C>
<C value="1.4"><D value="0.4"></D></C>
<C value="1.5"><D value="0.1"></D></C>
<C value="1.5"><D value="0.2"></D></C>
<C value="1.7"><D value="0.4"></D></C>

You could try something like
distinct-values(
A//C//D/string-join(
ancestor-or-self::*[self::A|self::C|self::D]/#value, '|'))

Related

I'm adding a link on ui page but it getting error it's not added

<a class="button" target=_remotePage" href=" here give a link but it's getting error on ui page">
Daily unit values
</a>
You have malformed HTML code, try this:
<a class="button" target="_blank" href="#">my link</a>
Valid options for target are:
_blank
_self
_parent
_top
framename
Reference: https://www.w3schools.com/tags/att_a_target.asp

Is it possible to replace a class with routerLinkActive instead of just adding a class?

I have an icon on a navigation bar which serves as a link to a admin route, I'd like this icon to change when I'm on that specific route, for this I can just replace the mdi-settings-outline class with mdi-settings, which will show a filled version of the same icon.
<li class="nav-item">
<a routerLink="/admin" routerLinkActive="mdi-settings" class="nav-link mdi mdi-settings-outline"></a>
</li>
However the regular routerLinkActive directive will only add the mdi-settings class to the link, which won't have the desired result. Can the routerLinkActive directive somehow replace the class instead of just adding it?
The routerLinkActive exports some properties that you can use in the template. You access the API by assigning the directive to a template variable. This is done by adding #link="routerLinkActive" where "link" is the name of the variable.
You can then use the properties of the directive, which are defined here in the API documentation.
https://angular.io/api/router/RouterLinkActive#properties
<li class="nav-item">
<a routerLink="/admin"
routerLinkActive="mdi-settings"
#link="routerLinkActive"
class="nav-link mdi"
[class.mdi-settings-outline]="!link.isActive"
></a>
</li>
Need to make the variable unique for each link
<a mat-list-item
[routerLinkActive]="['']"
[routerLinkActiveOptions]="{ exact: true }"
#reportsLink="routerLinkActive"
[ngClass]="reportsLink.isActive ? 'route-active': 'route-inactive'"
[routerLink]="['/reports']"
title="Reports">
</a>
<a mat-list-item
[routerLinkActive]="['']"
[routerLinkActiveOptions]="{ exact: true }"
#notificationsLink="routerLinkActive"
[ngClass]="notificationsLink.isActive ? 'route-active': 'route-inactive'"
[routerLink]="['/notifications']"
title="Notifications">
</a>

Interpolate variable into class with Angular

I would like to dynamically generate a class name for my element. For example,
<span class=``icon icon-${route.title}``></span> (had to use double backticks here, but it should really be just one set of backticks.)
<ul class="sidebar-list">
<li *ngFor="let route of menuRoutes.items">
<span class=`icon icon-${route.title}`></span>
<a routerLink="/{{route.path}}" routerLinkActive="active">{{ 'menu.' + route.title | translate}}</a>
</li>
</ul>
Try this:
<span class="icon icon-{{route.title}}"></span>
You can also archive this by using a [ngClass] directive
<span [ngClass]="['icon', route.title]"></span>

How can we extract elements value if elements attribute is dynamically changing

How can we extract value by using xpth or css selector if the attribute is dynamically changed for example:
<p data-reactid=".2e46q6vkxnc.1.$0">
<b data-reactid=".2e46q6vkxnc.1.$0.0">Mark Obtain</b>
<i class="avu-full-width" data-reactid=".2e46q6vkxnc.1.$0.1">
<span data-reactid=".2e46q6vkxnc.1.$0.1.0"> </span>
<span data-reactid=".2e46q6vkxnc.1.$0.1.1">450 A+.</span>
</i>
</p>
<p data-reactid=".2e46q6vkxnc.1.$1">
<b data-reactid=".2e46q6vkxnc.1.$1.0">Student Name</b>
<i class="avu-full-width" data-reactid=".2e46q6vkxnc.1.$1.1">
<span data-reactid=".2e46q6vkxnc.1.$0.1.0"> </span>
<span data-reactid=".2e46q6vkxnc.1.$0.1.1">First Name</span>
</i>
</p>
In this case attribute of element is dynamically changing but "Mark Obtain" and "Student Name" will always be same, so is there any way or can we write if condition or some regex along with xpath expression to get "450 A+" and "First Name" values.
Please help
To get required values you can use below XPath expressions:
//p[b="Mark Obtain"]//span[2]/text()
to get "450 A+."
and
//p[b="Student Name"]//span[2]/text()
to get "First Name"

Wordpress - link is being stripped when I post, how to stop?

When I try to post this:
<a class="post-handle" href="#" data-timestamp="2.09">my link</a>
The post ends up as:
<a class="post-handle" href="#">my link</a>
How can I stop WP from swallowing the data-timestamp="2.16" portion?

Resources