kableExtra HTML tables in exams2blackboard do not render properly in Blackboard Ultra VLE - kable

I have the following R/Markdown code that uses R/exams and kableExtra to generate a randomised question for use in the Blackboard Ultra VLE. Although it renders fine in plain HTML when I import the generated archive from exams2blackboard() into the VLE the tables are rendered as plain text.
The R/Markdown exercise file:
```{r data generation, echo = FALSE, results = "hide"}
## DATA GENERATION
create_table <- function() {
male <- rnorm(12, mean=85, sd=10)
female <- rnorm(12, mean=80, sd=7)
matrix(c(male, female), nrow = 12, dimnames = list(NULL,c("Male", "Female")))
}
create_table_empty <- function() {
header <- c("", "Male", "Female")
dat <- c("Mean number of correct MRT responses", "Mean ± SD", "Mean ± SD")
matrix(dat,nrow = 1, dimnames = list(NULL,header))
}
public <- create_table()
empty_table <- create_table_empty()
row.names(public) <- NULL
maleMean <- mean(public[,1])
maleSD <- sd(public[,1])
femaleMean <- mean(public[,2])
femaleSD <- sd(public[,2])
repeat {
if(maleMean > femaleMean && femaleSD < maleSD) {
break
}
public <- create_table()
empty_table <- create_table_empty()
row.names(public) <- NULL
maleMean <- mean(public[,1])
maleSD <- sd(public[,1])
femaleMean <- mean(public[,2])
femaleSD <- sd(public[,2])
}
sol <- c( maleMean, maleSD, femaleMean, femaleSD)
questions <- c(paste("Male Mean ± SD: ", format(sol[1], digits = 2),"±", format(sol[2], digits = 2), ", Female Mean ± SD: ", format(sol[3], digits = 2), "±", format(sol[4], digits = 2)),
paste("Male Mean ± SD: ", format(sol[1], digits = 2),"±", format(sol[2] + runif(1, min=1, max=3), digits = 2), ", Female Mean ± SD: ", format(sol[3], digits = 2), "±", format(sol[4] - runif(1, min=1, max=3),digits = 2)),
paste("Male Mean ± SD: ", format(sol[1] + runif(1, min=5, max=15), digits = 2),"±", format(sol[2], digits = 2) , ", Female Mean ± SD: ", format(sol[3] + runif(1, min=10, max=30), digits = 2), "±", format(sol[4], digits = 2)),
paste("Male Mean ± SD: ", format(sol[1], digits = 2),"±", format(sol[2], digits = 2), ", Female Mean ± SD: ", format(sol[3] + runif(1, min=10, max=30), digits = 2), "±", format(sol[4] - runif(1, min=1, max=3), digits = 2)),
paste("Male Mean ± SD: ", format(sol[1] + runif(1, min=10, max=30),digits = 2),"±", format(sol[2]- runif(1, min=1, max=3), digits = 2), ", Female Mean ± SD: ", format(sol[3], digits = 2) , "±", format(sol[4], digits = 2) ))
```
Question
========
```{r, echo = FALSE, comment = NA, results='asis'}
library("knitr")
library("kableExtra")
library("dplyr")
public %>%
kable(digits = 2,format = "html", booktabs = TRUE) %>%
column_spec (1:2,border_left = T, border_right = T) %>%
row_spec(1:12, hline_after = T, ) %>%
kable_styling(
bootstrap_options = "bordered", full_width = FALSE, position = "left")
```
Calculate the mean and standard deviation for the male and female participants' responses respectively.
```{r, echo = FALSE, comment = NA, results='asis'}
empty_table %>%
kable(caption = "Table 1:__",format = "html", booktabs = TRUE) %>%
column_spec (1:2,border_left = T, border_right = T) %>%
row_spec(0:1, hline_after = T, ) %>%
kable_styling(bootstrap_options = "bordered", full_width = FALSE, position = "left")
```
So when I run exams2blackboard("code.Rmd") it generates the following HTML snippet in the .dat file.
<table class="table table-bordered" style="width: auto !important; ">
<thead>
<tr>
<th style="text-align:right;">
Male
</th>
<th style="text-align:right;">
Female
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:right;border-left:1px solid;border-right:1px solid;">
80.45
</td>
<td style="text-align:right;border-left:1px solid;border-right:1px solid;">
89.37
</td>
</tr>
<tr>
<td style="text-align:right;border-left:1px solid;border-right:1px solid;">
84.76
</td>
<td style="text-align:right;border-left:1px solid;border-right:1px solid;">
92.89
</td>
</tr>
<tr>
<td style="text-align:right;border-left:1px solid;border-right:1px solid;">
76.23
</td>
<td style="text-align:right;border-left:1px solid;border-right:1px solid;">
78.47
</td>
</tr>
<tr>
<td style="text-align:right;border-left:1px solid;border-right:1px solid;">
97.08
</td>
<td style="text-align:right;border-left:1px solid;border-right:1px solid;">
75.27
</td>
</tr>
<tr>
<td style="text-align:right;border-left:1px solid;border-right:1px solid;">
81.66
</td>
<td style="text-align:right;border-left:1px solid;border-right:1px solid;">
85.22
</td>
</tr>
<tr>
<td style="text-align:right;border-left:1px solid;border-right:1px solid;">
85.11
</td>
<td style="text-align:right;border-left:1px solid;border-right:1px solid;">
79.01
</td>
</tr>
<tr>
<td style="text-align:right;border-left:1px solid;border-right:1px solid;">
86.78
</td>
<td style="text-align:right;border-left:1px solid;border-right:1px solid;">
84.86
</td>
</tr>
<tr>
<td style="text-align:right;border-left:1px solid;border-right:1px solid;">
100.67
</td>
<td style="text-align:right;border-left:1px solid;border-right:1px solid;">
73.63
</td>
</tr>
<tr>
<td style="text-align:right;border-left:1px solid;border-right:1px solid;">
94.16
</td>
<td style="text-align:right;border-left:1px solid;border-right:1px solid;">
79.34
</td>
</tr>
<tr>
<td style="text-align:right;border-left:1px solid;border-right:1px solid;">
92.22
</td>
<td style="text-align:right;border-left:1px solid;border-right:1px solid;">
71.18
</td>
</tr>
<tr>
<td style="text-align:right;border-left:1px solid;border-right:1px solid;">
72.81
</td>
<td style="text-align:right;border-left:1px solid;border-right:1px solid;">
77.73
</td>
</tr>
<tr>
<td style="text-align:right;border-left:1px solid;border-right:1px solid;">
95.00
</td>
<td style="text-align:right;border-left:1px solid;border-right:1px solid;">
74.89
</td>
</tr>
</tbody>
</table>
<p>Calculate the mean and standard deviation for the male and female participants’ responses respectively.</p>
<table class="table table-bordered" style="width: auto !important; ">
<caption>
Table 1:__
</caption>
<thead>
<tr>
<th style="text-align:left;">
</th>
<th style="text-align:left;">
Male
</th>
<th style="text-align:left;">
Female
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left;border-left:1px solid;border-right:1px solid;">
Mean number of correct MRT responses
</td>
<td style="text-align:left;border-left:1px solid;border-right:1px solid;">
Mean ± SD
</td>
<td style="text-align:left;">
Mean ± SD
</td>
</tr>
</tbody>
</table>
Bur when I import the question in Blackboard Ultra it collapses the table into plain text. So it renders as follows.
Male Female 80.45 89.37 84.76 92.89 76.23 78.47 97.08 75.27 81.66 85.22 85.11 79.01 86.78 84.86 100.67 73.63 94.16 79.34 92.22 71.18 72.81 77.73 95.00 74.89
Calculate the mean and standard deviation for the male and female participants’ responses respectively.
Table 1:__ Male Female Mean number of correct MRT responses Mean ± SD Mean ± SD
Has anyone had any luck creating tables that work with exams2blackboard?

