asciidoc: source block aligned into nested list item - asciidoc

I'm trying to arrange tabulation.
I need a source block is nested block inside a nested list item:
list:
. Restore buckups
* List logical names:
+
RESTORE FILELISTONLY from DISK = '/var/opt/mssql/backup/xxxx.bak'
+
Sample output:
[source,options="nowrap"]
----
include::doc/samples/logical_names.out[]
----
* Another nested list element...
Currently, it appears as:
I need source block is arranged at the same level of nested list item.
Any ideas.

In your example source, the source block terminates the Sample output: paragraph. Since there is no continuation included, it also terminates the list item, and the list, because a source block is not a list item (by itself).
The solution is to include a continuation between the two elements:
Sample output:
+
[source,options="nowrap"]
Note that you'll need to add a blank line between the source block and the next list item, to provide a clear separation between the two.

Related

Can a list in Restructured Text (reST) extend section numbers?

I have an RST document like this:
Introduction
------------
Some intro text.
Next Level Stuff
----------------
1. The first list item
2. The second list item
3. The third list item
I'm trying either a :numbered: toctree or .. sectnum:: to number the sections of my document, and have the numbered list inherit the section number. I'm trying to get a result like this:
1. Introduction
2. Next Level Stuff
2.1 The first list item
2.2 The second list item
2.3 The thirst list item
Is this structure supported in RST?

Replace List Item Appinventor

I have a TinyDB and in each tag of the TinyDB I have a list.
Each list has 3 items, each indexed as 1, 2 and 3.
I want to change the 3rd item, index 3.
So I have done the following
So I want to now save the change in the TinyDB
and have added a storeValue command as follows.
I figured out how to get the valuetoStore variable. As follows.
I had done this before, and thought it wrong because it still doesn't change the 3rd item in the list. But I've added a notifier to look at it and it's correct. So the "replace list item" isn't working how I thought it should. It isn't replacing the 3rd item with an "n."
Any ideas?
Thanks.
Your second try is almost correct. The only thing is, you should use the replace list item block together with the local variable name instead of retrieving the value again from TinyDB.
So what is the difference to your "solution"? Currently you assign the list to a local variable name. Then you use the replace list item block together with a list, you can't store somewhere (you are loading the list again from TinyDB). And in the end you store variable name (which doesn't have been modified at all) in TinyDB. Therefore the solution is to use the replace list item block together with the local variable name instead of retrieving the value again from TinyDB. Btw. a better name for the local variable name would be list.
Further tips
Also in the definition of the local variable name you should add a block, e.g. an empty string or 0
And if you want simplify a little bit, you can move the definition of the local variable name inside the for each loop. And alternatively of using the for each number loop, for list it's easier to use the for each item in list loop, see also the documentation. The list in your case is TinyDB1.GetTags.
As already said in the forum, generally I would use a list of lists and store it in only one tag in TinyDB
How to work with Lists by Saj
How to work with Lists and Lists of lists (pdf) by appinventor.org

BaseX XQuery error: root(): no context value bound

I am trying to run the following XQuery expression in BaseX to extract elements between two succeeding headings. (as an article section).
xquery for $x in doc("test.xq")//h2,
$y in $x/following-sibling::h2[1]
return //*[$x/following::* and $y/preceding::*]
But it gives the error
Error:
Stopped at D:/Program Files/BaseX/data/test.xq, 1/74:
[XPDY0002] root(): no context value bound.
By the expression I mean if $x is heading and $y is the first heading following $x, then select the common text for $x/following::* and $y/preceding::*
However I am not sure my expression works, but my question here is how can execute my intended query without error?
If you have also an expression which works for my need, that is welcomed.
[...] to extract elements between two succeeding headings [...]
You need something more like:
for $x in doc("test.xq")//h2
return $x/following-sibling::*[preceding-sibling::h2[1] is $x]
but on its own it won't give you anything useful because the XPath and XQuery data model only has flat sequences, not "multi-dimensional arrays". When you have a for that returns a sequence of values for each "iteration", the overall result of the for expression is the concatenation of all the result sequences, so as written above this expression will simply return you all the elements in every "section" in a single flat list. If you want to group the elements by section then you'd need to construct a new XML element for each group
for $x in doc("test.xq")//h2
return
<section>{$x/following-sibling::*[preceding-sibling::h2[1] is $x]}</section>
The error (as documented here) comes from this expression:
//*[$x/following::* and $y/preceding::*]
which begins with //. The abbreviation // stands for /descendant-or-self::node()/, which of course begins with /. The XPath standard says:
A / by itself selects the root node of the document containing the
context node. If it is followed by a relative location path, then the
location path selects the set of nodes that would be selected by the
relative location path relative to the root node of the document
containing the context node.
But from what you've shown us, there is nothing indicating that you've established a context node. So XPath doesn't have any way to know what document contains the context node. That's what the error message is referring to when it says
root(): no context value bound
To fix the error, you could precede the // with an explicit doc(...) or any other explicit way to set the context:
doc("test.xq")//*[$x/following::* and $y/preceding::*]
or
root($x)//*[$x/following::* and $y/preceding::*]
This should get rid of the error, but as Ian Roberts has written, it won't give you the result you want. See his answer for that.

