Can you partially order xml data types using an xquery when the logical columns aren't consistent (such as when there are headers in the first row(s))?
Edit Had a bad example, mislead answers away from original question. How could I order the typ column values, leaving the th headers at top? Or vice versa, ordering by the integer column rts instead?
Say I have this XML stored in an mssql XML field (select thexml from xmldata returns one row containing the following):
<table cellpadding="2" cellspacing="3" border="1">
<tr>
<th>typ</th>
<th>rts</th>
</tr>
<tr>
<td>ABC</td>
<td>26</td>
</tr>
<tr>
<td>DCC</td>
<td>21</td>
</tr>
<tr>
<td>DBB</td>
<td>4</td>
</tr>
<tr>
<td>XBQ</td>
<td>152</td>
</tr>
<tr>
<td>AHI</td>
<td>349</td>
</tr>
</table>
Now say I want to sort this by the HTML column typ. I'm looking for the following result:
<table cellpadding="2" cellspacing="3" border="1">
<tr>
<th>typ</th>
<th>rts</th>
</tr>
<tr>
<td>ABC</td>
<td>26</td>
</tr>
<tr>
<td>AHI</td>
<td>349</td>
</tr>
<tr>
<td>DBB</td>
<td>4</td>
</tr>
<tr>
<td>DCC</td>
<td>21</td>
</tr>
<tr>
<td>XBQ</td>
<td>152</td>
</tr>
</table>
Any XQuery experts who can break this down for me?
To sort on a particular column, reconstruct the table and then sort on non header rows:
SELECT thexml.query('
element table {
/table/#*,
/table/tr[th], (: copy header :)
for $r in /table/tr[not(th)] (: exclude header :)
order by $r/td[1] (: $r/td[2] to sort on rts col :)
return $r
}')
FROM xmldata
Related
I want to multiply {value.item.itemPrice} and {value.itemCount} and assigned to next<td></td>..I tried using {value.item.itemPrice}*{value.itemCount} but not working.please help me to solve this.I get this values from axios get API call.
<tbody>
{itemList.map((value, key) => (
<tr key={key}>
<td>{value.itemId}</td>
<td>{value.item.itemPrice}</td>
<td>{value.itemCount}</td>
<td>{value.item.itemPrice}*{value.itemCount}</td> //not woring this
</tr>
))}
<tr>
<td></td>
<td></td>
<td>Total</td>
<td>total here</td>
</tr>
</tbody>
When you use {my_var} everything that is inside is executed as javascript code and you can do mathematical operations or whatever you need.
This is how your code would be so that it works as you need.
<td>{value.item.itemPrice * value.itemCount}</td> // this code is ready
Bracket {} will tell JSX parser that the syntax should be interpreted as javascript and return value to be shown. Did you try ?
{value.item.itemPrice * value.itemCount}
Try That:
<td>{value.item.itemPrice * value.itemCount}</td>
you were displaying * as a text because it was outside of the brackets, then it wouldn't multiply
Given a set of columns specified by a user. Which will be contained within displayColumns i.e. ['value1', 'value2', 'value3'] i want to iterate over this set of values to provide me with the correct reference to each value in the model.
I don't know what the syntax is for substituting the column name into an expression so that when angular compiles it, it would look like -> {{device.name.value1.value.value}} ... I've tried [] but that obviously didn't work!
<tbody md-body>
<tr md-row ng-repeat="device in $ctrl.devices track by device.mRID">
<td md-cell ng-click="$ctrl.detailedView($event, device)">{{device.aliasName}}</td>
<td md-cell>{{device.mRID}}</td>
<td md-cell ng-repeat="column in $ctrl.displayColumns">{{device.name.[column].value.value}} {{device.name.[column].unit.symbol}}<td>
</tr>
</tbody>
This is called bracket notation:
{{device.name[column].value.value}} {{device.name[column].unit.sybmol}}
Not this:
{{device.name.[column].value.value}} {{device.name.[column].unit.sybmol}}
<tr>
<tr>
<td class="style1" valign="top"> URL : </td>
<td class="style3">
<span id="lblPresenter" class="bord">https://testurl.net</span>
</td>
</tr>
</tr>
enter code here
we1 = driver.findElement(By.xpath("//*[#id='lblPresenter']"));
System.out.println(we1.getAttribute("InnerHTML"));
//I am getting Null as result
or
System.out.println(we1.getText());
//I am not getting any result
strong text
I need to get URL from the above source code .
If any body have a solution please let me know .
In general, XPath should be avoided because it's slower and more error prone. This is a simple scenario that doesn't require an XPath. You can do the same thing using By.id()
WebElement ele = driver.findElement(By.id("lblPresenter"));
System.out.println(ele.getAttribute("innerHTML"));
System.out.println(ele.getText());
One issue with your we1.getAttribute("InnerHTML") is that the i in innerHTML should not be capitalized. Please try the above code and see if that works. If not, please post the results/errors.
I want do use two different ng-repeat loops in a table to kind of group different obejcts with each other but don't know really how to do it.
My code right now:
...
<tbody>
<tr ng-repeat="person1 in Array1">
<td>{{ person1.address }}</td>
<td>{{ person1.city}}</td>
<td>{{ person1.email}}</td>
</tr>
<tr ng-repeat="person2 in Array2">
<td>{{partner2.address }}</td>
<td>{{partner2.city}}</td>
<td>{{partner2.email}}</td>
</tr>
</tbody>
...
The result/table i'm aiming for:
person1[1].address | person1[1].city | person1[1].email
---------------------------------------------------------------
person2[1].address | person2[1].city | person2[1].email
---------------------------------------------------------------
person1[2].address | person1[2].city | person1[2].email
---------------------------------------------------------------
person2[2].address | person2[2].city | person2[2].email
---------------------------------------------------------------
That is, i'd like to the ng-repeat to out put person1[1] and person2[1] before putting out person1[2].
Is the solution to add an outer array, containing my two current arrays or are there any better solution?
best regards
Assuming you could ensure that your array had no null values and were the same length, you could use this technique:
Create a new array initialized to the length of the two other arrays and iterate on this to get $index.
Put your ng-repeat on the body ( you can have multiple body elements in a table).
You'd get something like this:
var counterArray = new Array(array1.length);
<tbody ng-repeat="item in counterArray">
<tr>
<td>{{ Array1[$index].address }}</td>
<td>{{ Array1[$index].city}}</td>
<td>{{ Array1[$index].email}}</td>
</tr>
<tr >
<td>{{ Array2[$index].address }}</td>
<td>{{ Array2[$index].city}}</td>
<td>{{ Array2[$index].email}}</td>
</tr>
</tbody>
It might be safer to use a getter function on those arrays also:
getData(index,array,value)
Where you can prevent any null errors from occurring.
I'm working on my first ASP Classic app, it's just a simple one that adds data to a MSSQL database, and displays all the records on another page...
I have everything seemingly working, except when I go to the view page it displays all the records in their own table, instead of displaying as one table with a header row, and then multiple records in multiple rows.
I'm not looking for someone to solve it for me, that's not how I learn, but if someone could point me in the right direction, where I could figure it out I'd sure appreciate it!
Sample Code:
<table border="1">
<tr>
<td><%=objRec.Fields("keyfield").Value%></td>
<td><%=objRec.Fields("server_application").Value%></td>
<td><%=objRec.Fields("environment").Value%></div></td>
<div align="center"><%=objRec.Fields("ip_address").Value%></td>
<td><%=objRec.Fields("url").Value%></td>
<td><%=objRec.Fields("server_name").Value%></td>
<td><%=objRec.Fields("obsolete").Value%></td>
</tr>
</table>
<% rownum = rownum + 1
objRec.MoveNext
Wend
objRec.Close()
Conn.Close()
Set objRec = Nothing
Set Conn = Nothing
%>
Here is how it should be
<table border="1">
<thead>
<tr>
<td>Key Field</td>
<td>Server Application</td>
<td>Field 3 header</td>
<td>Field 4 header</td>
<td>Field 5 header</td>
<td>Field 6 header</td>
<td>Field 7 header</td>
</tr>
</thead>
<tbody>
<% Do while not objRec.EOF %>
<tr>
<td><%=objRec.Fields("keyfield").Value%></td>
<td><%=objRec.Fields("server_application").Value%></td>
<td><%=objRec.Fields("environment").Value%></div></td>
<div align="center"><%=objRec.Fields("ip_address").Value%></td>
<td><%=objRec.Fields("url").Value%></td>
<td><%=objRec.Fields("server_name").Value%></td>
<td><%=objRec.Fields("obsolete").Value%></td>
</tr>
<% objRec.MoveNext()
Loop %>
</tbody>
</table>
<%
objRec.Close()
Conn.Close()
Set objRec = Nothing
Set Conn = Nothing
%>