Related

Sort list by order number with record grouping

I have a list of orders. I would like to sort the list in the way that if there are more than one order placed by the same customer, the orders are grouped. It is hard to explain by words so here is an example:
This is the list sorted by Order No:
<table>
<tr>
<th>Customer</th>
<th>Order No</th>
</tr>
<tr>
<td>A</td>
<td>1</td>
</tr>
<tr>
<td>B</td>
<td>2</td>
</tr>
<tr>
<td>C</td>
<td>3</td>
</tr>
<tr>
<td>A</td>
<td>4</td>
</tr>
<tr>
<td>A</td>
<td>5</td>
</tr>
<tr>
<td>D</td>
<td>6</td>
</tr><tr>
<td>C</td>
<td>7</td>
</tr>
</table>
I would like this list to look like this:
<table>
<tr>
<th>Customer</th>
<th>Order No</th>
</tr>
<tr>
<td>A</td>
<td>1</td>
</tr>
<tr>
<td>A</td>
<td>4</td>
</tr>
<tr>
<td>A</td>
<td>5</td>
</tr>
<tr>
<td>B</td>
<td>2</td>
</tr>
<tr>
<td>C</td>
<td>3</td>
</tr>
<tr>
<td>C</td>
<td>7</td>
</tr>
<tr>
<td>D</td>
<td>6</td>
</tr>
</table>
I will be very grateful for any hint :)
Thank you!
You can create a map of customers and orders.
For each map entry create a list of ordernumbers.
Doing so you can sort every order list.
Example:
const list = [
{ customer: 'A', ordernumber: 2 },
{ customer: 'B', ordernumber: 1},
{ customer: 'A', ordernumber: 1 },
{ customer: 'A', ordernumber: 3 }
]
customerOrderMap = {}
list.forEach(element => customerOrderMap[element.customer] = [])
list.forEach(element => customerOrderMap[element.customer].push(element.ordernumber))
Object.keys(customerOrderMap).forEach(key => {
console.log(customerOrderMap[key].sort((a, b) => a - b))
})
console.log(customerOrderMap)

