- From: Erik Bruchez <ebruchez@orbeon.com>
- Date: Tue, 27 Nov 2018 22:24:09 -0800
- To: Alain Couthures <alain.couthures@agencexml.com>
- Cc: Steven Pemberton <steven.pemberton@cwi.nl>, XForms <public-xformsusers@w3.org>
- Message-ID: <CAAc0PEUEaG0p6xxJi6iH7ZOEtXQVbFjHmTfByb5b61Tn_AEgTg@mail.gmail.com>
Steven, Alain: I just got to reading this. I agree with Alain and just repeating over `//*` and obtaining indentation by counting ancestors works really well. -Erik On Thu, Nov 8, 2018 at 1:32 AM Alain Couthures < alain.couthures@agencexml.com> wrote: > Hello Steven, > > I have already been using, as a workaround, a unique repeat on the > descendant:: axis because nodes are always listed in document order. Then, > counting how many ancestors each one has, allows to indent rendering > accordingly. > > I wrote, for some XML Prague Demo Jam, a simple XML editor with a very > short form indeed. > > This is not a fully satisfying approach because the tree structure is > flattened and it is, then, not possible to effectively produce embedded > sub-trees from this. > > --Alain > > Le 7 novembre 2018 à 17:22, Steven Pemberton <steven.pemberton@cwi.nl> a > écrit : > > > I have an XForm, where I don't know what the incoming data looks like, but > I want to view and browse it. > > This is what I do currently: > > <group> > <label>DATA</label> > <!-- NEST --> > <repeat ref="*"> > <output value="concat(name(.), ': ')"/> > <output ref=".[count(*)=0]"><label/></output> > <group ref=".[count(*)!=0]"> > <repeat ref="@*" class="inline"> > <output ref="."><label><output value="concat('@', name(.), > '=')"/></label></output> > </repeat> > <!-- NEST --> > <repeat ref="*"> > <output value="concat(name(.), ': ')"/> > <output ref=".[count(*)=0]"><label/></output> > <group ref=".[count(*)!=0]"> > <repeat ref="@*" class="inline"> > <output ref="."><label><output value="concat('@', > name(.), '=')"/></label></output> > </repeat> > <!-- NEST --> > AND SO ON AS DEEP AS I WANT > </group> > </repeat> > </group> > </repeat> > </group> > > Example output: > DATA > environment: > night: > location: > people: > count: 0 > systemHealth: > messages: > router: router is not available (timeout connecting to 192.168.1.1) > status: > igor: > core: > alive: true > lastActivity: 1541515205.12 > lastSuccess: 1541515205.12 > ignoreErrorUntil: > errorMessage: > save: > alive: true > lastActivity: 1541603734.74 > lastSuccess: 1541603734.74 > ignoreErrorUntil: > errorMessage: > etc. > > What you can see is that the markup between consecutive NESTs is > identical, displaying the name of the element, its attributes, and then > drops down one level in the hierarchy for the children of the element. > > The main disadvantage is that you can't go any deeper than the level of > nesting in the code: it can't react dynamically to deeper levels. > > The structure of the markup is this: > > <repeat ref="*"> > <output value="concat(name(.), ': ')"/> > <output ref=".[count(*)=0]"><label/></output> > <group ref=".[count(*)!=0]"> > <repeat ref="@*" class="inline"> > <output ref="."><label><output value="concat('@', name(.), > '=')"/></label></output> > </repeat> > RECURSE HERE > </group> > </repeat> > > It strikes me that there is a direct, if simpler, counterpart in repeats: > > <repeat ref="whatever"> > TEMPLATE > </repeat> > > and what we have is > > <traverse ref="whatever"> > TEMPLATE START > <descend/> > TEMPLATE END > </traverse> > > In my case: > > <traverse ref="*"> > <output value="concat(name(.), ': ')"/> > <output ref=".[count(*)=0]"><label/></output> > <group ref=".[count(*)!=0]"> > <repeat ref="@*" class="inline"> > <output ref="."><label><output value="concat('@', name(.), > '=')"/></label></output> > </repeat> > <descend ref="*"/> > </group> > </traverse> > > Anyone experience with using or implementing something like this? > > Steven > >
Received on Wednesday, 28 November 2018 06:24:42 UTC