App Inventor TinyWebDB List Problems

I got a problem using the TinyWebDB in App Inventor 2. Here's a Screenshot of the blockcode.
The goal of this Screen is to store a list(array) of images and later query them with a button but my problem starts already earlier. First there is a variable initialized called fotoList and declared as an empty list.
When this Screen initializes (left block) I store the empty fotoList under the tag FotoListTag. Then if the image under the tag "SteckbriefFoto" is not in this list -> getValue with tag "FotoListTag". Then he jumps into the block on the right and adds the photo .. other stuff not important .. at the end I store the list again in the TinyWebDB (and also in the TinyDB) with the tag "FotoListTag". Then it goes back to the block on the left where at the end I want to set an image.picture to the photo I stored in variable fotoList.
When I compile the code there is an error opening the page that says
Select list item: List index too large
Select list item: Attempt to get item number 1 of a list of length 0:()
I just don't get the problem with this code and i hope someone can help me.
For lists, valueIfTagNotThere should be create empty list instead of an empty string
On first run of your app, TinyDB is empty, which means, for tag = FotoListTag you get no value back, therefore this should be an empty list in the beginning.
Later you are trying to select the first item from the list (zahl is 1). As you know, the list is empty in the beginning, so probably you should add an if statement to check, if the list is not empty and only then select the first item... same for tag = Schriftlist.
You also have a timing issue. in Screen.Initialize you are trying to get a value from TinyWebDB. This is an asynchronous call, you get the result back in TinyWebDB.GotResult event and this takes a little bit (let's say 500 milliseconds), but meanwhile the complete blocks of the Screen.Initialize event will be executed. Probably you are expecting, that meanwhile tag = FotolistTag is not empty anymore, but this is not the case.

Keeping track of path while recursively going through branches (more info in description )- Using Tcl

Background:
Writting script in Tcl
Running the script using a tool called IDSBatch from linux (centos) terminal
I have a system (.rdl file) that contains blocks, groups and registers.
Blocks can contain other blocks, groups, or registers. Whereas groups can only have registers and registers stand alone.
The problem I am having is I want to print out the "address" of each register i.e the name of the block(s), group and register associated with that specific register. For example:
______Block (a)______
| |
Block (b) reg(bob)
| |
group(tall) group(short)
| | |
reg(bill) reg(bobby) reg(burt)
In the end the output should be something along the lines of:
reg one: a.bob
reg two: a.b.tall.bill
reg three: a.b.tall.bobby
reg four: a.b.short.burt
The true problem comes from the fact that blocks can contain blocks. So the system will not always have one to three levels (one level would be Block--reg, two levels would be Block--Block--reg or Block ---group---reg and so on...)
I was leaning to some sort of recursive solution, where I would access the element say a block and get all of it's children (groups,blocks and regs) then I would use the same function to access it's children (unless it's a register). This way it can take care of any combination blocks groups and registers but then I'm stuck on how to keep track of the address of a specific register.
Thank you for taking the time in reading this and would appreciate any input or suggestions.
You could use a list for doing that.
Starting with an empty list, you append all address parts to it. If you come across a register, you can then construct the path from front to back. After every level of recursion, you remove the last element to get rid of the part you handled.
Example: you just came across the register bill. Then, your list is a -> b ->tall. To get the address, you iterate over the list and concatenate the nodes together, then appending bill to the resulting string.
So, your recursion function would be somewhat like
If the currently handled element is a register: Reconstruct the path.
If the currently handled element is not a register: Append the path element to the list, call the function with that list and remove the last element of that list.

Resources