Perl XML::LibXML XPath 2.0 to XPath 1.0

I have the following XPath that works fine in XPath 2.0 (as tested in OxygenXML):
//h2[a[#id='start']]/following-sibling::*[not(preceding-sibling::*[self::div[#id='end']])]
but I'm getting different results when I use it with LibXML findnodes():
my #nodes = $source_doc->findnodes('//h2[a[#id="start"]]/following-sibling::*[not(preceding-sibling::*[self::div[#id="end"]])]');
After checking the LibXML documentation, it seems that LibXML supports XPath 1.0 only. How would I go about changing my XPath to something that works with XPath 1.0? Is it even possible to create a compatible path like this in XPath 1.0?
Since I've been asked to provide, I'm updating the post to include my sample data and the output I'm getting when I run the XPath I entered above:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="insn.css" />
<meta name="generator" content="encodingindex.xsl" />
<title>Index by Encoding</title>
</head>
<body><hr /><h1 class="topleveltable"><a name="top" id="top"></a>Top-level encodings</h1><div
class="regdiagram-32"></div><hr /><h2><a name="dp" id="start"></a>Data-processing and
miscellaneous instructions</h2><div class="decode_navigation">
<p>These instructions are under the top-level.</p>
</div><div class="regdiagram-32">
<table class="regdiagram">
<thead>
<tr>
<td>31</td>
<td>0</td>
</tr>
</thead>
<tbody>
<tr class="firstrow">
<td colspan="4" class="lr">!= 1111</td>
<td colspan="2" class="lr">00</td>
<td class="lr">op0</td>
<td colspan="5" class="lr">op1</td>
<td colspan="12" class="lr"></td>
<td class="lr">op2</td>
<td colspan="2" class="lr">op3</td>
<td class="lr">op4</td>
<td colspan="4" class="lr"></td>
</tr>
</tbody>
</table>
</div><div class="instructiontable">
<table class="instructiontable">
<tr>
<th colspan="5">Decode fields</th>
<th rowspan="2"> Instruction details </th>
</tr>
<tr>
<th class="bitfields">op0</th>
<th class="bitfields">op1</th>
<th class="bitfields">op2</th>
<th class="bitfields">op3</th>
<th class="bitfields">op4</th>
</tr>
<tr class="instructiontable">
<td class="bitfield"> 0 </td>
<td class="bitfield"> </td>
<td class="bitfield"> 1 </td>
<td class="bitfield"> != 00 </td>
<td class="bitfield"> 1 </td>
<td class="iformname">Extra load/store</td>
</tr>
<tr class="instructiontable">
<td class="bitfield"> 0 </td>
<td class="bitfield"> 0xxxx </td>
<td class="bitfield"> 1 </td>
<td class="bitfield"> 00 </td>
<td class="bitfield"> 1 </td>
<td class="iformname">Multiply and Accumulate</td>
</tr>
</table>
</div><hr /><h2><a name="sync" id="sync"></a>Synchronization primitives and
Load-Acquire/Store-Release</h2><div class="decode_navigation">
<p>These instructions are under <a href="#dp">Data-processing and miscellaneous
instructions</a>.</p>
</div><div class="regdiagram-32">
<table class="regdiagram">
<thead>
<tr>
<td>31</td>
<td>0</td>
</tr>
</thead>
<tbody>
<tr class="firstrow">
<td colspan="4" class="lr">!= 1111</td>
<td colspan="4" class="lr">0001</td>
<td class="lr">op0</td>
<td colspan="11" class="lr"></td>
<td colspan="2" class="lr">11</td>
<td colspan="2" class="lr"></td>
<td colspan="4" class="lr">1001</td>
<td colspan="4" class="lr"></td>
</tr>
</tbody>
</table>
</div><hr /><hr /><h2><a name="dpmisc" id="dpmisc"></a>Miscellaneous</h2><div
class="decode_navigation">
<p>These instructions are under <a href="#dp">Data-processing and miscellaneous
instructions</a>.</p>
</div><div class="regdiagram-32">
<table class="regdiagram">
<thead>
<tr>
<td>31</td>
<td>30</td>
<td>0</td>
</tr>
</thead>
<tbody>
<tr class="firstrow">
<td colspan="4" class="lr">!= 1111</td>
<td colspan="5" class="lr">00010</td>
<td colspan="2" class="lr">op0</td>
<td colspan="1" class="lr">0</td>
<td colspan="12" class="lr"></td>
<td colspan="1" class="lr">0</td>
<td colspan="3" class="lr">op1</td>
<td colspan="4" class="lr"></td>
</tr>
</tbody>
</table>
</div><div class="instructiontable">
<table class="instructiontable">
<tr>
<th colspan="2">Decode fields</th>
<th rowspan="2"> Instruction details </th>
</tr>
<tr>
<th class="bitfields">op0</th>
<th class="bitfields">op1</th>
</tr>
<tr class="instructiontable">
<td class="bitfield"> 01 </td>
<td class="bitfield"> 010 </td>
<td class="iformname">BXJ</td>
</tr>
<tr class="instructiontable">
<td class="bitfield"> 01 </td>
<td class="bitfield"> 011 </td>
<td class="iformname">BLX (register)</td>
</tr>
</table>
</div><div class="decode_navigation">
<p>These instructions are under <a href="#dp">Data-processing and miscellaneous
instructions</a>.</p>
</div><div class="regdiagram-32">
<table class="regdiagram">
<thead>
<tr>
<td>31</td>
<td>30</td>
<td>0</td>
</tr>
</thead>
<tbody>
<tr class="firstrow">
<td colspan="4" class="lr">!= 1111</td>
<td colspan="3" class="lr">000</td>
<td colspan="2" class="lr">op0</td>
<td colspan="2" class="lr"></td>
<td class="lr">op1</td>
<td colspan="15" class="lr"></td>
<td colspan="1" class="lr">0</td>
<td colspan="4" class="lr"></td>
</tr>
</tbody>
</table>
</div><div class="decode_constraints">
<p> The following constraints also apply to this encoding: op0:op1 != 100 </p>
</div><div class="instructiontable">
<table class="instructiontable">
<tr>
<th colspan="2">Decode fields</th>
<th rowspan="2"> Instruction details </th>
</tr>
<tr>
<th class="bitfields">op0</th>
<th class="bitfields">op1</th>
</tr>
<tr class="instructiontable">
<td class="bitfield"> 0x </td>
<td class="bitfield"> </td>
<td class="iformname"><a href="#intdp3reg_immsh">Integer Data Processing (three register,
immediate shift)</a></td>
</tr>
<tr class="instructiontable">
<td class="bitfield"> 10 </td>
<td class="bitfield"> 1 </td>
<td class="iformname"><a href="#intdp2reg_immsh">Integer Test and Compare (two register,
immediate shift)</a></td>
</tr>
<tr class="instructiontable">
<td class="bitfield"> 11 </td>
<td class="bitfield"> </td>
<td class="iformname"><a href="#logic3reg_immsh">Logical Arithmetic (three register,
immediate shift)</a></td>
</tr>
</table>
</div><hr /><div class="iclass" id="intdp3reg_immsh">
<a name="intdp3reg_immsh" id="intdp3reg_immsh"></a>
<h3 class="iclass">Integer Data Processing (three register, immediate shift)</h3>
<p>These instructions are under <a href="#dpregis">Data-processing register (immediate
shift)</a>.</p>
<div class="regdiagram-32">
<table class="regdiagram">
<thead>
<tr>
<td>31</td>
<td>0</td>
</tr>
</thead>
<tbody>
<tr class="firstrow">
<td colspan="4" class="lr">!= 1111</td>
<td class="l">0</td>
<td>0</td>
<td>0</td>
<td class="r">0</td>
<td colspan="3" class="lr">opc</td>
<td class="lr">S</td>
<td colspan="4" class="lr">Rn</td>
<td colspan="4" class="lr">Rd</td>
<td colspan="5" class="lr">imm5</td>
<td colspan="2" class="lr">type</td>
<td class="lr">0</td>
<td colspan="4" class="lr">Rm</td>
</tr>
<tr class="secondrow">
<td colspan="4" class="droppedname">cond</td>
<td colspan="4"></td>
<td colspan="3"></td>
<td></td>
<td colspan="4"></td>
<td colspan="4"></td>
<td colspan="5"></td>
<td colspan="2"></td>
<td></td>
<td colspan="4"></td>
</tr>
</tbody>
</table>
</div>
<div class="decode_constraints">
<p> The following constraints also apply to this encoding: cond != 1111 && cond !=
1111 </p>
</div>
<div class="instructiontable">
<table class="instructiontable" id="intdp3reg_immsh">
<thead class="instructiontable">
<tr>
<th class="bitfields-heading" rowspan="" colspan="3">Decode fields</th>
<th class="iformname" rowspan="2" colspan=""> Instruction Details </th>
</tr>
<tr>
<th class="bitfields" rowspan="" colspan="">opc</th>
<th class="bitfields" rowspan="" colspan="">S</th>
<th class="bitfields" rowspan="" colspan="">Rn</th>
</tr>
</thead>
<tbody>
<tr>
<td class="bitfield">000</td>
<td class="bitfield"></td>
<td class="bitfield"></td>
<td class="iformname"><a name="AND_r" href="and_r.html" id="AND_r">AND, ANDS
(register)</a></td>
</tr>
<tr>
<td class="bitfield">001</td>
<td class="bitfield"></td>
<td class="bitfield"></td>
<td class="iformname"><a name="EOR_r" href="eor_r.html" id="EOR_r">EOR, EORS
(register)</a></td>
</tr>
</tbody>
</table>
</div>
</div><div class="decode_constraints">
<p> The following constraints also apply to this encoding: op0:op1 != 100 </p>
</div><div class="instructiontable">
<table class="instructiontable">
<tr>
<th colspan="2">Decode fields</th>
<th rowspan="2"> Instruction details </th>
</tr>
<tr>
<th class="bitfields">op0</th>
<th class="bitfields">op1</th>
</tr>
<tr class="instructiontable">
<td class="bitfield"> 0x </td>
<td class="bitfield"> </td>
<td class="iformname"><a href="#intdp3reg_regsh">Integer Data Processing (three register,
register shift)</a></td>
</tr>
<tr class="instructiontable">
<td class="bitfield"> 10 </td>
<td class="bitfield"> 1 </td>
<td class="iformname"><a href="#intdp2reg_regsh">Integer Test and Compare (two register,
register shift)</a></td>
</tr>
</table>
</div><hr /><h2><a name="dpimm" id="dpimm"></a>Data-processing immediate</h2><div
class="decode_navigation">
<p>These instructions are under <a href="#dp">Data-processing and miscellaneous
instructions</a>.</p>
</div><div class="regdiagram-32">
<table class="regdiagram">
<thead>
<tr>
<td>31</td>
<td>0</td>
</tr>
</thead>
<tbody>
<tr class="firstrow">
<td colspan="4" class="lr">!= 1111</td>
<td colspan="3" class="lr">001</td>
<td colspan="2" class="lr">op0</td>
<td colspan="1" class="lr"></td>
<td colspan="2" class="lr">op1</td>
<td colspan="20" class="lr"></td>
</tr>
</tbody>
</table>
</div><div class="instructiontable">
<table class="instructiontable">
<tr>
<th colspan="2">Decode fields</th>
<th rowspan="2"> Instruction details </th>
</tr>
<tr>
<th class="bitfields">op0</th>
<th class="bitfields">op1</th>
</tr>
<tr class="instructiontable">
<td class="bitfield"> 0x </td>
<td class="bitfield"> </td>
<td class="iformname"><a href="#intdp2reg_imm">Integer Data Processing (two register and
immediate)</a></td>
</tr>
</table>
</div><hr /><div class="iclass" id="intdp2reg_imm">
<a name="intdp2reg_imm" id="intdp2reg_imm"></a>
</div><div class="iclass" id="end">
<a name="ldstimm" id="ldstimm"></a>
<h3 class="iclass">Load/Store Word, Unsigned Byte (immediate, literal)</h3>
<div class="regdiagram-32">
<table class="regdiagram">
<thead>
<tr>
<td>31</td>
<td>0</td>
</tr>
</thead>
<tbody>
<tr class="firstrow">
<td colspan="4" class="lr">!= 1111</td>
<td class="l">0</td>
<td>1</td>
<td class="r">0</td>
<td class="lr">P</td>
<td class="lr">U</td>
<td class="lr">o2</td>
<td class="lr">W</td>
<td class="lr">o1</td>
<td colspan="4" class="lr">Rn</td>
<td colspan="4" class="lr">Rt</td>
<td colspan="12" class="lr">imm12</td>
</tr>
<tr class="secondrow">
<td colspan="4" class="droppedname">cond</td>
<td colspan="3"></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td colspan="4"></td>
<td colspan="4"></td>
<td colspan="12"></td>
</tr>
</tbody>
</table>
</div>
<div class="decode_constraints">
<p> The following constraints also apply to this encoding: cond != 1111 && cond !=
1111 </p>
</div>
<div class="instructiontable">
<table class="instructiontable" id="ldstimm">
<thead class="instructiontable">
<tr>
<th class="bitfields-heading" rowspan="" colspan="4">Decode fields</th>
<th class="iformname" rowspan="2" colspan=""> Instruction Details </th>
</tr>
<tr>
<th class="bitfields" rowspan="" colspan="">P:W</th>
<th class="bitfields" rowspan="" colspan="">o2</th>
<th class="bitfields" rowspan="" colspan="">o1</th>
<th class="bitfields" rowspan="" colspan="">Rn</th>
</tr>
</thead>
<tbody>
<tr>
<td class="bitfield">!= 01</td>
<td class="bitfield">0</td>
<td class="bitfield">1</td>
<td class="bitfield">1111</td>
<td class="iformname"><a name="LDR_l" href="ldr_l.html" id="LDR_l">LDR
(literal)</a></td>
</tr>
<tr>
<td class="bitfield">!= 01</td>
<td class="bitfield">1</td>
<td class="bitfield">1</td>
<td class="bitfield">1111</td>
<td class="iformname"><a name="LDRB_l" href="ldrb_l.html" id="LDRB_l">LDRB
(literal)</a></td>
</tr>
</tbody>
</table>
</div>
</div></body>
</html>
Here's the output using the XPath given above:
<div class="decode_navigation">
<p>These instructions are under the top-level.</p>
</div>
Just to clarify, the output should include all of the divs in the sample HTML, about 400 lines in total.
I've also tried the XPath suggestions I've been given below, but they produced the same results.
Edit: Here's my code:
use strict;
use warnings;
use feature 'say';
use XML::LibXML;
my $encoding_index_file = q(C:\path\to\testfile.html);
my $source_doc = XML::LibXML->load_html(
location => $encoding_index_file,
recover => 1,
suppress_errors => 1,
);
my ($node) = $source_doc->findnodes('//h2[a[#id="start"]]/following-sibling::*[not(preceding-sibling::div[#id="end"])]');
say $node->toString;
Not only does that XPath conform to XPath 1.0, it works correctly in XML::LibXML.
use strict;
use warnings qw( all );
use feature qw( say );
use XML::LibXML qw( );
my $doc = XML::LibXML->new->parse_html_string(<<'__EOS__');
<html>
<h2><a id="start">Foo</a></h2>
<div id="pre1"><img></div>
<div id="pre2"><img></div>
<div id="end"><img></div>
<div id="post1"><img></div>
<div id="post2"><img></div>
</html>
__EOS__
# Select all the siblings of the starting h2 element that follow
# it and don't have <div id="end"/> as a preceding sibling.
for my $node ($doc->findnodes('//h2[a[#id="start"]]/following-sibling::*[not(preceding-sibling::*[self::div[#id="end"]])]')) {
my $name = $node->nodeName;
my $id = $node->getAttribute('id');
say $id ? sprintf("%s#%s", $name, $id) : $name;
}
Output:
div#pre1
div#pre2
div#end
By the way,
//h2[a[#id="start"]]/following-sibling::*[not(preceding-sibling::*[self::div[#id="end"]])]
is a weird way of writing
//h2[a[#id="start"]]/following-sibling::*[not(preceding-sibling::div[#id="end"])]
Maybe you wanted
//h2[a[#id="start"]]/following-sibling::*[not(self::div[#id="end"] or preceding-sibling::div[#id="end"])]
That would produce the following output:
div#pre1
div#pre2
I managed to get to the bottom of what was causing the problem: Every sibling found by the XPath is handled by LibXML as a separate node, so I needed to assign them to an array, not a simple scalar as I was doing. The not-weird XPath suggested by ikegami was also better than the one I was using, as mine was doubling up everything in the output.
Here's the code that produces the correct results:
use strict;
use warnings;
use feature 'say';
use XML::LibXML qw( );
my $encoding_index_file = q(C:\path\to\testfile.html);
my $source_doc = XML::LibXML->load_html(
location => $encoding_index_file,
recover => 1,
suppress_errors => 1,
);
my $contents = "";
my #nodes = $source_doc->findnodes('//h2[a[#id="start"]]/following-sibling::[not(preceding-sibling::div[#id="end"])]');
foreach my $node (#nodes) {
my ($str) = $node->toString;
$contents = $contents . $str;
}
print $contents;

jtemplate giving ; expected below is my code

My Code is:
<table border="1" rules="all" cellpadding="0" width="100%" cellspacing="1" id="table1" style="text-align:center">
<thead>
{var tmpchannelid = '0'}
{#foreach $T as ChannelRoomBind}
{#if $T.ChannelRoomBind.channelid neq ${tmpchannelid}}
<tr class="midhead2_calen">
<td>{$T.ChannelRoomBind.ChannelName }</td>
</tr>
{#/if}
{ tmpchannelid = {$T.ChannelRoomBind.channelId}}
{#/for}
</thead>
<tbody>
<tr>
</tr>
</tbody>
</table>

Create top labels for nodes using graphviz (dot)

I need to create a graph representing a extendable hashing structure. So far I have had success with creating graphs in graphviz (using the dot tool)... I am however having trouble making top labels representing the number of bits for each bucket... What I want to do is something similar to this:
What I cannot get done are the small 2's and 1's representing bits.. Can anybody explain how I would go around doing this?
My graph so far looks like this:
digraph G {
nodesep = 0.5;
rankdir = LR;
node [shape=record];
node0[label = "<f0>0 | <f1>1"];
node1[label = "0010 | |", toplabel="1"];
subgraph cluster_0 {
style=filled;
color=white;
node [style=filled,color=white];
node0;
label = "i = 1";
}
node0:f0->node1;}
You may consider using HTML-Like labels if you really must do this with graphviz.
I recreated the mentioned example from wikipedia:
rankdir = LR;
node [shape=none];
splines=false;
n1[label=<
<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
<TR>
<TD CELLPADDING="2">2</TD>
<TD BORDER="0"></TD>
</TR>
<TR><TD COLSPAN="2" PORT="port00"> 00 </TD></TR>
<TR><TD COLSPAN="2" PORT="port01"> 01 </TD></TR>
<TR><TD COLSPAN="2" PORT="port10"> 10 </TD></TR>
<TR><TD COLSPAN="2" PORT="port11"> 11 </TD></TR>
</TABLE>>];
a[label=<
<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
<TR>
<TD CELLPADDING="0" BORDER="0" COLSPAN="2">
<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="2" FIXEDSIZE="TRUE" WIDTH="1" ALIGN="LEFT"><TR><TD>1</TD></TR></TABLE>
</TD>
</TR>
<TR>
<TD PORT="porta"> A </TD>
<TD>k2</TD>
</TR>
</TABLE>>];
b[label=<
<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
<TR>
<TD CELLPADDING="2">2</TD>
<TD BORDER="0" COLSPAN="2"></TD>
</TR>
<TR>
<TD PORT="portb" COLSPAN="2"> B </TD>
<TD>k1</TD>
</TR>
</TABLE>>];
c[label=<
<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
<TR>
<TD CELLPADDING="2">2</TD>
<TD BORDER="0" COLSPAN="2"></TD>
</TR>
<TR>
<TD PORT="portc" COLSPAN="2"> C </TD>
<TD>k3</TD>
</TR>
</TABLE>>];
n1:port00 -> a:porta;
n1:port01 -> a:porta;
n1:port10 -> b:portb;
n1:port11 -> c:portc;
As you can see, the code is not pretty... however, the result comes close:
http://graph.gafol.net/evEKgxwgj
Please note that there is a variation for the top label for demonstration purposes - node a uses a nested table.

Switching to jQuery 1.5 breaks a selector

just upgraded to jQuery 1.5 and now it seems the find() has problems with several selctores:
var $AlertColumn = $('[name=TABLE_1] tr').find('.SAPBEXstdData:eq(9), .SAPBEXstdDataOdd:eq(9), td.SAPBEXaggData:eq(9)');
as of 1.5 (and IE7), the thing hangs in IE7 with an error popup after a while that there's a script running forever.
It works perfect in 1.4.2.
ok here comes the code (to the first data row), I have to work on the Alert-Row which is the 9th having those classes used in find():
<TABLE class=SAPBEXCellspacing cellSpacing=1 cellPadding=0 width=1250 border=0 name="TABLE_1" sizcache="5" sizset="20"><TBODY sizcache="5" sizset="20">
<TR sizcache="5" sizset="21">
<TD noWrap colSpan=19 sizcache="5" sizset="21">
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0 sizcache="5" sizset="21">
<FORM name=SAPBWUForm5 action=/sap/bw/BEx?SAP-LANGUAGE=DE&ITEM=TABLE_1&STATE_ID=4KXJZOX5URFHG6BQFFTKAJ0OH&STATELESS=X&LAST_MESSAGE_ID=0 method=post sizcache="5" sizset="21">
<TBODY sizcache="5" sizset="21">
<TR sizcache="5" sizset="22">
<TD class=SAPBEXScrollVert noWrap sizcache="5" sizset="22">
<TABLE cellSpacing=0 cellPadding=1 border=0 sizcache="5" sizset="22">
<TBODY sizcache="5" sizset="22">
<TR>
<TD class=SAPBEXTxtStd noWrap><IMG title="Erste Zeile" alt="Erste Zeile" src="/sap/bw/Mime/BEx/Icons/page_first_row_inact.gif" border=0></TD>
<TD class=SAPBEXTxtStd noWrap><IMG title="Vorherige Zeilen" alt="Vorherige Zeilen" src="/sap/bw/Mime/BEx/Icons/page_up_inact.gif" border=0></TD>
<TD class=SAPBEXTxtStd noWrap> <LABEL>Zeile</LABEL></TD>
<TD noWrap><INPUT class=SAPBEXTxtFldright id=DATA_ROW_FROM title="Zeile - Maximale Anzahl: 170" onchange=document.SAPBWUForm5.submit() size=3 value=1 name=DATA_ROW_FROM></TD>
<TD class=SAPBEXTxtStd noWrap>/ 170 </TD>
<TD class=SAPBEXTxtStd noWrap><A title="Nächste Zeilen" href="JavaScript:SAPBW(5,'','','68')"><IMG title="Nächste Zeilen" alt="Nächste Zeilen" src="/sap/bw/Mime/BEx/Icons/page_down.gif" border=0></A></TD>
<TD class=SAPBEXTxtStd noWrap><A title="Letzte Zeile" href="JavaScript:SAPBW(5,'','','170')"><IMG title="Letzte Zeile" alt="Letzte Zeile" src="/sap/bw/Mime/BEx/Icons/page_last_row.gif" border=0></A></TD></TR></TBODY></TABLE></TD></FORM></TR></TBODY></TABLE></TD></TR>
<TR></TR>
<TR>
<TD class=SAPBEXchaText noWrap>Profit Center</TD>
<TD class=SAPBEXchaText noWrap>Projektleiter</TD>
<TD class=SAPBEXchaText noWrap colSpan=2>Projekt</TD>
<TD class=SAPBEXchaText noWrap>akt. Status</TD>
<TD class=SAPBEXchaText noWrap>akt. Status Dat.</TD>
<TD class=SAPBEXchaText noWrap>Kredit Datum</TD>
<TD class=SAPBEXchaText noWrap>letzte Buchung</TD>
<TD class=SAPBEXstdItem noWrap>Kredit</TD>
<TD class=SAPBEXstdItem noWrap>Ist Q1 2010</TD>
<TD class=SAPBEXstdItem noWrap>Ist Q2 2010</TD>
<TD class=SAPBEXstdItem noWrap>Ist Q3 2010</TD>
<TD class=SAPBEXstdItem noWrap>Ist Q4 2010</TD>
<TD class=SAPBEXstdItem noWrap>Kredit %</TD>
<TD class=SAPBEXstdItem noWrap>FC Q3</TD>
<TD class=SAPBEXstdItem noWrap>FC Q4</TD>
<TD class=SAPBEXstdItem noWrap>Projektende</TD>
<TD class=SAPBEXstdItem noWrap>Alert</TD>
<TD class=SAPBEXstdItem noWrap>Notizen</TD></TR>
<TR>
<TD class=SAPBEXstdItem noWrap rowSpan=7>PC100</TD>
<TD class=SAPBEXstdItem noWrap rowSpan=3>Ammann Conrad</TD>
<TD class=SAPBEXstdItem noWrap>G000034</TD>
<TD class=SAPBEXstdItem noWrap>Techn. Zusammenarbeit China</TD>
<TD class=SAPBEXstdItem noWrap>k.a.</TD>
<TD class=SAPBEXstdItem noWrap>#</TD>
<TD class=SAPBEXstdItem noWrap>#</TD>
<TD class=SAPBEXstdItem noWrap>#</TD>
<TD class=SAPBEXstdData title=0 noWrap>0</TD>
<TD class=SAPBEXstdData noWrap> </TD>
<TD class=SAPBEXstdData noWrap> </TD>
<TD class=SAPBEXstdData noWrap> </TD>
<TD class=SAPBEXstdData title=0 noWrap>0</TD>
<TD class=SAPBEXstdData noWrap> </TD>
<TD class=SAPBEXstdData noWrap> </TD>
<TD class=SAPBEXstdData noWrap> </TD>
<TD class=SAPBEXstdData noWrap> </TD>
<TD class=SAPBEXstdData noWrap>I NEED THIS ONE (9th) of every Data Row</TD>
<TD class=SAPBEXstdData title=0 noWrap>
<DIV class=notiz style="TEXT-ALIGN: left"></DIV></TD></TR>
<TR>
<TD class=SAPBEXstdItem noWrap>G000164</TD>
<TD class=SAPBEXstdItem noWrap>Tag der offenen Tür</TD>...
........
Try and put input in front of your selector (like input[name=TABLE_1] tr), because it may be that jQuery is looking through every element, including spans, divs, h1s, etc...
$('[name=TABLE_1] tr') seems invalid because TABLE or TBODY don't have any NAME attribute (correct me if I'm wrong).
Two different solutions:
If it ain't broke, don't fix it: stay with jQuery 1.4.2. or...
Rewrite the selector so that it selects more efficiently. Start with $('table[name=TABLE_1] tr'), and use a more specific selector in .find() - perhaps use .children() instead of .find()? Would need to see the actual markup for more specific suggestions.
Edit Your markup is horribly invalid. form is not a valid child of table, name is not a valid attribute of table (as pointed out by #Capsule), you're not using nowrap correctly... I recommend that you familiarize yourself with the W3C Validator and go from there.